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:
ISCSITARGET_ENABLE=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:
[...] Target iqn.2014-05.com.example:storage.lun1 IncomingUser someuser secret OutgoingUser 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
iqn.2014-05.com.example:storage.lun1 from the IP address
172.31.132.55 (server1.example.com) and 172.31.132.59
(server2.example.com)...
vi
/etc/initiators.allow
[...] iqn.2014-05.com.example:storage.lun1 172.31.132.55, 172.31.132.59 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 (iscsi.example.com) and check what storage
devices it has to offer:
iscsiadm
-m discovery -t st -p 172.31.132.60 (shared resource IP
address)
server1:~#
iscsiadm -m discovery -t st -p 172.31.132.60
172.31.132.60:3260,1 iqn.2014-05.com.example:storage.lun1
172.31.132.60:3260,1 iqn.2014-05.com.example:storage.lun1
The
settings for the storage device iqn.2014-05.com.example:storage.lun1
on 192.168.0.102:3260,1 are stored in the file
/etc/iscsi/nodes/iqn.2001-04.com.example:storage.lun1/172.31.132.60
,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 "172.31.132.60 :3260" --op=update --name
node.session.auth.authmethod --value=CHAP
iscsiadm -m node --targetname "iqn.2014-05.com.example:storage.lun1" --portal "172.31.132.60 :3260" --op=update --name node.session.auth.username --value=someuser
iscsiadm -m node --targetname "iqn.2014-05.com.example:storage.lun1" --portal "1172.31.132.60 :3260" --op=update --name node.session.auth.password --value=secret
iscsiadm -m node --targetname "iqn.2014-05.com.example:storage.lun1" --portal "172.31.132.60 :3260" --op=update --name node.session.auth.username --value=someuser
iscsiadm -m node --targetname "iqn.2014-05.com.example:storage.lun1" --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 "iqn.2014-05.com.example:storage.lun1"
--portal "1172.31.132.60 :3260" --login
No comments:
Post a Comment