Document how to fix BASE-IS-OLD
[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 === Meanwhile on Melee Islan^W^WGiustini (telnet version) ===
54
55 * Log into the telnet config interface (see dsa-passwords for details)
56 * run {{{show iscsi-hosts}}}. You should see a iqn without a hostname attached.
57   Compare that one to **InitiatorName** in {{{/etc/iscsi/initiatorname.iscsi}}}. 
58   If they are the same, set it like {{{set iscsi-host host iqn.1993-08.org.debian:01:f3c2e4746681 rossini}}}
59   **bad thing, you need to remember the iqn for the next step**
60 * run {{{show chap-records}}}, this will list you the already configured hosts.
61   To add a new host run something like {{{create chap-record name iqn.1993-08.org.debian:01:f3c2e4746681 secret foobar mutual-name iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda mutual-secret 1234567890ABCDEF }}}
62 * for volume management see [[export-iscsi]]
63
64 === Back on the host ===
65
66 * edit /etc/iscsi/iscsid.conf:
67 ** set {{{node.session.auth.authmethod = CHAP}}}
68 ** set {{{node.session.auth.username}}} to own initiatorname (again, see {{{/etc/iscsi/initiatorname.iscsi}}})
69 ** set {{{node.session.auth.password}}}
70 ** set {{{node.session.auth.username_in = iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda}}}
71 ** set {{{node.session.auth.password_in}}}
72
73 * stop and start iscsi:
74 {{{
75         service open-iscsi stop &&
76         sleep 3 &&
77         service open-iscsi start)
78 }}}
79
80 * not sure if this is necessary again:
81 {{{
82         iscsiadm -m discovery -t st -p 10.0.0.17
83 }}}
84
85 * and just for fun, run this again.
86 {{{
87         iscsiadm -m node
88 }}}
89 The output should be the same as above:
90 {{{
91         dijkstra:~# iscsiadm -m node
92         10.0.0.17:3260,1 iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a
93         10.0.0.18:3260,2 iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a
94 }}}
95
96 * moment of truth.  Login:
97 {{{
98         iscsiadm -m node --targetname "iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a" --login
99 }}}
100
101 * cat /proc/scsi/scsi, dmsg, the logs should show it having detected new block devices as sdX.
102   You should have gotten each volume twice (once via .17 and once via .18).
103 * more pretty status stuff, if you care:
104 {{{
105 dijkstra:~# iscsiadm -m session -P 1
106 Target: iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a
107         Current Portal: 10.0.0.17:3260,1
108         Persistent Portal: 10.0.0.17:3260,1
109                 **********
110                 Interface:
111                 **********
112                 Iface Name: default
113                 Iface Transport: tcp
114                 Iface Initiatorname: iqn.1993-08.org.debian:01:dea714656496
115                 Iface IPaddress: 10.0.0.218
116                 Iface HWaddress: default
117                 Iface Netdev: default
118                 SID: 1
119                 iSCSI Connection State: LOGGED IN
120                 iSCSI Session State: LOGGED_IN
121                 Internal iscsid Session State: NO CHANGE
122         Current Portal: 10.0.0.18:3260,2
123         Persistent Portal: 10.0.0.18:3260,2
124                 **********
125                 Interface:
126                 **********
127                 Iface Name: default
128                 Iface Transport: tcp
129                 Iface Initiatorname: iqn.1993-08.org.debian:01:dea714656496
130                 Iface IPaddress: 10.0.0.218
131                 Iface HWaddress: default
132                 Iface Netdev: default
133                 SID: 2
134                 iSCSI Connection State: LOGGED IN
135                 iSCSI Session State: LOGGED_IN
136                 Internal iscsid Session State: NO CHANGE
137
138 }}}
139
140 * next, install and configure multipath-tools
141 {{{
142 cat > /etc/multipath.conf << EOF
143 defaults {
144         udev_dir                /dev
145         polling_interval        10
146         selector                "round-robin 0"
147         path_grouping_policy    multibus
148         getuid_callout          "/lib/udev/scsi_id -g -u -s /block/%n"
149         prio_callout            /bin/true
150         path_checker            readsector0
151         rr_min_io               100
152         rr_weight               priorities
153         failback                immediate
154         no_path_retry           fail
155         user_friendly_name      yes
156 }
157 blacklist {
158         devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
159         devnode "^hd[a-z][[0-9]*]"
160         devnode "^vd[a-z]"
161         devnode "^cciss!c[0-9]d[0-9]*[p[0-9]*]"
162         device {
163                 vendor DEC.*
164                 product MSA[15]00
165         }
166 }
167 multipaths {
168         multipath {
169                 wwid 3600c0ff000d5f6bde2d4cf4901000000
170                 alias geo2-boot
171         }
172 }
173 EOF
174
175 apt-get install multipath-tools
176 }}}
177
178 * look at the topology
179 {{{
180         echo show topology | multipathd -k
181 }}}
182
183 * for the wwid thing in there create an entry in multipath.conf with a proper name, then reload multipathd
184 {{{
185         vi /etc/multipath.conf
186         service multipath-tools reload
187         echo show topology | multipathd -k
188         ls -l /dev/mapper
189 }}}
190
191 * If you are happy with what you have, change node.startup to automatic in iscsid.conf
192 {{{
193         vi /etc/iscsi/iscsid.conf
194 }}}
195
196 * see if it works out of the box after a reboot.
197
198
199 === misc ===
200
201 * misc commands:
202 {{{
203   iscsiadm -m node --targetname "iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a" --rescan
204   iscsiadm -m node --targetname "iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a" --login
205   iscsiadm -m node --targetname "iqn.1986-03.com.hp:storage.msa2012i.0834d5ecda.a" --logout
206 }}}