ISCSI: Difference between revisions
From VVCWiki
Jump to navigationJump to search
(No difference)
|
Latest revision as of 15:13, 6 June 2010
iSCSI setup
Setup a target
- install packages
yum install scsi-target-utils
- add targets and allowed hosts to the config file /etc/tgt/targets.conf
default-driver iscsi <target iqn.2010-05.lan.chepkov:centos> backing-store /dev/centos/target1 backing-store /dev/centos/target2 vendor_id VVC initiator-address 10.10.10.19 initiator-address 10.10.10.20 initiator-address 10.10.10.21 </target>
- enable and start the service
chkconfig tgtd on service tgtd start
Setup an initiator
- install packages
yum install iscsi-initiator-utils
- create udev rules to get persistent names
/etc/udev/rules.d/local.rules
KERNEL=="sd*[a-z]", BUS=="scsi", SYSFS{vendor}=="VVC", PROGRAM="/etc/udev/scripts/iscsidev.sh %b",SYMLINK+="iscsi/%c{1}/lun%c{2}/disk" KERNEL=="sd*[0-9]", BUS=="scsi", SYSFS{vendor}=="VVC", PROGRAM="/etc/udev/scripts/iscsidev.sh %b",SYMLINK+="iscsi/%c{1}/lun%c{2}/part%n"
/etc/udev/scripts/iscsidev.sh
#!/bin/sh
BUS=${1}
HOST=${BUS%%:*}
LUN=`echo ${BUS} | cut -d":" -f4`
[ -e /sys/class/iscsi_host ] || exit 1
file="/sys/class/iscsi_host/host${HOST}/device/session*/iscsi_session*/targetname"
target_name=$(cat ${file} | cut -d":" -f2 | sed 's/\./_/')
logger "iscsidev called with $1 and returned ${target_name} ${LUN}"
echo "${target_name} ${LUN}"
- start iscsid and discover the targets
service iscsid start iscsiadm -m discovery -t sendtargets -p 10.10.10.55
- enable and start service
chkconfig iscsi on service iscsi off
- check it out
# ls -lR /dev/iscsi/ /dev/iscsi/: total 0 drwxr-xr-x 4 root root 80 Jun 6 13:56 centos /dev/iscsi/centos: total 0 drwxr-xr-x 2 root root 80 Jun 6 13:58 lun1 drwxr-xr-x 2 root root 80 Jun 6 13:58 lun2 /dev/iscsi/centos/lun1: total 0 lrwxrwxrwx 1 root root 12 Jun 6 13:56 disk -> ../../../sda lrwxrwxrwx 1 root root 13 Jun 6 13:58 part1 -> ../../../sda1 /dev/iscsi/centos/lun2: total 0 lrwxrwxrwx 1 root root 12 Jun 6 13:56 disk -> ../../../sdb lrwxrwxrwx 1 root root 13 Jun 6 13:58 part1 -> ../../../sdb1