Warning Livedoc is no longer being updated and will be deprecated shortly. Please refer to https://documentation.tjhsst.edu.

SAN/iSCSI Administration

From Livedoc - The Documentation Repository
Revision as of 19:08, 27 December 2016 by Lburton (talk | contribs) (Add labels)
Jump to: navigation, search

This page contains administration guidelines and commands for iSCSI exports on the CSL SAN.

Adding an iSCSI LUN

This is used to add a new iSCSI LUN to the SAN.

ZVOL creation

All of the iSCSI exports on the SAN are currently backed by ZVOL block devices. ZVOLs provide much better performance than using raw datafiles over top of a normal filesystem and are easily expanded and managed using ZFS.

For ease of management, related ZVOLs are typically grouped underneath a ZFS filesystem. First we create the filesystem, then we create each of the ZVOLs beneath it. For most VMs, you will need two ZVOLs; one for the root partition and one for swap.

1  zfs create apocalypse/vms/<vm>
2  zfs create -V 15G apocalypse/vms/<vm>/root
3  zfs create -V 1G apocalypse/vms/<vm>/swap

iSCSI Exports

iSCSI Exports are currently done using the LIO iSCSI Target managed through Pacemaker. Therefore, we need to add the new LUNs to Pacemaker which will handle bringing them online on the appropriate host.

First you need to generate a unique value for each LUN to use as an SCSI ID. We use the first half of the md5 hash of the LUN's name as a reliably unique value.

 echo -n apocalypse-<vm>-root | md5sum | head -c 16
 echo -n apocalypse-<vm>-swap | md5sum | head -c 16

You will also need a LUN number for each LUN you are adding; these are generally assigned starting from 0 and incrementing with each LUN added. To get the highest numbered LUN check the add.luns file. Change the lines in the add.luns file to match the format shown below. Make sure the LUNs in the add.luns file have been added to the end of the luns file before clearing add.luns.

apocalypse-ns2-root,<LUN number>(add 1 to the previous),/dev/zvol/apocalypse/vms/<vm>/root,<SCSI ID>
apocalypse-ns2-swap,<LUN number>(add 1 to the previous),/dev/zvol/apocalypse/vms/<vm>/swap,<SCSI ID>

Then, run the add-luns.sh script.


Finally, each VM Server needs to be told to rescan for iSCSI LUN changes. IMPORTANT - DO NOT restart iscsid or you will crash all of the VMs on the server; rather use the following command to instruct iscsid to scan for changes.

 iscsiadm -m session --rescan

iSCSI exports using targetcli

Assuming a structure like:


Then you can generate targetcli commands for 2 AFS servers running on 3 different VM servers with 4 different disks on sonic:

 1 ip=""
 2 for i in openafs1 openafs3; do
 3   for h in root swap vicepa vicepb; do
 4     echo "/backstores/iblock create name=$i-$h dev=/dev/zvol/sonic/vms/$i/$h"
 5     echo "/iscsi create iqn.1992-03.edu.tjhsst:target:sonic.0:sn.$i-$h"
 6     echo "/iscsi/iqn.1992-03.edu.tjhsst:target:sonic.0:sn.$i-$h/tpg1/luns create /backstores/iblock/$i-$h"
 7     echo "/iscsi/iqn.1992-03.edu.tjhsst:target:sonic.0:sn.$i-$h/tpg1/portals create ip_address=$ip ip_port=3260"
 8     echo "/iscsi/iqn.1992-03.edu.tjhsst:target:sonic.0:sn.$i-$h/tpg1 set attribute authentication=0"
 9     for j in galapagos antipodes cocos; do
10       echo "/iscsi/iqn.1992-03.edu.tjhsst:target:sonic.0:sn.$i-$h/tpg1/acls create iqn.1992-03.edu.tjhsst:initiator:$j.csl.tjhsst.edu.0"
11     done
12   done
13 done
14 echo "/ saveconfig"

If you want to get the disk WWNs you can do something like:

root@barrel:/var/target# cat backup-2016-12-22_00:10:36.lio | egrep '(disk|wwn)' | tr -s ' ' ' ' | cut -d" " -f3

You could of course set the WWN as you create them with LIO as well.

Some LIO references:



ZFS LIO Ref http://scyu.logdown.com/posts/277456-create-zfs-iscsi-nfs-storage-on-ubuntu-14-04-for-esxi

Client config with open-iscsi

See [1] for iscsiadm commands.

Multipath Configuration

Multipath now needs to be configured on the client servers. This is most easily done on one server and then copied to the others. On one of the client servers, run:

Note: this will probably be deprecated soon as we'll just have a LACP trunk for the server instead of multiple IPs

Currently barrel does not use multipath!


Then, for each LUN you are adding, run:

 ls /dev/mapper/ | grep 090427202e6db84c #(replace this with the SCSI_SN of the LUN)

For each LUN, add an entry in /etc/multipath.conf similar to the following; replacing the WWID with the value returned above, and the alias with the name of the LUN.

 multipath {
     wwid 36001405090427202e6db84c000000000
     alias apocalypse-ion-root
     features                "1 queue_if_no_path"

Next for each LUN, you need to remove the temporary multipath alias (which defaults to the WWID) by running:

 multipath -f 36001405090427202e6db84c000000000 #(replace this with the WWID)

Finally, re-run the multipath command to regenerate the multipath devices with the new aliases.

You should now have an entry in /dev/mapper/ for each LUN you added to the SAN. Once you have verified that everything is working, you need to replicate this configuration across the other systems connected to the SAN. Copy the updated /etc/multipath.conf to them, then run:

 iscsiadm -m session --rescan

See the main SAN article for a list of systems currently connected to the SAN via iSCSI.