Welcome to Halil Demirezen's Tips and Tutorials Page
Personal
Home
Contact
Biography
Research

Projects
Tutorials
Celsus Library (TR)

Categories

LinuxNetworkComputer VisionDatabasesProgamming
vmware


ISCSI: Multiple ISCSI disks on the same Linux host 2020-04-09 15:03:03

This tutorial is not only intended to give tips for adding multiple ISCSI targets (disks) on the same
Linux host, but also give some steps how to add ISCSI disk to the Linux box. The example Linux box
is Centos 7. Thus the iscsi tools come as a part of iscsi-initiator-utils package.

/etc/iscsi/iscsid.conf is the file where the discovery, username and password parameters are located.
initiatorname.iscsi under the same directory refers actually to our Linux box, thus the same initiator name
will be used for multiple iscsi targets (disks).

Having that said, We can start by the process of discovering iscsi targets, and eventually adding it to the
system with their respective username passwords. Target discovery is a temporary step of iscsi process.
It helps sort out which target ip addresses and name should be used when attaching to it. The binary
command which we will be using at every step is iscsiadm, which is shipped with the package
that I've mentioned above. iscsiadm uses the parameters located in the /etc/iscsi/iscsid.conf file
for the discovery process. The parameters below will be used in the file. Thus, for adding multiple target
we may need to update there parameters in the file before issueing discovery command.

discovery.sendtargets.auth.username = example_username
discovery.sendtargets.auth.password = example_password

After updating the config file, we issue the below command to get the target name and redundant ip
addresses for the next step.

iscsiadm -m discovery -t st -p PORTAL_IP -o new --discover | awk '{ print $2}'


This command will query the PORTAL_IP with the username and password which we mentioned above
and return the target IP addresses and target name to be used for login step. We will set username and
password for the target username and password for each node IP returned from the discovery command.


iscsiadm -m node --targetname TARGET_NAME -p NODE_IP -o update -n node.session.auth.username -v USERNAME
iscsiadm -m node --targetname TARGET_NAME -p NODE_IP -o update -n node.session.auth.password -v PASSWORD


Eventually we will issue login to create a connection with NODE_IP for that target. We can think each NODE_IP
connection as a single path in mutlpath environment.

iscsiadm -m node --targetname TARGET_NAME -p NODE_IP --login


You can easily see the active iscsi connection as below

iscsiadm -m session
tcp: [1] 10.10.10.79:3260,1051 iqn.1332-08.com.netapp:ams0301 (non-flash)
tcp: [2] 10.10.10.88:3260,1052 iqn.1332-08.com.netapp:ams0301 (non-flash)
tcp: [3] 10.10.10.231:3260,1044 iqn.1332-08.com.netapp:stfams0302 (non-flash)
tcp: [4] 10.10.10.233:3260,1046 iqn.1332-08.com.netapp:stfams0302 (non-flash)


And the respective multipath output of this

mutlipath -l
3600a09803990354e575d47437361716b dm-0 NETAPP,LUN C-Mode
size=1000G features='3 queue_if_no_path pg_init_retries 50' hwhandler='1 alua' wp=rw
|-+- policy='round-robin 0' prio=0 status=active
| `- 8:0:0:169 sdc 8:32 active undef running
`-+- policy='round-robin 0' prio=0 status=enabled
`- 7:0:0:169 sdd 8:48 active undef running
3600a09803830562f7a2130323773736f dm-1 NETAPP,LUN C-Mode
size=3.9T features='3 queue_if_no_path pg_init_retries 50' hwhandler='1 alua' wp=rw
|-+- policy='round-robin 0' prio=0 status=active
| `- 10:0:0:0 sdf 8:80 active undef running
`-+- policy='round-robin 0' prio=0 status=enabled
`- 9:0:0:0 sde 8:64 active undef running