Sunday, June 8, 2014

Shared Resource creation using ISCSI package through LINUX

ISCSI shared storage creation:

ISCSI target:

sudo apt-get install iscsitarget

Open /etc/default/iscsitarget.

vi /etc/default/iscsitarget
... and set ISCSITARGET_ENABLE to true:
 We can use unused logical volumes, image files, 
hard drives (e.g. /dev/sdb), hard drive partitions 
(e.g. /dev/sdb1) or RAID devices (e.g. /dev/md0) for the storage. 
In this example, I will create a logical volume of 20GB named 
storage_lun1 in the volume group vg0:
lvcreate -L15G -n storage_lun1 vg0
(If you want to use an image file, you can create it as follows:
mkdir /storage

dd if=/dev/zero of=/storage/lun1.img bs=1024k count=20000
This creates the image file /storage/lun1.img with a size of 20GB.
Next we edit /etc/ietd.conf...
vi /etc/ietd.conf
... and comment out everything in that file. At the end we add the following stanza:
        IncomingUser someuser secret
        Lun 0 Path=/dev/vg0/storage_lun1,Type=fileio
        Alias LUN1
        #MaxConnections  6

Now we tell the target that we want to allow connections to the device from the IP address ( and (
vi /etc/initiators.allow
and start the target:
/etc/init.d/iscsitarget start

2.2. ISCSI initiator

sudo apt-get install open-iscsi

Next we open /etc/iscsi/iscsid.conf...
vi /etc/iscsi/iscsid.conf
... and set node.startup to automatic:
node.startup = automatic
Then we restart the initiator:
/etc/init.d/open-iscsi restart
Now we connect to the target ( and check what storage devices it has to offer:
iscsiadm -m discovery -t st -p (shared resource IP address)
server1:~# iscsiadm -m discovery -t st -p,1

The settings for the storage device on,1 are stored in the file /etc/iscsi/nodes/ ,3260,1/default. We need to set the username and password for the target in that file; instead of editing that file manually, we can use the iscsiadm command to do this for us:
iscsiadm -m node --targetname "iqn.2014-05com.example:storage.lun1" --portal " :3260" --op=update --name node.session.auth.authmethod --value=CHAP
iscsiadm -m node --targetname "" --portal " :3260" --op=update --name node.session.auth.username --value=someuser
iscsiadm -m node --targetname "" --portal "1172.31.132.60 :3260" --op=update --name node.session.auth.password --value=secret
Now we can log in by running...
sudo iscsiadm -m node --targetname "" --portal "1172.31.132.60 :3260" --login

No comments:

Post a Comment