ISCSI 服务器

Server:192.168.1.211

基于 RAID 10 & LVM,虚拟机里添加四块硬盘,分别为 /dec/sdb /dev/sdc /dev/sdd /dev/sde

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
yum -y install mdadm
mdadm -Cv /dev/md0 -n 4 -l 10 /dec/sdb /dev/sdc /dev/sdd /dev/sde
mdadm -D /dev/md0
pvcreate /dev/md0
vgcreate vg0 /dev/md0
lvcreate -n lv1 -L 5G vg0
targetcli
>/backstores/block create server.lvm1 /dev/vg0/lv1
>/iscsi create iqn.2018-04.com.example:server
>/iscsi/iqn.2018-04.com.example:server/tpg1/acls create iqn.2018-04.com.example:desktop
>/iscsi/iqn.2018-04.com.example:server/tpg1/luns create /backstores/server.lv1
>/iscsi/iqn.2018-04.com.example:server/tpg1/portals delete 0.0.0.0 3260
>/iscsi/iqn.2018-04.com.example:server/tpg1/portals create 192.168.1.211 3260
>saveconfig
>exit
firewall-cmd --permanent --add-port=3260/tcp
firewall-cmd --reload
systemclt restart targetd
systemctl enable targetd

Desktop:192.168.1.210

1
2
3
4
5
6
7
8
9
10
11
12
13
yum -y install iscsi-initiator-utils
vim /etc/iscsi/initiatorname.iscsi
iqn.2018-04.com.example:desktop
systemctl restart iscsi iscsid
systemctl enable iscsi iscsid
iscsiadm -m discovery -t st -p 192.168.1.211
iscsiadm -m node -T iqn.2018-04.com.example:server -p 192.168.1.211 -l
mkfs.ext4 /dev/vdb
blkid | grep /dev/vdb >> /etc/fstab
vim /etc/fstab
UUID="b7a2532e-10d9-4a38-a338-c22e994a0773" /mnt/iscsi ext4 defaults,_netdev 0 0
mkdir /mnt/iscsi
mount -a