SolusVM Xen 子机 迁移命令
2014-07-26 tech

暂时不做IDC,本篇博客只作为留档

参照SolusVM的WIKI,那边写的有一些乱,这边就重新写一遍给自己备用好了
以下步骤自上而下执行,旧机和新机可以同时操作,这样可以加快搬迁速度
有些地方我用标签格式替代了,可以直接替代相应标签丢到Console用

Old Node:

1
2
3
4
5
6
lvcreate -n vm{CHILD_ID}_backup —size {Original Size + 5}G /dev/{Old Node Volumn Group Name}
mkfs.ext3 /dev/{Old Node Volumn Group Name}/vm{CHILD_ID}_backup
mkdir -p /home/vm{CHILD_ID}_backup
mount /dev/{Old Node Volumn Group Name}/vm{CHILD_ID}_backup /home/vm{CHILD_ID}_backup
xm shutdown vm{CHILD_ID}
dd if=/dev/{Old Node Volumn Group Name}/vm{CHILD_ID}_img of=/home/vm{CHILD_ID}_backup/vm{CHILD_ID}_backup.img

New Node:

1
2
3
4
5
6
7
lvcreate -n vm{CHILD_ID}_backup —size {Original Size + 5}G /dev/{New Node Volumn Group Name}
lvcreate -n vm{CHILD_ID}_img —size {Original Size}G /dev/{New Node Volumn Group Name}
lvcreate -n vm{CHILD_ID}_swap —size {Original Swap Size}M /dev/{New Node Volumn Group Name}
mkswap /dev/{New Node Volumn Group Name}/vm{CHILD_ID}_swap
mkfs.ext3 /dev/{New Node Volumn Group Name}/vm{CHILD_ID}_backup
mkdir -p /home/vm{CHILD_ID}_backup
mount /dev/{New Node Volumn Group Name}/vm{CHILD_ID}_backup /home/vm{CHILD_ID}_backup

Old Node:

1
scp -C /home/vm{CHILD_ID}_backup/vm{CHILD_ID}_backup.img root@{New Node IP}:/home/vm{CHILD_ID}_backup/

New Node:

1
dd if=/home/vm{CHILD_ID}_backup/vm{CHILD_ID}_backup.img of=/dev/{New Node Volumn Group Name}/vm{CHILD_ID}_img

Old Node:

1
2
3
4
umount /home/vm{CHILD_ID}_backup
lvremove /dev/{Old Node Volumn Group Name}/vm{CHILD_ID}_backup
lvremove /dev/{Old Node Volumn Group Name}/vm{CHILD_ID}_img
lvremove /dev/{Old Node Volumn Group Name}/vm{CHILD_ID}_swap

New Node:

1
2
umount /home/vm{CHILD_ID}_backup
lvremove /dev/{New Node Volumn Group Name}/vm{CHILD_ID}_backup