1) 拓扑
|----------------------|
| node03.1000cc.net |
| iSCSI Target |
| 192.168.10.13 |
|-----------+----------|
|
|----------------------| | |----------------------|
| node01.1000cc.net | | | node2.1000cc.net |
| 192.168.10.11 +--------------+--------------+ 192.168.10.12 |
|----------------------| |----------------------|
2) 安装及配置iSCSI Target
[root@node3 ~]# yum install targetcli -y
[root@node3 ~]# mkdir /iscsi
[root@node3 ~]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb49
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> cd /backstores/fileio
/backstores/fileio> create disk1 /iscsi/disk1 3G
Created fileio disk1 with size 3221225472
/backstores/fileio> create disk2 /iscsi/disk2 3G
Created fileio disk2 with size 3221225472
/backstores/fileio> cd /iscsi
/iscsi> create iqn.2020-02.net.1000cc:fence
Created target iqn.2020-02.net.1000cc:fence.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> create iqn.2020-02.net.1000cc:data
Created target iqn.2020-02.net.1000cc:data.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> cd iqn.2020-02.net.1000cc:data/tpg1/luns
/iscsi/iqn.20...ata/tpg1/luns> create /backstores/fileio/disk1
Created LUN 0.
/iscsi/iqn.20...ata/tpg1/luns> cd ../acls
/iscsi/iqn.20...ata/tpg1/acls> create iqn.2020-02.net.1000cc:node1
Created Node ACL for iqn.2020-02.net.1000cc:node1
Created mapped LUN 0.
/iscsi/iqn.20...ata/tpg1/acls> cd iqn.2020-02.net.1000cc:node1/
/iscsi/iqn.20....1000cc:node1> set auth userid=snow
Parameter userid is now 'snow'.
/iscsi/iqn.20....1000cc:node1> set auth password=123456
Parameter password is now '123456'.
/iscsi/iqn.20....1000cc:node1> cd ../
/iscsi/iqn.20...ata/tpg1/acls> create iqn.2020-02.net.1000cc:node2
Created Node ACL for iqn.2020-02.net.1000cc:node2
Created mapped LUN 0.
/iscsi/iqn.20...ata/tpg1/acls> cd iqn.2020-02.net.1000cc:node2/
/iscsi/iqn.20....1000cc:node2> set auth userid=snow
Parameter userid is now 'snow'.
/iscsi/iqn.20....1000cc:node2> set auth password=123456
Parameter password is now '123456'.
/iscsi/iqn.20...ata/tpg1/acls> cd /iscsi/iqn.2020-02.net.1000cc:fence/tpg1/luns
/iscsi/iqn.20...nce/tpg1/luns> create /backstores/fileio/disk2
Created LUN 0..
/iscsi/iqn.20...nce/tpg1/luns> cd ../acls
/iscsi/iqn.20...nce/tpg1/acls> create iqn.2020-02.net.1000cc:node1
Created Node ACL for iqn.2020-02.net.1000cc:node1
Created mapped LUN 0..
/iscsi/iqn.20...nce/tpg1/acls> cd iqn.2020-02.net.1000cc:node1/
/iscsi/iqn.20....1000cc:node1> set auth userid=snow
Parameter userid is now 'snow'.
/iscsi/iqn.20....1000cc:node1> set auth password=123456
Parameter password is now '123456'..
/iscsi/iqn.20....1000cc:node1> cd ../
/iscsi/iqn.20...nce/tpg1/acls> create iqn.2020-02.net.1000cc:node2
Created Node ACL for iqn.2020-02.net.1000cc:node2
Created mapped LUN 0..
/iscsi/iqn.20...nce/tpg1/acls> cd iqn.2020-02.net.1000cc:node2/
/iscsi/iqn.20....1000cc:node2> set auth userid=snow
Parameter userid is now 'snow'.
/iscsi/iqn.20....1000cc:node2> set auth password=123456
Parameter password is now '123456'..
/> ls
o- / ....................................................................... [...]
o- backstores ............................................................ [...]
| o- block ................................................ [Storage Objects: 0]
| o- fileio ............................................... [Storage Objects: 2]
| | o- disk1 ...................... [/iscsi/disk1 (3.0GiB) write-back activated]
| | | o- alua ................................................. [ALUA Groups: 1]
| | | o- default_tg_pt_gp ..................... [ALUA state: Active/optimized]
| | o- disk2 ...................... [/iscsi/disk2 (3.0GiB) write-back activated]
| | o- alua ................................................. [ALUA Groups: 1]
| | o- default_tg_pt_gp ..................... [ALUA state: Active/optimized]
| o- pscsi ................................................ [Storage Objects: 0]
| o- ramdisk .............................................. [Storage Objects: 0]
o- iSCSI .......................................................... [Targets: 2]
| o- iqn.2020-02.net.1000cc:data ..................................... [TPGs: 1]
| | o- tpg1 ............................................. [no-gen-acls, no-auth]
| | o- acls ........................................................ [ACLs: 2]
| | | o- iqn.2020-02.net.1000cc:node1 ....................... [Mapped LUNs: 1]
| | | | o- mapped_lun0 .............................. [lun0 fileio/disk1 (rw)]
| | | o- iqn.2020-02.net.1000cc:node2 ....................... [Mapped LUNs: 1]
| | | o- mapped_lun0 .............................. [lun0 fileio/disk1 (rw)]
| | o- luns ........................................................ [LUNs: 1]
| | | o- lun0 ............... [fileio/disk1 (/iscsi/disk1) (default_tg_pt_gp)]
| | o- portals .................................................. [Portals: 1]
| | o- 0.0.0.0:3260 ................................................... [OK]
| o- iqn.2020-02.net.1000cc:fence .................................... [TPGs: 1]
| o- tpg1 ............................................. [no-gen-acls, no-auth]
| o- acls ........................................................ [ACLs: 2]
| | o- iqn.2020-02.net.1000cc:node1 ....................... [Mapped LUNs: 1]
| | | o- mapped_lun0 .............................. [lun0 fileio/disk2 (rw)]
| | o- iqn.2020-02.net.1000cc:node2 ....................... [Mapped LUNs: 1]
| | o- mapped_lun0 .............................. [lun0 fileio/disk2 (rw)]
| o- luns ........................................................ [LUNs: 1]
| | o- lun0 ............... [fileio/disk2 (/iscsi/disk2) (default_tg_pt_gp)]
| o- portals .................................................. [Portals: 1]
| o- 0.0.0.0:3260 ................................................... [OK]
o- loopback ....................................................... [Targets: 0]
/> exit
Global pref auto_save_on_exit=true
Configuration saved to /etc/target/saveconfig.json
[root@node3 ~]# systemctl enable --now target.service
[root@node3 ~]# netstat -lantp | grep 3260
tcp 0 0 192.168.10.13:3260 0.0.0.0:* LISTEN -
tcp 0 0 192.168.10.23:3260 0.0.0.0:* LISTEN -
3) 配置iSCSI Initiator(Node1和Node2都需要安装)
[root@node1 ~]# pssh -h host-list.txt -i 'yum install iscsi-initiator-utils -y'
[root@node1 ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2020-02.net.1000cc:node1
[root@node1 ~]# vim /etc/iscsi/iscsid.conf
# 更改57,61,62行,改为如下内容
node.session.auth.authmethod = CHAP
node.session.auth.username = snow
node.session.auth.password = 123456
[root@node2 ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2020-02.net.1000cc:node2
[root@node2 ~]# vim /etc/iscsi/iscsid.conf
# 更改57,61,62行,改为如下内容
node.session.auth.authmethod = CHAP
node.session.auth.username = snow
node.session.auth.password = 123456
4)连接iSCSI Target
[root@node1 ~]# iscsiadm -m discovery -t sendtargets -p node3.1000cc.net
192.168.10.13:3260,1 iqn.2020-02.net.1000cc:fence
192.168.10.13:3260,1 iqn.2020-02.net.1000cc:data
[root@node2 ~]# iscsiadm -m discovery -t sendtargets -p node3.1000cc.net
192.168.10.13:3260,1 iqn.2020-02.net.1000cc:fence
192.168.10.13:3260,1 iqn.2020-02.net.1000cc:data
[root@node1 ~]# iscsiadm -m node --login
Logging in to [iface: default, target: iqn.2020-02.net.1000cc:data, portal: 192.168.10.13,3260] (multiple)
Logging in to [iface: default, target: iqn.2020-02.net.1000cc:fence, portal: 192.168.10.13,3260] (multiple)
Login to [iface: default, target: iqn.2020-02.net.1000cc:data, portal: 192.168.10.13,3260] successful.
Login to [iface: default, target: iqn.2020-02.net.1000cc:fence, portal: 192.168.10.13,3260] successful.
[root@node2 ~]# iscsiadm -m node --login
Logging in to [iface: default, target: iqn.2020-02.net.1000cc:data, portal: 192.168.10.13,3260] (multiple)
Logging in to [iface: default, target: iqn.2020-02.net.1000cc:fence, portal: 192.168.10.13,3260] (multiple)
Login to [iface: default, target: iqn.2020-02.net.1000cc:data, portal: 192.168.10.13,3260] successful.
Login to [iface: default, target: iqn.2020-02.net.1000cc:fence, portal: 192.168.10.13,3260] successful.
[root@node1 ~]# pssh -h host-list.txt -i 'lsblk | grep sd'
[1] 14:58:04 [SUCCESS] root@node1.1000cc.net
sda 8:0 0 3G 0 disk
sdb 8:16 0 3G 0 disk
[2] 14:58:04 [SUCCESS] root@node2.1000cc.net
sda 8:0 0 3G 0 disk
sdb 8:16 0 3G 0 disk
|