iSCSI 有一套自己分享 target 檔名的定義,基本上,藉由 iSCSI 分享出來的 target 檔名都是以 iqn 為開頭,意思是:『iSCSI Qualified Name (iSCSI 合格名稱)』的意思(註5)。那麼在 iqn 後面要接啥檔名呢?通常是這樣的:
iqn.yyyy-mm.
所以我这里按照规范设置的名称,添加好如下配置:
<target iqn.2017-07.com.cnblogs.jyzhao:alfreddisk>
backing-store /dev/vg_storage/lv_lun1 # Becomes LUN 1
</target>
配置完成后,就启动服务和设置开机自启动:
[root@Storage ~]# service tgtd start
Starting SCSI target daemon: [ OK ]
[root@Storage ~]# chkconfig tgtd on
[root@Storage ~]# chkconfig --list|grep tgtd
tgtd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@Storage ~]# service tgtd status
tgtd (pid 1763 1760) is running...
然后查询下相关的信息,比如占用的端口、LUN信息(Type:disk):
[root@Storage ~]# netstat -tlunp |grep tgt
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 1760/tgtd
tcp 0 0 :::3260 :::* LISTEN 1760/tgtd
[root@Storage ~]# tgt-admin --show
Target 1: iqn.2017-07.com.cnblogs.jyzhao:alfreddisk
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 10737 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/vg_storage/lv_lun1
Backing store flags:
Account information:
ACL information:
ALL
5.配置iSCSI客户端
确认开机启动项设置开启:
[root@jyrac1 ~]# chkconfig --list|grep scsi
iscsi 0:off 1:off 2:off 3:on 4:on 5:on 6:off
iscsid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
使用iscsiadm命令扫描服务端的LUN
iscsiadm -m discovery -t sendtargets -p 10.10.1.99
--报错
[root@jyrac1 ~]# iscsiadm -m discovery -t sendtargets -p 10.10.1.99
[ OK ] iscsid: [ OK ]
iscsiadm: cannot make connection to 10.10.1.99: No route to host
iscsiadm: cannot make connection to 10.10.1.99: No route to host
iscsiadm: cannot make connection to 10.10.1.99: No route to host
iscsiadm: cannot make connection to 10.10.1.99: No route to host
iscsiadm: cannot make connection to 10.10.1.99: No route to host
iscsiadm: cannot make connection to 10.10.1.99: No route to host
iscsiadm: connection login retries (reopen_max) 5 exceeded
iscsiadm: Could not perform SendTargets discovery: encountered connection failure
[root@jyrac1 ~]#
--ping可以通
[root@jyrac1 ~]# ping 10.10.1.99
PING 10.10.1.99 (10.10.1.99) 56(84) bytes of data.
64 bytes from 10.10.1.99: icmp_seq=1 ttl=64 time=0.789 ms
64 bytes from 10.10.1.99: icmp_seq=2 ttl=64 time=0.536 ms
^C
--- 10.10.1.99 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1073ms
rtt min/avg/max/mdev = 0.536/0.662/0.789/0.129 ms