centos7 安装Open ISCSI 启动器 软件包
yum install iscsi-initiator-utils -y
查看 iscsi 启动器名称
[root@mulangcloud ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:a5c39efe925
扫描 iscsi target
192.168.8.73
iscsi 服务器.
[root@mulangcloud ~]# iscsiadm -m discovery -t st -p 192.168.8.73
192.168.8.73:3260,1 iqn.2020-03.com.ml:target
扫描 open iscsi 客户端已经登陆的 session
在完成目标发现后,即可以登录到相应的节点,使用目标设备提供的存储空间.
-T
后面跟target名称,--login
等同于-l
,
[root@mulangcloud ~]# iscsiadm -m session
tcp: [4] 192.168.8.73:3260,1 iqn.2020-03.com.ml:target (non-flash)
[root@mulangcloud ~]# iscsiadm -m session -r 4 --rescan
Rescanning session [sid: 4, target: iqn.2020-03.com.ml:target, portal: 192.168.8.73,3260]
[root@mulangcloud ~]# ls -l /dev/disk/by-path/
total 0
lrwxrwxrwx 1 root root 9 Jul 24 09:27 ip-192.168.8.73:3260-iscsi-iqn.2020-03.com.ml:target-lun-0 -> ../../sdd
lrwxrwxrwx 1 root root 10 Jul 24 09:27 ip-192.168.8.73:3260-iscsi-iqn.2020-03.com.ml:target-lun-0-part1 -> ../../sdd1
lrwxrwxrwx 1 root root 10 Jul 24 09:27 ip-192.168.8.73:3260-iscsi-iqn.2020-03.com.ml:target-lun-0-part2 -> ../../sdd2
lrwxrwxrwx 1 root root 9 Jul 24 09:25 ip-192.168.8.73:3260-iscsi-iqn.2020-03.com.ml:target-lun-1 -> ../../sde
lrwxrwxrwx 1 root root 9 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0 -> ../../sda
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part3 -> ../../sda3
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part4 -> ../../sda4
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part6 -> ../../sda6
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part7 -> ../../sda7
lrwxrwxrwx 1 root root 9 Jul 19 08:40 pci-0000:00:1f.2-ata-2.0 -> ../../sdb
lrwxrwxrwx 1 root root 9 Jul 19 08:40 pci-0000:00:1f.2-ata-3.0 -> ../../sdc
[root@mulangcloud ~]# echo 1 > /sys/block/sdd/device/delete
[root@mulangcloud ~]# echo 1 > /sys/block/sde/device/delete
[root@mulangcloud ~]# ls -l /dev/disk/by-path/
total 0
lrwxrwxrwx 1 root root 9 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0 -> ../../sda
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part1 -> ../../sda1
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part3 -> ../../sda3
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part4 -> ../../sda4
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part6 -> ../../sda6
lrwxrwxrwx 1 root root 10 Jul 19 08:40 pci-0000:00:1f.2-ata-1.0-part7 -> ../../sda7
lrwxrwxrwx 1 root root 9 Jul 19 08:40 pci-0000:00:1f.2-ata-2.0 -> ../../sdb
lrwxrwxrwx 1 root root 9 Jul 19 08:40 pci-0000:00:1f.2-ata-3.0 -> ../../sdc
[root@mulangcloud ~]# iscsiadm -m node -T iqn.2020-03.com.ml:target -u
Logging out of session [sid: 4, target: iqn.2020-03.com.ml:target, portal: 192.168.8.73,3260]
Logout of [sid: 4, target: iqn.2020-03.com.ml:target, portal: 192.168.8.73,3260] successful.
other
列出所有target
iscsiadm -m node
连接所有target
iscsiadm -m node -L all
连接指定target
iscsiadm -m node -T iqn.... -p 172.29.88.62 --login
使用如下命令可以查看配置信息
iscsiadm -m node -o show -T iqn.2000-01.com.synology:rackstation.exservice-bak
查看目前 iSCSI target 连接状态
iscsiadm -m session
iscsiadm: No active sessions.
(目前没有已连接的 iSCSI target)
断开所有target
iscsiadm -m node -U all
断开指定target
iscsiadm -m node -T iqn... -p 172.29.88.62 --logout
删除所有node信息
iscsiadm -m node --op delete
删除指定节点(/var/lib/iscsi/nodes目录下,先断开session)
iscsiadm -m node -o delete -name iqn.2012-01.cn.nayun:test-01
删除一个目标(/var/lib/iscsi/send_targets目录下)
iscsiadm --mode discovery -o delete -p 172.29.88.62:3260