iSCSI target:
ip:172.16.100.100
iSCSI initiator:
172.16.100.101
iSCSI target:
# yum install scsi-target-utils
查看安装信息:
# rpm -ql scsi-target-utils
/etc/rc.d/init.d/tgtd
/etc/sysconfig/tgtd
/etc/tgt/targets.conf
/usr/sbin/tgt-admin
/usr/sbin/tgt-setup-lun
/usr/sbin/tgtadm
/usr/sbin/tgtd
/usr/sbin/tgtimg
/usr/share/doc/scsi-target-utils-1.0.24
/usr/share/doc/scsi-target-utils-1.0.24/README
/usr/share/doc/scsi-target-utils-1.0.24/README.iscsi
/usr/share/doc/scsi-target-utils-1.0.24/README.iser
/usr/share/doc/scsi-target-utils-1.0.24/README.lu_configuration
/usr/share/doc/scsi-target-utils-1.0.24/README.mmc
/usr/share/man/man5/targets.conf.5.gz
/usr/share/man/man8/tgt-admin.8.gz
/usr/share/man/man8/tgt-setup-lun.8.gz
/usr/share/man/man8/tgtadm.8.gz
[root@localhost ~]#
# vim /etc/tgt/targets.conf
backing-store /dev/sdb
initiator-address 172.16.100.0/24
定义名称和ACL
# /etc/init.d/tgtd start
# lsof -i:3260
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
tgtd 1212 root 4u IPv4 10241 0t0 TCP *:iscsi-target (LISTEN)
tgtd 1212 root 5u IPv6 10242 0t0 TCP *:iscsi-target (LISTEN)
tgtd 1214 root 4u IPv4 10241 0t0 TCP *:iscsi-target (LISTEN)
tgtd 1214 root 5u IPv6 10242 0t0 TCP *:iscsi-target (LISTEN)
[root@localhost ~]#
# tgtadm --lld iscsi -m target --op show
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 5369 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sdb
Backing store flags:
Account information:
ACL information:
172.16.100.0/24
[root@localhost ~]#
客户端进行挂载:
# yum install iscsi-initiator-utilsiscsi-initiator-utils-devel
# rpm -ql iscsi-initiator-utils
/etc/NetworkManager
/etc/NetworkManager/dispatcher.d
/etc/NetworkManager/dispatcher.d/04-iscsi
/etc/iscsi
/etc/iscsi/iscsid.conf
/etc/logrotate.d/iscsiuiolog
/etc/rc.d/init.d/iscsi
/etc/rc.d/init.d/iscsid
/sbin/brcm_iscsiuio
/sbin/iscsi-iname
/sbin/iscsiadm
/sbin/iscsid
/sbin/iscsistart
/sbin/iscsiuio
/usr/lib64/libiscsi.so.0
/usr/lib64/python2.6/site-packages/libiscsimodule.so
/usr/share/doc/iscsi-initiator-utils-6.2.0.873
/usr/share/doc/iscsi-initiator-utils-6.2.0.873/README
/usr/share/man/man8/iscsi-iname.8.gz
/usr/share/man/man8/iscsiadm.8.gz
/usr/share/man/man8/iscsid.8.gz
/usr/share/man/man8/iscsistart.8.gz
/usr/share/man/man8/iscsiuio.8.gz
/var/lib/iscsi
/var/lib/iscsi/ifaces
/var/lib/iscsi/isns
/var/lib/iscsi/nodes
/var/lib/iscsi/send_targets
/var/lib/iscsi/slp
/var/lib/iscsi/static
/var/lock/iscsi
[root@localhost ~]#
在客户端发现target
修改
# iscsi-iname
iqn.1994-05.com.redhat:dbf73fa38dba
# /etc/init.d/iscsi restart
# iscsiadm -m discovery -t sendtargets -p172.16.100.100
172.16.100.100:3260,1iqn.2014-10.com.mengtao:server.disk1
[root@localhost ~]#
# ls /var/lib/iscsi/send_targets/
172.16.100.100,3260
[root@localhost ~]#
这里就会看到数据信息
# iscsiadm -m node -Tiqn.2014-10.com.mengtao:server.disk1 -p 172.16.100.100 –l
连接登录设备
以下显示已经登录成功
# fdisk /dev/sdb
# mkfs.ext4 /dev/sdb1
分区格式化
# mount /dev/sdb1 /mnt/
# cp /etc/fstab /mnt/
# ls -lh /mnt/
total 20K
-rw-r--r-- 1 root root 779 Oct 29 22:10fstab
drwx------ 2 root root 16K Oct 29 22:09lost+found
[root@localhost ~]#
以上配置基于IP的ACL访问控制
配置基于chap认证
首先退出登录:
# iscsiadm -m node -Tiqn.2014-10.com.mengtao:server.disk1 -p 172.16.100.100 -u
Logging out of session [sid: 2, target:iqn.2014-10.com.mengtao:server.disk1, portal: 172.16.100.100,3260]
Logout of [sid: 2, target:iqn.2014-10.com.mengtao:server.disk1, portal: 172.16.100.100,3260] successful.
[root@localhost ~]#
删除信息:
# iscsiadm -m node -o delete -T iqn.2014-10.com.mengtao:server.disk1 -p172.16.100.100
# rm -rf/var/lib/iscsi/send_targets/172.16.100.100,3260
# ls -lh /var/lib/iscsi/send_targets/
total 0
服务器端配置:
backing-store /dev/sdb
incominguser iscsiuser iscsiuser
initiator-address 172.16.100.0/24
# tgtadm --lld iscsi -m target --op show
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 5369 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sdb
Backing store flags:
Account information:
iscsiuser
ACL information:
172.16.100.0/24
[root@localhost ~]#
客户端操作:
发现设备:
# iscsiadm -m discovery -t sendtargets -p172.16.100.100
172.16.100.100:3260,1iqn.2014-10.com.mengtao:server.disk1
# iscsiadm -m node -T iqn.2014-10.com.mengtao:server.disk1 -p 172.16.100.100 -l
Logging in to [iface: default, target:iqn.2014-10.com.mengtao:server.disk1, portal: 172.16.100.100,3260] (multiple)
iscsiadm: Could not login to [iface:default, target: iqn.2014-10.com.mengtao:server.disk1, portal:172.16.100.100,3260].
iscsiadm: initiator reported error (24 -iSCSI login failed due to authorization failure)
iscsiadm: Could not log into all portals
[root@localhost ~]#
认证失败
修改配置:
# /etc/init.d/iscsi restart
# iscsiadm -m discovery -t st -p 172.16.100.100
172.16.100.100:3260,1iqn.2014-10.com.mengtao:server.disk1
# iscsiadm -m discovery -t st -p 172.16.100.100 -l
172.16.100.100:3260,1iqn.2014-10.com.mengtao:server.disk1
Logging in to [iface: default, target:iqn.2014-10.com.mengtao:server.disk1, portal: 172.16.100.100,3260] (multiple)
Login to [iface: default, target: iqn.2014-10.com.mengtao:server.disk1,portal: 172.16.100.100,3260] successful.
[root@localhost ~]#
# mount /dev/sdc1 /mnt/
# ls -lh /mnt/
total 20K
-rw-r--r-- 1 root root 779 Oct 29 22:10fstab
drwx------ 2 root root 16K Oct 29 22:09lost+found
[root@localhost ~]#