2021-06-08

iSCSI 服务:
*在 server101 上安装服务端程序,设置开机自启,防火墙允许此服务
mount /dev/cdrom /isos/
dnf install targetcli -y
70 firewall-cmd --permanent --add-service=iscsi-target
71 firewall-cmd --reload
firewall-cmd --add-port=3260/tcp --permanent
success
[root@westoslinux ~]# firewall-cmd --reload
systemctl enable --now target
16 systemctl enable --now iscsi
17 systemctl enable --now iscsid

*在vdb磁盘上分一个1G大小的LVM分区,用以创建逻辑卷组iSCSI_vg和一个100M大小的逻辑卷disk1_lv
fdisk /dev/vdb n enter enter enter +3G wq
fdisk /dev/vdb n enter enter +1G t 5 8e wq
reboot
pvcreate /dev/vdb5
vgcreate iSCSI_vg /dev/vdb5
lvcreate -L 100M -n disk1_lv iSCSI_vg
mkfs.xfs /dev/iSCSI_vg/disk1_lv

*使用 disk1_lv 作为 iSCSI 的后端存储名称为 server101.disk1
backstores/block create server101.disk1 /dev/iSCSI_vg/disk1_lv

*定义IQN为 iqn.2020-04.com.westos:server101
iscsi/ create iqn.2020-04.com.westos:server101

iscsi/iqn.2020-04.com.westos:server101/tpg1/luns create /backstores/block/server101.disk1

*设置ACL允许initiator name为iqn.2020-04.com.westos:client201的客户端可以连接
iscsi/iqn.2020-04.com.westos:server101/tpg1/acls create iqn.2020-04.com.westos:client201

程序监听172.25.254.101的3260端口
cd iscsi/iqn.2020-04.com.westos:server101/tpg1/portals/
delete 0.0.0.0 3260
iscsi/iqn.2020-04.com.westos:server101/tpg1/portals/ create 172.25.254.101 3260

*client安装客户端程序,连接server101的iSCSI目标资源到本地
16 systemctl enable --now iscsi
17 systemctl enable --now iscsid
vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2020-04.com.westos:client201

systemctl restart iscsi
systemctl restart iscsid

用以创建一个xfs文件系统,并开机自动挂载到/iscsidisk
dnf install iscsi-initiator-utils -y
iscsiadm -m discovery -t st -p 172.25.254.101
iscsiadm -m node -T iqn.2020-04.com.westos:server101 -p 172.25.254.101 -l

fdisk /dev/sda n p e e e wq
mkfs.xfs /dev/sda1
mount /dev/sda1 /iscsidisk/
/dev/sda1 /iscsidisk xfs defaults 0 0

上一篇:iSCSI网络磁盘


下一篇:Linux中的SCSI模型及iSCSI设备发现示例