Move LVM partitions from one server to another
Hi All,
Few days ago, in an interview I was asked whether in RHEL/CentOS is it possible to move LVM partitions from one server to another servers. Just for illustration, I will call the Server "A" which currently has LVM Filesystems and call the Server "B", on which I want to move the LVM Filesystems of Server "A". I know that I can move VG (and its LVs obviously) from one server to another by exporting and importing it (if we have a shared storage or if we physically plug and unplug the disks), as also illustrated in this link too. This was my answer too. Now, is it possible to move (or copy) the VG from Server "A" to Server "B" without a shared storage or without plug/unplug-ing the disks. Forgive my ignorance on this. |
Quote:
The steps would basically go like this... Create snapshot: (implies you have enough room in the VG to create the snapshot. I chose 1G...you can be more conservative with the size if you want. NOTE: snapshots are COW snapshots) Code:
root@serverA# lvcreate --snapshot /dev/volumegroup/logvol --name logvol_snap --size 1G Code:
root@serverA# mount -o ro /dev/volumegroup/logvol_snap /mnt Code:
root@serverA# rsync -auv --delete /mnt/ serverB:/path/to/dir/ |
Hi Custangro,
I just paid more attention to the steps listed by you. Here, you are just syncing two directories, but this won't move the VG or LVM Filesystem but its contents. Is there any way out that I can move the entire VG to another server without removing disks from the primary server. Thanks. |
This is how we move LVs from one server to another:
Target machine: Quote:
Quote:
|
Quote:
Thanks for the response. My source machine (where LVM is present) is 192.168.1.20 and target machine is 192.168.1.10 I am getting the below error (invalid option -- q) when I am running this command on 192.168.1.20 Code:
# sh -c "dd if=/dev/vg1/lv1 bs=2M | pv | nc 192.168.1.10 7000 -q 10" |
Quote:
It would help if you could give us the output of Code:
vgs Code:
lvs |
Quote:
Please find the output of lvs and vgs. Code:
root@box2:~# vgs |
Quote:
The steps would basically go like this... Create snapshots: Code:
root@serverA# lvcreate --snapshot /dev/vg1/lv1 --name lv1_snap --size 1G Code:
root@serverA# mkdir /mnt/lv1 Code:
root@serverB# vgcreate vg1 /dev/sdX Code:
root@serverA# rsync -auv --delete /mnt/lv1_snap serverB:/mnt/lv1 |
Quote:
I am sorry, I think I am unable to make you understand my query. My aim is NOT to sync the data of the LVM filesystems but to copy (or move) the entire VG/LV to other server such that if I a type lvs or vgs on other server, I could see the copied/moved VGs/LVs onto new server. For example, as of now vg1 (and lv1/2) are on box2 (192.168.1.20). Code:
root@box2:~# vgs Code:
root@box1:~# vgs |
Hi All,
This link worked for me partially. Although, I had to create VG/LV myself, I wonder if there is a way to copy/move LVM metadata too. I followed these steps. I added similar disks on the target system (192.168.1.10) with VG and LV. Code:
root@box1:~# pvcreate /dev/sd{b,c,d} Code:
root@box2:~# dd if=/dev/vg1/lv1 | ssh 192.168.1.10 dd of=/dev/newvg1/newlv1 Code:
root@box1:~# mount /dev/newvg1/newlv1 /mnt |
"Rsync is a great remote server copy tool"
Quote:
This is my first reply since I just signed up. Hope I did it right. |
cosmicflush,
Welcome to LinuxQuestions. This thread is 6 years old and so your comments will probably not help the OP (original poster). In most cases replying to old threads has little value. In searching be mindful of the age of the information since what was posted years ago might not be relevant today. |
All times are GMT -5. The time now is 04:44 PM. |