How to migrate storage data (pvmove) on Physical Linux Server

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:

Host Name: storage01
  • IP-Address: 192.168.2.121 192.168.2.126
  • Disk: 4 GB(LVM) & 9GB(Non-LVM).
  • Operation system: Centos 7.6 

Host Name: storage02
  • IP-Address: 192.168.2.123 192.168.2.127
  • Disk: 7GB & 12 GB.
  • Operation system: Centos 7.6 

Host Name: data01
  • 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. 

# yum install targetcli -y
# systemctl start target
# systemctl enable target 

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

 e.  Review the configuration

/> cd
/> ls 

f. Save and exit the targetcli utility

/> saveconfig
/> exit

4. Let’s login to Data01 server & install iscsi-initiator-utils package.

# yum install iscsi-initiator-utils

5. Change the initiator name

# vi /etc/iscsi/initiatorname.iscsi
InitiatorName= iqn.2021-07.com.data01:client

6. Start the below services.

# systemctl start iscsi
# systemctl start iscsid

7. Discovery the iscsi target using iscsiadm command.

# iscsiadm -m discovery -t st -p 192.168.2.121:3260
# iscsiadm -m discovery -t st -p 192.168.2.126:3260

8. Login to iscsi target & check disks assign to data01 server.

# 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

Note: -l = login ; -u is to logout.

9. Install multipath package to resolve multiple disk issue. 

# yum install device-mapper-multipath -y

10. Copy the example file from below location to /etc

# cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/

11. Start multipathd service on data01

# systemctl start multipathd


12. Check the multipath.conf file.


# cat -n /etc/multipath.conf | grep -v "#"
23 defaults {
24 user_friendly_names yes
25 find_multipaths yes
26 }

13. Check disk status using multipath command

# multipath -ll

14. Let create partition of both disk mpatha and mpathb and mount on /data1 and /data2 folders.

# 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/

Lab02: Extend the same storage LVM LUN from 4GB to 6GB.

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 

2. Login to data01 servers and scan the HBA. 
 
# multipath -ll mpathb
# echo 1 > /sys/block/sde/device/rescan
# echo 1 > /sys/block/sdc/device/rescan

3. Initialized the disk and extend the partition.

# multipathd resize map mpathb 
# multipath -ll mpathb 
# pvresize /dev/mapper/mpathb 
# lvextend -l 100%FREE -n /dev/datavg01/datavg01 -rn

4. Check disk space.

# 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

2. Create new LUN02
/> cd /backstores/block 
/backstores/block> create S1SLUN02 /dev/sde
 
3. Map the LUNs to storage devices.

/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 

5. Save and exist

/> saveconfig 
/> exit

 6. Let’s login to data01 servers and scan host device.

# 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

8. Now extend the disk.

# 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.

# yum install targetcli -y
# systemctl start target
# systemctl enable target 

2. Create disk partition on below disk.

# pvcreate /dev/sdc
# vgcreate iscsivg /dev/sdc
# lvcreate -l 100%FREE -n iscsilv iscsivg

 3. Start the configuration of iscsi target.

# targetcli

4. Create LUNS

/> cd backstores/block
/backstores/block> create S2SLUN00 /dev/sdb 
/backstores/block> create S2LLUN01 /dev/iscsivg/iscsilv

5. Create iscis servers.

/> 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

7. 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

 8. Review the configuration

/> cd
/> ls 

9. Save and exit the targetcli utility

/> saveconfig
/> exit

 10. Login to data01 server and generate data on partition /data01 and /data02.

# 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

 12. Connect the ISCSI target of storage02 & check disk assigned.

# 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

 13. Add the disk to LVM and extend the volume group.

# pvcreate /dev/mapper/mpathd
# pvcreate /dev/mapper/mpathe
# vgextend datavg01 /dev/mapper/mpathd
# vgextend datavg02 /dev/mapper/mpathe

 14. Move the data from storage01 disks to storage02 disks.

# pvmove -b /dev/mapper/mpathb /dev/mapper/mpathd
# pvmove -b /dev/mapper/mpathb /dev/mapper/mpathd

 15. Monitor the data transfer status using the below command.

#  lvs -a -o+devices

 16. Once data migration is completed we can start remove disks of storage01

# 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