Monday, May 2, 2011

VPS to VPS migration

* If we want to migrate a vps from one hardware node to another hardware node.

For example:-
In Hardware Node 1 VPS :- 999 3 running 10.10.1.10 www.ajeesh.com

I want to transfer this VPS to Hardware Node 2[10.10.6.5]

1. For vzmigrate first make a password less ssh login from HN1 to HN2. Using the ssh key method we can achieve this.

-bash-3.2# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
57:31:fb:ac:5f:6f:36:0f:62:f5:88:09:76:73:47:1a root@Hardwarenode1.com

/]# cat id_rsa.pub
ssh-rsa Adfgdfgdfgdfgdfgdfgdfgdfgdf8P9XlxUtlgdfgdfE4hEduw5ir7oxsnDW9EM0/pm6w5iDpVcU0adoJypzcsNCrsFn/3hwJ2RsWJJzEUy+vYOXS2WdfgdfgdfgdfgdfgSywtHShkIU4jUF4MHNjWmx45StqrAr36IzjwniK9larIs9jCASDFDSFDFS/0ZXjnJgyRSQiju1rSGdYSDFSDFSDFSDFSDFSD== root@Hardwarenode1.com

Next SSH into Hardware Node 2and paste this key to /root/.ssh/authorized_keys

Next:- in screen here 10.10.6.5 is the IP address of HardwareNode2
-bash-3.2# vzmigrate --online -v 10.10.6.5 999
OPT:--online
OPT:-v
OPT:10.10.6.5
Starting online migration of CT 999 to 10.10.6.5
OpenVZ is running...
Loading /etc/vz/vz.conf and /etc/vz/conf/999.conf files
Check IPs on destination node: 10.10.1.10 192.168.0.10
Preparing remote node
Copying config file
999.conf 100% 1709 1.7KB/s 00:00
Saved parameters for CT 999
Creating remote container root dir
Creating remote container private dir
Initializing remote quota
Quota init
Turning remote quota on
Syncing private
Live migrating container...
Suspending container
Setting up checkpoint...
suspend...
get context...
Checkpointing completed succesfully
Dumping container
Setting up checkpoint...
join context..
dump...
Checkpointing completed succesfully
Copying dumpfile
dump.999 100% 514KB 513.6KB/s 00:00
Syncing private (2nd pass)
Syncing 2nd level quota
Dumping 2nd level quota
Copying 2nd level quota
quotadump.999 100% 21 0.0KB/s 00:00
Load 2nd level quota
Undumping container
Restoring container ...
Starting container ...
vzquota : (warning) Quota is running for id 999 already
Container is mounted
undump...
Adding IP address(es): 10.10.1.10 192.168.0.10
Setting CPU units: 1000
get context...
Container start in progress...
Restoring completed succesfully
Resuming container
Resuming...
Times:
Suspend + Dump: 0.53982
Copy dump file: 0.483621
Second rsync: 1.58368
2nd level quota: 0.631729
Undump + Resume: 0.685746
Total time: 3.92459
Cleanup
Killing container
Killing...
Container is unmounted
Removing dumpfiles
Destroying container
Destroying container private area: /home/vz/private/999
Container private area was destroyed

If you don't want to destroy the source vps please execute the following command

# vzmigrate -r no --online -v 10.10.6.5[HN2] 999[VEID of your VPS]

==========================================================
But this migration is only good for same Datacentre(on their LAN). Different Data centre and public transfer it is not a right choice.

rsync -vare ssh HN1:/* /vz/private// --progress --numeric-ids --exclude="/proc/*" --exclude="/dev/*"

HN to HN
rsync -vare ssh HN1(old serverIP):/vz/private//* /vz/private// --progress --numeric-ids
=============================================================

No comments:

Post a Comment