{"id":536,"date":"2012-12-18T15:41:54","date_gmt":"2012-12-18T14:41:54","guid":{"rendered":"http:\/\/elkano.org\/blog\/?page_id=536"},"modified":"2016-12-14T16:18:35","modified_gmt":"2016-12-14T15:18:35","slug":"set-up-multipath-iscsi-targets-on-debian","status":"publish","type":"post","link":"https:\/\/elkano.org\/blog\/set-up-multipath-iscsi-targets-on-debian\/","title":{"rendered":"Setting up multipath iscsi targets on debian"},"content":{"rendered":"<p>In this little tutorial I&#8217;m going to explain the basic steps to set up an iscsi target on a debian machine.<\/p>\n<p>Install required packages:<\/p>\n<pre class=\"dontquote prettyprint lang-xml\"># apt-get install open-iscsi multipath-tools<\/pre>\n<p>I always use multipath to get path availability.<\/p>\n<p>Configure \/etc\/iscsi\/iscsid.conf file according to your storage server. It is very common the use of chap authentication for logging into a specified target. In order to configure the user and password, edit \/etc\/iscsi\/iscsid.conf file and change these parameters:<\/p>\n<pre class=\"dontquote prettyprint lang-xml\">node.session.auth.authmethod = CHAP\r\nnode.session.auth.username_in = user\r\nnode.session.auth.password_in = password<\/pre>\n<p>Discover iscsi targets:<\/p>\n<pre class=\"dontquote prettyprint lang-xml\"># iscsiadm -m discovery -t sendtargets -p &lt;PORTAL_IP&gt;<\/pre>\n<p>You are going to get an output like this:<\/p>\n<pre class=\"dontquote prettyprint lang-xml\">192.168.0.50:3260,1 iscsi-target1\r\n192.168.0.150:3260,1 iscsi-target1<\/pre>\n<p>In this case we have two paths to the same target. It can be, because your storage server has two differents controllers, that can be accessed to reach same target or because your storage server has two network cards but only one internal controller. Any way, we have two paths to reach the same target.<\/p>\n<p>Now, that we have the target discovered we can log in on each portal:<\/p>\n<pre class=\"dontquote prettyprint lang-xml\"># \/usr\/bin\/iscsiadm --mode node --portal 192.168.0.50:3260 --targetname iscsi-target1 --login\r\n# \/usr\/bin\/iscsiadm --mode node --portal 192.168.0.150:3260 --targetname iscsi-target1 --login<\/pre>\n<p>To view your current iscsi connections:<\/p>\n<pre class=\"dontquote prettyprint lang-xml\"># iscsiadm -m session\r\ntcp: [2] 172.16.64.10:3260,1 iscsi-target1\r\ntcp: [3] 172.16.66.10:3260,1 iscsi-target1<\/pre>\n<p>or<\/p>\n<pre class=\"dontquote prettyprint lang-xml\"># \/etc\/init.d\/open-iscsi status\r\nCurrent active iSCSI sessions:\r\ntcp: [2] 172.16.64.10:3260,1 iscsi-target1\r\ntcp: [3] 172.16.66.10:3260,1 iscsi-target1<\/pre>\n<p>To see what luns provides each iscsi connection you can run the following command, with the parameter -r we specify the session number we want to see:<\/p>\n<pre>\r\n~# iscsiadm -m session -P3 -r3\r\niSCSI Transport Class version 2.0-870\r\nversion 2.0-873\r\nTarget: iscsi-target1 (non-flash)\r\n\tCurrent Portal: 192.168.0.50:3260,1\r\n\tPersistent Portal: 192.168.0.50:3260,1\r\n\t\t**********\r\n\t\tInterface:\r\n\t\t**********\r\n\t\tIface Name: default\r\n\t\tIface Transport: tcp\r\n\t\tIface Initiatorname: iqn.1993-08.org.debian:01:6a8c80ddf449\r\n\t\tIface IPaddress: 192.168.0.20\r\n\t\tIface HWaddress: &lt;empty&gt;\r\n\t\tIface Netdev: &lt;empty&gt;\r\n\t\tSID: 8\r\n\t\tiSCSI Connection State: LOGGED IN\r\n\t\tiSCSI Session State: LOGGED_IN\r\n\t\tInternal iscsid Session State: NO CHANGE\r\n\t\t*********\r\n\t\tTimeouts:\r\n\t\t*********\r\n\t\tRecovery Timeout: 120\r\n\t\tTarget Reset Timeout: 30\r\n\t\tLUN Reset Timeout: 20\r\n\t\tAbort Timeout: 15\r\n\t\t*****\r\n\t\tCHAP:\r\n\t\t*****\r\n\t\tusername: chapuser\r\n\t\tpassword: ********\r\n\t\tusername_in: &lt;empty&gt;\r\n\t\tpassword_in: ********\r\n\t\t************************\r\n\t\tNegotiated iSCSI params:\r\n\t\t************************\r\n\t\tHeaderDigest: None\r\n\t\tDataDigest: None\r\n\t\tMaxRecvDataSegmentLength: 262144\r\n\t\tMaxXmitDataSegmentLength: 1048576\r\n\t\tFirstBurstLength: 65536\r\n\t\tMaxBurstLength: 1048576\r\n\t\tImmediateData: Yes\r\n\t\tInitialR2T: No\r\n\t\tMaxOutstandingR2T: 1\r\n\t\t************************\r\n\t\tAttached SCSI devices:\r\n\t\t************************\r\n\t\tHost Number: 9\tState: running\r\n\t\tscsi9 Channel 00 Id 0 Lun: 0\r\n\t\t\tAttached scsi disk sda\t\tState: running\r\n<\/pre>\n<p>If you check the available devs under \/dev\/disk\/by-path you are going to see your new disks provided by iscsi luns. You can see how each lun is detected twice, one for each available path, for example lun0 can be accesed through sda and sdb:<\/p>\n<pre class=\"dontquote prettyprint lang-xml\"># ls -l \/dev\/disk\/by-path\/\r\ntotal 0\r\nlrwxrwxrwx 1 root root 9 dic 13 23:47 ip-192.168.0.150:3260-iscsi-target1-lun-0 -&gt; ..\/..\/sda\r\nlrwxrwxrwx 1 root root 9 dic 13 23:47 ip-192.168.0.150:3260-iscsi-target1-lun-1 -&gt; ..\/..\/sdc\r\nlrwxrwxrwx 1 root root 9 dic 13 23:47 ip-192.168.0.150:3260-iscsi-target1-lun-2 -&gt; ..\/..\/sde\r\nlrwxrwxrwx 1 root root 9 dic 13 23:47 ip-192.168.0.50:3260-iscsi-target1-lun-0 -&gt; ..\/..\/sdb\r\nlrwxrwxrwx 1 root root 9 dic 13 23:47 ip-192.168.0.50:3260-iscsi-target1-lun-1 -&gt; ..\/..\/sdd\r\nlrwxrwxrwx 1 root root 9 dic 13 23:47 ip-192.168.0.50:3260-iscsi-target1-lun-2 -&gt; ..\/..\/sdf\r\n<\/pre>\n<p>We are going to use multipath tool to unify the two paths in an unified one. To do so  check the properties of the new device:<\/p>\n<pre>\r\n~# udevadm info -q property \/dev\/sda\r\nDEVLINKS=\/dev\/disk\/by-id\/scsi-2616c304142756451 \/dev\/disk\/by-path\/ip-192.168.0.50:3260-iscsi-target1-lun-0\r\nDEVNAME=\/dev\/sda\r\nDEVPATH=\/devices\/platform\/host8\/session3\/target8:0:0\/8:0:0:0\/block\/sda\r\nDEVTYPE=disk\r\nID_BUS=scsi\r\nID_MODEL=al0ABudQ263abHG3\r\nID_MODEL_ENC=al0ABudQ263abHG3\r\nID_PATH=ip-192.168.0.50:3260-iscsi-target1-lun-0\r\nID_PATH_TAG=ip-172_16_68_50_3260-iscsi-target1-lun-0\r\nID_REVISION=220\r\nID_SCSI=1\r\nID_SCSI_SERIAL=731ab7e9\r\nID_SERIAL=2616c304142756451\r\nID_SERIAL_SHORT=616c304142756451\r\nID_TYPE=disk\r\nID_VENDOR=SCST_BIO\r\nID_VENDOR_ENC=SCST_BIO\r\nMAJOR=8\r\nMINOR=128\r\nSUBSYSTEM=block\r\nTAGS=:systemd:\r\nUSEC_INITIALIZED=40848863230\r\n<\/pre>\n<p>And configure multipath accordingly adding this section to the file <strong>\/etc\/multipatch.conf<\/strong><\/p>\n<pre>\r\ndevices {\r\n   device {\r\n                vendor                          &quot;SCST_FIO|SCST_BIO&quot;\r\n                product                         &quot;*&quot;\r\n                path_selector                   &quot;round-robin 0&quot;\r\n                path_grouping_policy            multibus\r\n                rr_min_io                       100\r\n        }\r\n}\r\n<\/pre>\n<p>To check the unified paths run the following command:<\/p>\n<pre class=\"dontquote prettyprint lang-xml\"># multipath -ll\r\nmpath12 (2507a637562517a71) dm-4 SCST_BIO,PzcubQzqZx3JHfm1\r\nsize=9.3T features=&#039;0&#039; hwhandler=&#039;0&#039; wp=rw\r\n|-+- policy=&#039;round-robin 0&#039; prio=1 status=active\r\n| `- 3:0:0:2 sdf 8:80   active ready  running\r\n`-+- policy=&#039;round-robin 0&#039; prio=1 status=enabled\r\n  `- 2:0:0:2 sde 8:64   active ready  running\r\nmpath11 (26b59586b61536156) dm-2 SCST_BIO,kYXkaSaVkZZalcKP\r\nsize=4.9T features=&#039;0&#039; hwhandler=&#039;0&#039; wp=rw\r\n|-+- policy=&#039;round-robin 0&#039; prio=1 status=active\r\n| `- 2:0:0:1 sdc 8:32   active ready  running\r\n`-+- policy=&#039;round-robin 0&#039; prio=1 status=enabled\r\n  `- 3:0:0:1 sdd 8:48   active ready  running\r\nmpath10 (24b4f4575564c6b4b) dm-3 SCST_BIO,KOEuVLkKIxommozh\r\nsize=4.9T features=&#039;0&#039; hwhandler=&#039;0&#039; wp=rw\r\n|-+- policy=&#039;round-robin 0&#039; prio=1 status=active\r\n| `- 2:0:0:0 sda 8:0    active ready  running\r\n`-+- policy=&#039;round-robin 0&#039; prio=1 status=enabled\r\n  `- 3:0:0:0 sdb 8:16   active ready  running<\/pre>\n<p>We can see multipath topology, <strong>mpath12<\/strong> is the multipath device for <strong>sde<\/strong> and <strong>sdf<\/strong> accesed through <strong>dm-4<\/strong>. Now, we can partition \/dev\/mapper\/mpath12 as needed and use it as other disk in our system. Multipath has some parameters that can be changed for each device, for example the path policy (see multipath help). In our example the policy is set to round-robin.<\/p>\n<p>if you don&#8217;t see any multipath devices with the above command try running multipath -v3 to see verbose messages and see if are showing up messages like this:<\/p>\n<p>Apr 12 20:07:51 | sda: blacklisted, udev property missing<\/p>\n<p>if so, add these lines to <strong>multipath.conf <\/strong>and run again <strong>multipath -v3<\/strong> command<\/p>\n<pre>\r\nblacklist_exceptions {\r\n        property &quot;(ID_WWN|SCSI_IDENT_.*|ID_SERIAL)&quot;\r\n}\r\n<\/pre>\n<p>And now the paths should be discovered.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this little tutorial I&#8217;m going to explain the basic steps to set up an iscsi target on a debian machine. Install required packages: # apt-get install open-iscsi multipath-tools I always use multipath to get path availability. Configure \/etc\/iscsi\/iscsid.conf file according to your storage server. It is very common the use of chap authentication for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[201,191,200],"_links":{"self":[{"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/posts\/536"}],"collection":[{"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/comments?post=536"}],"version-history":[{"count":23,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/posts\/536\/revisions"}],"predecessor-version":[{"id":560,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/posts\/536\/revisions\/560"}],"wp:attachment":[{"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/media?parent=536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/categories?post=536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/tags?post=536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}