Page 1 of 1
hot standby VM
Posted: 30. Jun 2011, 15:43
by librarymark
Hello, all -
I have to come up with a way to make two vm host servers stay in sync. My boss wants me to make it such that if one of our servers craps out, I can bring up all the vm's on the other server with little down time as possible (of course) and have the Vm's no more than a day out of date data wise.
I have done a lot of searching on this forum and haven't run across a definitive method for doing this. I would rather not have to bring down a vm to clone it if I don't have to.
Can someone point me to a better way than just stopping the running vm and copying it? Would I be able to copy snapshot files from one Vm to an Identical Vm on another physical host?
Thanks!
Library Mark
Re: hot standby VM
Posted: 30. Jun 2011, 15:56
by Perryg
For Windows hosts check out shadowcopy, or Google live backup site:forums.virtualbox.org
Re: hot standby VM
Posted: 30. Jun 2011, 16:01
by librarymark
Thanks, Perryg - sadly, I am using Ubuntu Server 11.04. I guess I should have mentioned it.
Re: hot standby VM
Posted: 30. Jun 2011, 17:13
by Perryg
Re: hot standby VM
Posted: 1. Jul 2011, 16:35
by mschwartz
http://linux.about.com/library/cmd/blcmdl1_rdist.htm
NAME
rdist - remote file distribution client program
...
DESCRIPTION
Rdist is a program to maintain identical copies of files over multiple hosts. It preserves the owner, group, mode, and mtime of files if possible and can update programs that are executing.
Re: hot standby VM [Solved]
Posted: 5. Oct 2011, 19:18
by librarymark
So I wound up using LVM snapshots and rsync. Works very well so far in testing. I keep one machine on the production VM server and export it to an appliance, Then, import the appliance on the backup server. When creating the VM, make sure that there is unused space on the disk so that the LVM snapshots work. Also be sure the share the ssh key from the primary VM to the backup - see
http://www.debian-administration.org/articles/152.
Near as I can tell, if the primary VM fails, all I have to do is change the IP of the backup vm and we are back in business.
(I'm using Ubuntu 9.10 server for testing)
My bash test script looks like this:
Code: Select all
#!/bin/bash
remote_machine="<remote machine IP>"
local_mysql_password="<local mysql password>"
LVCREATE="/sbin/lvcreate"
LVREMOVE="/sbin/lvremove"
MYSQL="/usr/bin/mysql"
MOUNT="/bin/mount"
UMOUNT="/bin/umount"
SSH="/usr/bin/ssh"
RSYNC="/usr/bin/rsync"
# flush and lock local mysql
$MYSQL -p$local_mysql_password -e 'flush tables with read lock; flush logs;'
# create snapshot
$LVCREATE -pr -L5G -s -n rootsnapshot /dev/lvm-test/root
# unlock local mysql
$MYSQL -p$local_mysql_password -e 'unlock tables;'
# mount the snapshot
$MOUNT /dev/lvm-test/rootsnapshot /mnt/rootsnapshot/
# stop apache and mysql on remote host
$SSH $remote_machine '/etc/init.d/apache2 stop'
$SSH $remote_machine 'stop mysql'
# do backup here
$RSYNC --exclude-from /root/exclude_list.txt --delete -avz -e ssh / root@$remote_machine:/
# start mysql and apache on remote host
$SSH $remote_machine 'start mysql'
$SSH $remote_machine '/etc/init.d/apache2 start'
# unmount the snapshot
$UMOUNT /mnt/rootsnapshot/
# remove the snapshot
$LVREMOVE -f /dev/lvm-test/rootsnapshot
and exclude_list.txt looks like this:
Code: Select all
/root/.ssh
/etc/udev
/var/lib/nfs
/proc
/sys
/dev
/tmp
/mnt
/var/run
/var/lib/ureadahead
LIke I said, it seems to be working well. I can install software on the original VM and run the backup script, and the same software runs on the backup machine. If anyone can help me improve this or point out mistakes I would be grateful. This of course does not work for VM's that don't support LVM's like my pfsense firewalls and such, but it's a huge step forward.
Re: hot standby VM
Posted: 5. Oct 2011, 19:36
by vbox4me2
The backup VM's can use the same IP/Mac just keep cable connect set to disconnected or keep them offline, the other Host's IP is not important. If possible use shared storage, that will keep the VM's really small while the data is not inside them.
Re: hot standby VM
Posted: 5. Oct 2011, 19:55
by librarymark
The issue with disconnecting the network cable disconnected is that the backup won't run. When you create the appliance, it gets a new MAC. I have the backup script running every hour.
Re: hot standby VM
Posted: 5. Oct 2011, 20:52
by vbox4me2
If the VM and VBox is not running then the backup(rsync) will update the target, for testing purpose you can bring up a vm with cable disconnected. The MAC can and should be made the same, a hot standby is useless if things need to be changed.
For example when using 2 Hosts where the second is serving as a hot standby but also running other stuff the standby VM's are registered but in a shutdown state, rsync mirrors from A to B but in a separate folder, a small script de-registers the shutdown VDI's, moves the rsynced images, re-registers them and starts them, all with the same uuid/ip and mac. When A is back up the same applies in reverse.
Re: hot standby VM
Posted: 5. Oct 2011, 21:26
by librarymark
My "system" is talking vm to vm, not vm-host to vm-host. If I turn off the backup VM, it does not get updated.
Re: hot standby VM
Posted: 5. Oct 2011, 21:44
by vbox4me2
Huh? what exactly are you updating then? hopefully you are rsyncing vdi to vdi, any other way is a bit cumbersome.
Re: hot standby VM
Posted: 6. Oct 2011, 00:33
by librarymark
Right now I am backing up from one VM to another.
Re: hot standby VM
Posted: 31. Jan 2012, 15:32
by bb42
On my Linux Debian Server, I now use OpenVZ as part of Promox VE - this includes a Cluster option, i.e. central management of multiple physical servers in a master-slave relation.
For my windows clients, I found the various features of VirtualBox with Windows surpass any Linux option.
Re: hot standby VM
Posted: 5. Feb 2012, 22:39
by Technologov
My recommendation:
make 2 servers, and single shared storage (via NFS or SMB), so you can share one VM on both servers:
Machine->add (the VM on both hosts)
then:
You need to check if guest is alive or not, and if not, just fire up the VM on second host.
You can check either by ping or "Guest Control exec".
Re: hot standby VM
Posted: 21. Feb 2013, 18:31
by janki
i am new in cluster server using virtualbox so please give me information about it what ever you all know about it because i want to prepare research paper on it.