【linux】Centos7 iscsi服务搭建
Server:
#yum -y install targetcli
#systemctl stop firewalld.service
#systemctl start target.service
#systemctl enable target.service
#fdisk /dev/vdb
n
p
1
+3G
w
#partprobe /dev/vdb
#ls /dev/vdb(TAB)
#pvcreate /dev/vdb1
#vgcreate iscsi_vg /dev/vdb1
#lvcreate -L 2G -n iscsi_lvm iscsi_vg
#targetcli
>/backstores/block create serverX.disk1 /dev/iscsi_vg/iscsi_lvm
>/iscsi create iqn.2017-07.com.example:serverX
>/iscsi/iqn.2017-07.com.example:serverX/tpg1/acls create iqn.2017-07.com.example:desktopX
>/iscsi/iqn.2017-07.com.example:serverX/tpg1/luns create /backstores/block/serverX.disk1
>/iscsi/iqn.2017-07.com.example:serverX/tpg1/portals create 172.25.X.11
>saveconfig
>exit
Desktop:
#yum -y install iscsi-initiator-utils.x86_64
#vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2017-07.com.example:desktop0
#iscsiadm -m discovery -t st -p 172.25.X.11
#systemctl restart iscsid
#systemctl restart iscsi
#systemctl enable iscsid
#systemctl enable iscsi
#iscsiadm -m discovery -t st -p 172.25.X.11
#iscsiadm -m node -T iqn.2017-07.com.example:serverX -p 172.25.X.11
#iscsiadm -m node -T iqn.2017-07.com.example:serverX -p 172.25.X.11 -l
#fdisk -l | dmesg | lsblk
#fdisk /dev/sdX
n
p
1
+xG
w
#partprobe /dev/sdX
#mkfs.xfs /dev/sdXX
#blkid /dev/sdXX >> /etc/fstab
UUID="" /mnt/iscsi xfs defaults,_netdev 0 0
#mkdir /mnt/iscsi
#mount -a
#df -h
#reboot
#df -h