In this tutorial, we are going to learn the below thing
- How to configure ISCSI Target and ISCSI initiator with LVM and Non-LVM Disk.
- How to configure Multipath and extend LVM and Non-LVM Disk.
- How to Migrate Data from Storage01 to Storage02.
- How to release Storage01 disks.
- Troubleshooting with multipath.
Environment:
- IP-Address: 192.168.2.121 192.168.2.126
- Disk: 4 GB(LVM) & 9GB(Non-LVM).
- Operation system: Centos 7.6
- IP-Address: 192.168.2.123 192.168.2.127
- Disk: 7GB & 12 GB.
- Operation system: Centos 7.6
- IP-Address: 192.168.2.122
- Operation system: Centos 7.6
Note: Disable firewall and selinux on all the servers.
Lab01: Configure ISCSI Target and ISCSI initiator with LVM and Non-LVM Disk using multipath.
1. Let’s login to storage01 and install iscsi target software.
2. Let’s create lvm partition on 4 GB disk.
# pvcreate /dev/sdc
# vgcreate iscsivg /dev/sdc
# lvcreate -l 100%FREE -n iscsilv iscsivg
3. Let start the configuration of iscsi target.
# targetcli
a. Create LUNS on LVM(4GB) and Non-LVM disk(9-GB)
/> cd backstores/block
/backstores/block> create S1SLUN00 /dev/sdb
/backstores/block> create S1LLUN01 /dev/iscsivg/iscsilv
b. Create iscsi server
/> cd iscsi
/iscsi> create iqn.2021-07.com.storage01:server
c. Create iscsi client
/> cd /iscsi/iqn.2021-07.com.storage01:server/tpg1/acls
/iscsi/iqn.20...ver/tpg1/acls> create iqn.2021-07.com.data01:client
d. Map the LUNS to iscsi client.
/> cd /iscsi/iqn.2021-07.com.data01:server/tpg1/luns
/iscsi/iqn.20...ver/tpg1/luns> create /backstores/block/LUN00
/iscsi/iqn.20...ver/tpg1/luns> create /backstores/block/LUN01
/> cd
/> ls
f. Save and exit the targetcli utility
/> saveconfig
/> exit
4. Let’s login to Data01 server & install iscsi-initiator-utils package.
5. Change the initiator name# yum install iscsi-initiator-utils
# vi /etc/iscsi/initiatorname.iscsi
InitiatorName= iqn.2021-07.com.data01:client
6. Start the below services.
# systemctl start iscsi
# systemctl start iscsid
# iscsiadm -m discovery -t st -p 192.168.2.121:3260# iscsiadm -m discovery -t st -p 192.168.2.126:3260
# iscsiadm -m node -T iqn.2021-07.com.storage01:server -p 192.168.2.121:3260 -l#lsblk# iscsiadm -m node -T iqn.2021-07.com.storage01:server -p 192.168.2.126:3260 -l#lsblk
9. Install multipath package to resolve multiple disk issue.
# yum install device-mapper-multipath -y
# cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/
# systemctl start multipathd
# cat -n /etc/multipath.conf | grep -v "#"23 defaults {24 user_friendly_names yes25 find_multipaths yes26 }
# multipath -ll
# pvcreate /dev/mapper/mpatha# pvcreate /dev/mapper/mpathb# vgcreate datavg01 /dev/mapper/mpatha# vgcreate datavg02 /dev/mapper/mpathb# lvcreate -l 100%FREE -n datalv01 datavg01# lvcreate -l 100%FREE -n datalv02 datavg02# mkdir /data1# mkdir /data2# mkfs.xfs /dev/datavg01/datalv01# mkfs.xfs /dev/datavg02/datalv02# mount /dev/datavg01/datalv01 /data1/# mount /dev/datavg02/datalv02 /data2/
1. Login to storage01 server and add 2GB new disk and extend the logical volume.
# pvcreate /dev/sdd# vgextend iscsivg /dev/sdd# lvextend -l +100%FREE /dev/iscsivg/iscsilv
# multipath -ll mpathb
# echo 1 > /sys/block/sde/device/rescan
# echo 1 > /sys/block/sdc/device/rescan
# multipathd resize map mpathb# multipath -ll mpathb# pvresize /dev/mapper/mpathb# lvextend -l 100%FREE -n /dev/datavg01/datavg01 -rn
# df -Pth /data01
Lab03: Add new disk storage and extend 9 GB Non LVM disk
1. Login to storage01 server and new disk of 1 GB to target application.
# targetcli
/> cd /backstores/block
/backstores/block> create S1SLUN02 /dev/sde
/backstores/block> cd /iscsi/iqn.2021-07.com.storage01:server/tpg1/luns/
/iscsi/iqn.20...ver/tpg1/luns> create /backstores/block/LUN02
4. Check the status
/> ls
/> saveconfig/> exit
# echo "- - -" > /sys/class/scsi_host/host4/scan
# echo "- - -" > /sys/class/scsi_host/host5/scan
7. After scanning the disk you can see the disk visible in multipath.
# multipath -ll
# pvcreate /dev/mapper/mpathc# vgextend datavg02 /dev/mapper/mpathc# lvcreate -l 100%FREE -n datalv02 datavg02 -rn
Lab 4: Move all data from the disk connect from storage01 to storage02 and remove disk of storage01 without any downtime.
1. Let’s start build storage02 servers using iscsi target software.
# pvcreate /dev/sdc
# vgcreate iscsivg /dev/sdc
# lvcreate -l 100%FREE -n iscsilv iscsivg
# targetcli
/> cd backstores/block
/backstores/block> create S2SLUN00 /dev/sdb
/backstores/block> create S2LLUN01 /dev/iscsivg/iscsilv
/> cd iscis
/iscsi> create iqn.2021-07.com.storage02:server
6. Create iscis client
/> cd /iscsi/iqn.2021-07.com.storage02:server/tpg1/acls
/iscsi/iqn.20...ver/tpg1/acls> create iqn.2021-07.com.data01:client
/> cd /iscsi/iqn.2021-07.com.data01:server/tpg1/luns/iscsi/iqn.20...ver/tpg1/luns> create /backstores/block/LUN00/iscsi/iqn.20...ver/tpg1/luns> create /backstores/block/LUN01
/> cd/> ls
/> saveconfig/> exit
# dd if=/dev/zero of=/data01/1g.bin bs=1G count=1
# dd if=/dev/zero of=/data01/2g.bin bs=1G count=1
# dd if=/dev/zero of=/data01/3g.bin bs=1G count=1
# dd if=/dev/zero of=/data01/4g.bin bs=1G count=1
# dd if=/dev/zero of=/data02/1g.bin bs=1G count=1
# dd if=/dev/zero of=/data02/2g.bin bs=1G count=1
# dd if=/dev/zero of=/data02/3g.bin bs=1G count=1
# dd if=/dev/zero of=/data02/4g.bin bs=1G count=1
11. Discover the new ISCSI target created on storage02 servers .
# iscsiadm -m discovery -t st -p 192.168.2.123:3260
# iscsiadm -m discovery -t st -p 192.168.2.127:3260
# iscsiadm -m node -T iqn.2021-07.com.storage02:server -p 192.168.2.123:3260 -l
# lsblk
# iscsiadm -m node -T iqn.2021-07.com.storage02:server -p 192.168.2.127:3260 -l
# lsblk
# multipath -ll
# pvcreate /dev/mapper/mpathd
# pvcreate /dev/mapper/mpathe
# vgextend datavg01 /dev/mapper/mpathd
# vgextend datavg02 /dev/mapper/mpathe
# pvmove -b /dev/mapper/mpathb /dev/mapper/mpathd
# pvmove -b /dev/mapper/mpathb /dev/mapper/mpathd
# lvs -a -o+devices
# vgreduce datavg01 /dev/mapper/mpathb
# vgreduce datavg02 /dev/mapper/mpathc
# pvremove /dev/mapper/mpathb
# pvremove /dev/mapper/mpathc
# multipath -f /dev/mapper/mpathb
# multipath -f /dev/mapper/mpathc
# blockdev --flushbufs /dev/mapper/mpathb
# blockdev --flushbufs /dev/mapper/mpathc
# echo 1 > /sys/block/sde/device/delete
# echo 1 > /sys/block/sdc/device/delete
# echo 1 > /sys/block/sdx/device/delete
# echo 1 > /sys/block/sdx/device/delete
# df -h
17. Logout to storage01 ISCSI target
# iscsiadm -m node -T iqn.2021-07.com.storage01:server -p 192.168.2.121:3260 -u
# iscsiadm -m node -T iqn.2021-07.com.storage01:server -p 192.168.2.126:3260 -u
No comments:
Post a Comment