fff90f42c4310e7913e93ee67f5cf411d5398a0c
[mirror/dsa-wiki.git] / input / howto / iscsi.creole
1 == Setup a new iscsi initiator ==
2
3 giustini is our storage, i.e. the target in iscsi terminology.
4 The initiator, i.e. the machine that wants to access iscsi
5 block devices, we will simply call host.
6
7 === host preparations ===
8
9 * On the host install open-iscsi
10 {{{
11     apt-get install open-iscsi
12 }}}
13
14 * Then run discovery once so that giustini knows it already.  Saves
15 some copy/pasting later on:
16 {{{
17     iscsiadm -m discovery -t st -p 10.0.0.17
18 }}}
19
20 * You should now see two lines in the output of
21 {{{
22     iscsiadm -m node
23 }}}
24 corresponding to the two addresses that controller A has:
25 {{{
26         dijkstra:~# iscsiadm -m node
27         10.0.0.17:3260,1 iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a
28         10.0.0.18:3260,2 iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a
29 }}}
30
31 === Meanwhile on Melee Islan^W^WGiustini ===
32
33 * Log into the web config interface (see dsa-passwords for details)
34 * Go to **Manage** -> **General Config** -> **Manage Host List** and give
35   the new host a nice nickname (i.e. its name).  If you did the
36   discovery above it should already be listed in the global host
37   list and you just need to set its name.  Else you would also need to
38   manually set the host's iqn (iscsi qualifiled name) which you can
39   find on the host in {{{/etc/iscsi/initiatorname.iscsi}}}.
40 * Go to **Manage** -> **General Config** -> **Manage CHAP** to add a new
41   entry for the new host.  Pick the correct node name, and set a
42   secret for it (N.B.: the maximum is 15, not 16 chars - 
43   the interface and documentation lies).  Also setup mutual chap:
44   As name use giustini's base iqn {{{iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda}}}
45   and again pick a secret (same constraints as above).
46 * Go to **Manage** -> **Volume Management** -> **volume menu** -> **add volume** to add
47   a new volume.  Choose volume size and name as you wish (our policy for name
48   appears to be "//<targethost>//-//<mountpoint or purpose>//.
49   Leave LUN empty (i.e. NONE).
50 * Go to **Manage** -> **Volume Management** -> **volume mapping** and map the
51   new volume to a free LUN on the new host.
52
53 === Back on the host ===
54
55 * edit /etc/iscsi/iscsid.conf:
56 ** set {{{node.session.auth.authmethod = CHAP}}}
57 ** set {{{node.session.auth.username}}} to own initiatorname (again, see {{{/etc/iscsi/initiatorname.iscsi}}})
58 ** set {{{node.session.auth.password}}}
59 ** set {{{node.session.auth.username_in = iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda}}}
60 ** set {{{node.session.auth.password_in}}}
61
62 * stop and start iscsi:
63 {{{
64         /etc/init.d/open-iscsi stop &&
65         sleep 3 &&
66         (cd / && env -i /etc/init.d/open-iscsi start)
67 }}}
68
69 * not sure if this is necessary again:
70 {{{
71         iscsiadm -m discovery -t st -p 10.0.0.17
72 }}}
73
74 * and just for fun, run this again.
75 {{{
76         iscsiadm -m node
77 }}}
78 The output should be the same as above:
79 {{{
80         dijkstra:~# iscsiadm -m node
81         10.0.0.17:3260,1 iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a
82         10.0.0.18:3260,2 iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a
83 }}}
84
85 * moment of truth.  Login:
86 {{{
87         iscsiadm -m node --targetname "iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a" --login
88 }}}
89
90 * cat /proc/scsi/scsi, dmsg, the logs should show it having detected new block devices as sdX.
91   You should have gotten each volume twice (once via .17 and once via .18).
92 * more pretty status stuff, if you care:
93 {{{
94 dijkstra:~# iscsiadm -m session -P 1
95 Target: iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a
96         Current Portal: 10.0.0.17:3260,1
97         Persistent Portal: 10.0.0.17:3260,1
98                 **********
99                 Interface:
100                 **********
101                 Iface Name: default
102                 Iface Transport: tcp
103                 Iface Initiatorname: iqn.1993-08.org.debian:01:dea714656496
104                 Iface IPaddress: 10.0.0.218
105                 Iface HWaddress: default
106                 Iface Netdev: default
107                 SID: 1
108                 iSCSI Connection State: LOGGED IN
109                 iSCSI Session State: LOGGED_IN
110                 Internal iscsid Session State: NO CHANGE
111         Current Portal: 10.0.0.18:3260,2
112         Persistent Portal: 10.0.0.18:3260,2
113                 **********
114                 Interface:
115                 **********
116                 Iface Name: default
117                 Iface Transport: tcp
118                 Iface Initiatorname: iqn.1993-08.org.debian:01:dea714656496
119                 Iface IPaddress: 10.0.0.218
120                 Iface HWaddress: default
121                 Iface Netdev: default
122                 SID: 2
123                 iSCSI Connection State: LOGGED IN
124                 iSCSI Session State: LOGGED_IN
125                 Internal iscsid Session State: NO CHANGE
126
127 }}}
128
129 * next, install and configure multipath-tools
130 {{{
131 cat > /etc/multipath.conf << EOF
132 defaults {
133         udev_dir                /dev
134         polling_interval        10
135         selector                "round-robin 0"
136         path_grouping_policy    multibus
137         getuid_callout          "/lib/udev/scsi_id -g -u -s /block/%n"
138         prio_callout            /bin/true
139         path_checker            readsector0
140         rr_min_io               100
141         rr_weight               priorities
142         failback                immediate
143         no_path_retry           fail
144         user_friendly_name      yes
145 }
146 blacklist {
147         devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
148         devnode "^hd[a-z][[0-9]*]"
149         devnode "^vd[a-z]"
150         devnode "^cciss!c[0-9]d[0-9]*[p[0-9]*]"
151         device {
152                 vendor DEC.*
153                 product MSA[15]00
154         }
155 }
156 multipaths {
157         multipath {
158                 wwid 3600c0ff000d5f6bde2d4cf4901000000
159                 alias geo2-boot
160         }
161 }
162 EOF
163
164 apt-get install multipath-tools
165 }}}
166
167 * look at the topology
168 {{{
169         echo show topology | multipathd -k
170 }}}
171
172 * for the wwid thing in there create an entry in multipath.conf with a proper name, then reload multipathd
173 {{{
174         vi /etc/multipath.conf
175         /etc/init.d/multipath-tools reload
176         echo show topology | multipathd -k
177         ls -l /dev/mapper
178 }}}
179
180 * If you are happy with what you have, change node.startup to automatic in iscsid.conf
181 {{{
182         vi /etc/iscsi/iscsid.conf
183 }}}
184
185 * see if it works out of the box after a reboot.
186
187
188 === misc ===
189
190 * misc commands:
191 {{{
192   iscsiadm -m node --targetname "iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a" --rescan
193   iscsiadm -m node --targetname "iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a" --login
194   iscsiadm -m node --targetname "iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a" --logout
195 }}}