Friday, June 1, 2018

Online data migration w/ LVM


If you want to migrate your data to a new disc - let's say you decided to
purchase another storage appliance and you want your MYSQL datadir to move to
that appliance without any downtime, LVM mirroring is the way to go.

1. Prepare your LUN and assign/zone it to your server

2. Once the LUN is available, add it to the current VG that holds the MYSQL
datadir
# vgextend myql_vg /dev/sdc

3. Create a mirror of the MYSQL logical volume pointing to the newly added LUN
(this is the RIGHT side of the mirror)
# lvconvert -m1 /dev/mapper/mysql_vg-mysql_lv /dev/sdc

4. Wait until the sync is complete (must be 100% under Cpy%Sync field)
# lvs

5. Once the sync is complete, remove/detach the LEFT side of the mirror (that is
the old LUN) from the MYSQL logical volume
# lvconvert -m0 /dev/mapper/mysql_vg-mysql_lv /dev/sdb

6. Remove the old LUN from the MYSQL VG
# vgreduce mysql_vg /dev/sdb

7. Remove PV label
# pvremove /dev/sdb

8. Detach it from your server

9. Hola! You were able to move your MYSQL database to a new and faster disk
without a  downtime!

No comments:

Post a Comment