服务器添加4块硬盘
mdadm -Cv /dev/md0 -n 3 -l 5 -x 1 /dev/sdb /dev/sdc /dev/sdd /dev/sde
mdadm -Cv /dev/md0 -n 3 -l 5 -x 1 /dev/sdb /dev/sdc /dev/sdd /dev/sde
记下UUID值
mdadm -D /dev/md0
mdadm -D /dev/md0
UUID : 3bf9f088:85d776c9:174cce9b:5ef065b6
vim /etc/mdadm.conf
DEVICE /dev/sdb /dev/sdc /dev/sdd /dev/sde
ARRAY /dev/md0 UUID=3bf9f088:85d776c9:174cce9b:5ef065b6
yum install targetd targetcli -y
systemctl start targetd
create disk0 /dev/md0
cd /
ls
create
cd iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.1d335848f0e7/tpg1/luns
yum install targetd targetcli -y
systemctl start targetd
targetcli
o- backstores .......................................................... [...]
o- backstores .......................................................... [...]
| o- block .............................................. [Storage Objects: 1]
| o- fileio ............................................. [Storage Objects: 0]
| o- pscsi .............................................. [Storage Objects: 0]
| o- ramdisk ............................................ [Storage Objects: 0]
o- iscsi ........................................................ [Targets: 0]
o- loopback ..................................................... [Targets:
cd /backstores/blockcreate disk0 /dev/md0
cd /
ls
o- backstores .......................................................... [...]
| o- block .............................................. [Storage Objects: 1]
| | o- disk0 ..................... [/dev/md0 (40.0GiB) write-thru deactivated]
| o- fileio ............................................. [Storage Objects: 0]
| o- pscsi .............................................. [Storage Objects: 0]
| o- ramdisk ............................................ [Storage Objects: 0]
o- iscsi ........................................................ [Targets: 0]
o- loopback ..................................................... [Targets:
cd iscsicreate
cd iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.1d335848f0e7/tpg1/luns
create /backstores/block/disk0
cd ../acls
cd ../acls
create iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.1d335848f0e7:client
cd ../portals
create 192.168.10.10
ls /
exit
firewall-cmd --permanent --add-port=3260/tcp
firewall-cmd --reload
客户端
ping -c 4 192.168.10.10
yum install iscsi-initiator-utils
vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.1d335848f0e7:client
systemctl restart iscsid
iscsiadm -m discovery -t st -p 192.168.10.10
create 192.168.10.10
ls /
exit
firewall-cmd --permanent --add-port=3260/tcp
firewall-cmd --reload
客户端
ping -c 4 192.168.10.10
yum install iscsi-initiator-utils
vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.1d335848f0e7:client
systemctl restart iscsid
iscsiadm -m discovery -t st -p 192.168.10.10
iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.1d335848f0e7 -p 192.168.10.10 --login
mkfs.xfs /dev/sdb
mkdir /iscsi
mount /dev/sdb /iscsi
df -h
blkid | grep /dev/sdb
vim /etc/fstab
UUID=fc614f17-082f-467e-bb4e-40c5ff811d24 /iscsi xfs defaults,_netdev 0 0