Can anyone provide a guide on how to mirror an existing VPS to a different host? The ideal setup would be like this:
Linux VPS at Host 1 [Master]
Linux VPS at Host 2 [Slave]
All requests go to the Master, which provides sshd, httpd, ftpd, and mail services. This server is replicated to the Slave VPS on Host 2 and kept synchronized. (rsync?)
If/When Master server/host goes down, all requests automatically get routed to the Slave VPS at Host 2 and when Master VPS at Host 1 is back up, the Slave updates the Master with files/content/db's which have changed and requests start going to the Master VPS again at Host 1.
The slave acts as a backup machine which is also the fail-over system.
I know that some hosts are now offering Mirrored VPS's, however I would like to place them at different hosts, which to me seems a much more secure, reliable and robust mirrored setup.
In all likelyhood I would be doing this on a CentOS Linux box, so instructions for that distro would be most appreciated. Anyone know of a good HOWTO or guide for this?
Thanks to everyone on WHT who provide such excellent stickies as "Secure a VPS" which is probably the first thing any VPS newbie should delve into! You provide a valuable service to the community and you *are* appreciated!!
You're definitely taking the right approach! VPS failover in the same data center is a plan for disaster but very few realize it. The idea is use DNS failover with database and content replication (slave-master or master-master for the DB). This is the simplest form of data/db syncing.
The actual implementation requires a very long tutorial. Perhaps some day we'll release the failover mechanism we use for free here. Time will tell.
one way to do it is to have a shared filesystem, such as a san - although single point of failure again then, and you'd only want the san to contain your web/db data, not your os.
database replication can be done at the db layer pretty well/easily.
of course round-robin dns is easy.
you could just setup the second server as secondary mx for mail.
but rsync is not really going to work properly for this kind of thing, as you'll have to do it too often to be useful - like once every few seconds. rsync is brilliant and i use it all the time for backup (and even initial deployment of new servers) but i don't think its quite right here.
failover systems you would use on hardware is different to what you can do with a vps - like a hardware load balancer would be fine for two hardware servers, but not virtual ones. i guess if you control the host nodes it would be easy enough, just use lvm over iscsi to snapshot the /vz/private/<veid>/ directories.
i agree with unixy, failover in the same datacenter isn't hugely useful, its ok, but what happens when power/isp goes down - both your servers are useless.
i'm trying to setup a backup system with my three vps's but don't have a satisfactory implementation yet - but then i'm trying to sync a mailserver vps and a webserver vps to a third vps on another continent, so kind of two-into-one setup.
I do something like that (and if you search these forums there are multiple discussions on this exact topic).
I use DNSMadeEasy for the DNS failover (this will detect when your primary is down and start routing traffic to your backup). Mind you it's not perfect but it's cheap and good enough for me.
You can then mirror your DB's using Master:Master replication (there are more then one way of doing this), use something like Unison (unfortunately doesn't seem to have been upgraded in awhile) for your file replication.