isasi
target 存储: 192.168.1.17
1.装包
scsi-target-utils-0.0-5.20080917snap.el5.i386.rpm
2.启动服务
/etc/init.d/tgtd start
3.划分分区
fdisk /dev/sda
(删除本来存在的分区,需要rm -rf /dev/sda5)
partprobe /dev/sda
4.配置规则
tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2009-12.com.uplooking.stu17:storage
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sda5
tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
tgtadm --lld iscsi --op new --mode account --user neco --password 123
e.g. tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2001-04.com.example:storage.disk2.amiens.sys1.xyz
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/hdc1
tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
tgtadm --lld iscsi --op bind --mode target --tid 1 -I 192.168.2.29
tgtadm --lld iscsi --op bind --mode target --tid 1 -I 192.168.11.0/24
tgtadm --lld iscsi --op new --mode account --user fujita --password tomo
5.查看iscsi设备导出状态
tgtadm --lld iscsi --op show --mode target
6.添加配置文件/etc/tgt/targets.conf(重新启动后,不用重新配置规则)
<target iqn.2009-12.cpm.uplooking.stu17:storage>
backing-store /dev/sda5
initiator-address ALL
</target>
7.chkconfig tgtd on
iscsi-initiator
1.装包
iscsi-initiator-utils-6.2.0.868-0.18.el5.i386.rpm
2.启动服务
/etc/init.d/iscsid start
3.发现iSCSI设备
iscsiadm -m discovery -t sendtargets -p 192.168.1.17:3260 (只需要启动一次,下次自动发现)
4.登录并导入iSCSI设备
iscsiadm -m node -T iqn.2009-12.com.uplooking.stu17:storage -p 192.168.1.17:3260 -l
回显
Logging in to [iface: default, target: iqn.2009-12.com.uplooking.stu17:storage, portal: 192.168.1.17,3260]
Login to [iface: default, target: iqn.2009-12.com.uplooking.stu17:storage, portal: 192.168.1.17,3260]: successful
6.查看共享分区
fdisk -l
7.登出并撤销导入iSCSI设备 (但/var/lib/iscsi/send_targets/ 有之前的信息文件)
iscsiadm -m node -T iqn.2009-12.com.uplooking.stu17:storage -p 192.168.1.17:3260 -u
回显
Logging out of session [sid: 1, target: iqn.2009-12.com.uplooking.stu17:storage, portal: 192.168.1.17,3260]
Logout of [sid: 1, target: iqn.2009-12.com.uplooking.stu17:storage, portal: 192.168.1.17,3260]: successful
8.重新登录
/etc/init.d/iscsi start
9.发现操作后就可以配置响应服务自动导入
chkconfig iscsid on
chkconfig iscsi on
UDEV:(使存储的名字唯一(storage),防止作LVM的时候名字不一致,出现错误)
1.查看分区的信息
udevinfo -a -p /sys/block/sdb
2.使用脚本
vim /etc/udev/scripts/iscsidev.sh
---------------
#!/bin/bash
BUS=${1}
HOST=${BUS%%:*}
[ -e /sys/class/iscsi_host ] || exit 1
file="/sys/class/iscsi_host/host${HOST}/device/session*/iscsi_session*/targetname"
target_name=$(cat ${file})
if [ -z "${target_name}" ] ; then
exit 1
fi
echo "${target_name##*:}"
--------------
chmod +x /etc/udev/scripts/iscsidev.sh
vim /etc/udev/rules.d/55-openiscsi.rules
------------------
KERNEL=="sd*",BUS=="scsi",PROGRAM="/etc/udev/scripts/iscsidev.sh %b",SYMLINK+="iscsi/%c"
------------------
3.重启服务,使规则生效
/etc/init.d/iscsi restart
4.产生新的文件
[root@node2 rules.d]# ls /dev/iscsi/storage
/dev/iscsi/storage