2012/10/26

Open-iscsi initiator



This was done on ubuntu 12.04 . Something similar with work on Red Hat, Fedora, or CentOS, by replacing e.g. apt-get with yum install.  

Prep work

Ubuntu/Debian derivatives: apt-get install open-iscsi open-iscsi-utils
RedHat/CentOS derivatives: yum install iscsi-initiator-utils

Modify the initiator name if needed (e.g., if this was a cloned VM that already had open-iscsi installed), because each must be unique (e.g., if we cloned the VM, then we must change the IQN!)
vi /etc/iscsi/iscsid.conf (change “manual” to “automatic”, set CHAP parameters, etc., if needed)
vi /etc/iscsi/initiatorname.iscsi (put the correct initiator name)

(Probe the SAN so that this will show up as a valid initiator on the SAN)
 iscsiadm -m discovery -t sendtargets -p 10.10.10.27
 iscsiadm -m discovery -t sendtargets -p 10.10.10.29
(connect to the iSCSI SAN/target, allow this iSCSI initiator)

Our SAN has multiple iSCSI interfaces, so we'll use multipathing


restart iscsi-network-interface
/etc/init.d/open-iscsi restart

iscsiadm -m discovery -t sendtargets -p 10.10.10.27
iscsiadm -m discovery -t sendtargets -p 10.10.10.29
iscsiadm -m node -l

apt-get install multipath-tools
multipath -d -l  (the two scsi paths should show up and should be recognized as a single block target with multiple paths)
apt-get install sg3-utils
sg_map   (the new scsi devices should show up)

Prepare the filesystem for persistent mounting

ls -la /dev/disk/by-id  (get the /dev/disk/by-id/dm-uuid-mpath-… for this new multipath device)
mkdir /mnt/localscratch0
vi /etc/fstab
Add a line like this: 
/dev/disk/by-id/dm-uuid-mpath-360060f870104b72e004f3263600000001 /mnt/localscratch0 ext4    defaults,noatime        0 2

Format the filesystem (destroying all existing data; only do this if you do not want to keep your previous data on that LUN), then mount it
mkfs.ext4 -L localscratch0 /dev/disk/by-id/dm-uuid-mpath-360060f870104b72e004f3263600000001
mount -a

That's it, all done.  It should auto-mount on the next reboot.

No comments: