環境RHEL7.4 1.搭建伺服器端主機環境 網路配置 網卡eth0 10.0.0.1 網卡eth1 10.1.0.1 網卡eth2 10.2.0.1 網卡eth3 10.3.0.1 硬碟配置 添加一塊100GB硬碟,配置成DATAVG,劃分LV併發布成iscsi硬碟 iscsi target服務配 ...
網卡eth0 10.0.0.1
添加一塊100GB硬碟,配置成DATAVG,劃分LV併發布成iscsi硬碟
#yum install targetd targetcli -y
firewall-cmd --permanent --add-port=3260/tcp
p查看->n新建->p主分區->1分區1->回車預設起始扇區->回車預設使用全部大小
t選擇分區類型->L列出所有類型->8e設定為Linux LVM->w寫入磁碟
# vgcreate vgiscsi00 /dev/sdb1
# lvcreate -n lv_5G_00 -L 5G vgiscsi00
# lvcreate -n lv_5G_01 -L 5G vgiscsi00
# lvcreate -n lv_5G_02 -L 5G vgiscsi00
/backstores/block> create asmdisk5G00.disk /dev/vgiscsi00/lv_5G_00
/backstores/block> create asmdisk5G01.disk /dev/vgiscsi00/lv_5G_01
/backstores/block> create asmdisk5G02.disk /dev/vgiscsi00/lv_5G_02
/iscsi> create iqn.2015-06.com.sample.domain:sharedisk
create iqn.2015-06.com.sample.domain:server00
create /backstores/block/asmdisk5G00.disk
create /backstores/block/asmdisk5G01.disk
create /backstores/block/asmdisk5G02.disk
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
2.客戶端主機配置
網卡eth0 10.0.0.10
客戶端訪問iscsi存儲
yum install iscsi-initiator-utils -y
[root@localhost ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2015-06.com.sample.domain:server00
# iscsiadm -m discovery -t st -p 10.0.0.1
5.登陸到呈現的iSCSI目標
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.0.0.1 –l
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.1.0.1 –l
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.2.0.1 –l
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.3.0.1 -l
[root@localhost nodes]# iscsiadm -m session -P 3|grep Attached
5. 查找新iSCSI目標的持久節點記錄
less iqn.2015-06.com.sample.domain:sharedisk /10.0.0.1,3260,1/default
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.0.0.1 –u
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.1.0.1 –u
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.2.0.1 –u
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.3.0.1 -u
ls -1R仍存在記錄,但是lsblk塊存儲消失,重啟iscsi服務,lsblk重新發現
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.0.0.1 -u
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.1.0.1 -u
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.2.0.1 -u
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.3.0.1 -u
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.0.0.1 -o delete
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.1.0.1 -o delete
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.2.0.1 -o delete
# iscsiadm -m node -T iqn.2015-06.com.sample.domain:sharedisk -p 10.3.0.1 -o delete
ls -1R記錄消失,但是lsblk塊存儲消失,重啟iscsi服務,lsblk沒有節點記錄
# iscsiadm -m discovery -t st -p 192.168.31.11
#ls -1R
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
├─sda1 8:1 0 500M 0 part /boot
├─rhel-root 253:0 0 27.5G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
[root@localhost nodes]# blkid /dev/sdb
[root@localhost nodes]# fdisk -l