For all system administrators, there is a (pretty painful) frequently occurring incident, which they hate the most. That is: Migrating a server, for one reason or the other!
For those who still couldn’t get it, assume you have a fully functional web/mail server working flawlessly for more than two years (which you take pride in). One morning, you find a mail from your service provider, that the server you were using for your web/mail services, has reached end-of-life (EOL) and it is advised to move your services to another server. There may be other reasons too, like faulty hardware, such as hard drive crash, etc. You quickly feel your stomach throwing up, because you recall, that how much pain it was to setup qmail, anti-spam, the Apache web-servrer with all those extra modules and MySQL tweaking, hosting 200+ websites, mail boxes, etc etc. And now it is obvious that you have to redo the whole thing again. (Oh my God!). Plus the migration. If it was your own personal server, it might not be such a gruesome picture. However, if this is one of your clients’ server, then you might be cursing yourself to be a system admin at the moment. It is not fiction! This happens to every sys admin. For some (strange) reason, the system admin throws his head down again, and starts building up the new server.
What if you did not have to redo everything from scratch? Haan !!! (Your eyes pop out with excitement). “I would love it!”, you might say. I also hear a “I must be in heaven ?!”. No. :) Luckily you don’t have to wait so long (to go to heaven, that is). The solution is there for you to take advantage of. The solution is Virtulization!
Oh! I know, I know. You just started mumbling, “another nut-case with VMware solution”. No. Why do you think about Vmware only? I am aware that Vmware is (probably? :) the biggest name out there in virtualization. It is not the default answer to all virtulization needs, of everyone out there. If you didn’t know that, then it is time to for you to know, and I would repeat: Vmware is not the only solution for all virtulization needs, of everyone out there. Especially, if you are one of those small/tight budget hosting business, who is just managing the business on a couple of servers, Vmware is just too costly for you. (You can use Vmware Server though, which comes free of cost, but that is a separate story). So what to do?
Xen! Xen has been around for quite some time. It should not sound un-familiar to you at all. Xen, (not XenSource), is part of every modern day Linux distribution out there. RHEL, Fedora (upto Fedora 8), Debian, CENTOS, etc, etc. RHEL declared it the ultimate enterprise ready virtualization technology during past RHEL releases. Suprisingly RedHat started promoting KVM instead of Xen since RHEL 5.3. However RedHat did not throw XEN out of window (yet). [Update: RedHat has removed XEN from RHEL 6]. RedHat has to keep supporting its enterprise XEN customers for coming 5 years. Even if they stop doing that, even if RedHat does not promote XEN, it does not mean that XEN will not exist. XEN is thriving. And being most popular and widely used open-source virtualization technology, it will keep thriving.
So how can you take advantage of XEN virtulization for the scenario explained in the opening text of this article? Simple! Here is the solution in simple words:
All modern Linux distributions support running XEN hypervisor kernel as Domain-0 , or as privileged domain, except Fedora9 and onwards. (Fedora decided to focus on KVM only). So what you should do is, (solution), setup your server to boot XEN kernel instead of normal linux kernel. Then setup your main server as domain 0. Do not setup any web/mail services here. Instead, create a virtual machine on this physical server, (optionally) using command line tools. Setup that (newly created) virtual machine to serve your web/mail/other services. Obviously you would have used a virtual disk ( a large file on the physical host) to setup this virtual machine. (Buying a shared storage and setup virtual disks on that would be financially unjustifiable for a small company, for one or two servers). Then, you can either use the existing IP of the physical server and DNAT particular services towards your virtual machine, or you can get an additional IP from your service provider, and assign that to your virtual machine (ideally on the bridged network). Try not to run any service on the physical host, other than ssh. This will keep things easy to manage. Assign decent amount of RAM to this virtual machine, out of your total physical memory of the physical host. Then, go live.
Now when you have done it, what is the advantage? What is all this hype about? Well, here is the benefit. Assume the same thing happens now, which is explained in opening text. That is, you get an email from the service provider to move your data, as the server is reaching EOL. When you get this mail, instead of panicking, you just smile, as nothing has happened. You would simply ask your service provider to provide the alternate physical host, go through the acquisition and OS installation. Then, simply setup XEN on it, which is nothing but installing the XEN kernel and booting it. Now you are ready for migration. Announce some downtime to your users, (or management), depending on the size of the virtual disk you have on the old server, (because you need time to copy it over the network). Then shut down the virtual machine on the old server. Copy the disk file of this virtual machine over the network from old physical host to the new one. Copy the config file in the same way. Set up a few IP related settings for this “migrated” virtual machine, and ……… start the virtual machine! That is all. Given a few extra steps you have to do for setting up the IP inside the virtual machine, and a few firewall rules on the new physical host, you have nothing else to do. Your job is done. Congratulations !!! You just migrated a server from one physical server to another, without a drop of sweat, successfully. (Oh yes, don’t forget to adjust DNS pointers of your websites to the new (virtual) server.)
It may seem odd at first that running one virtual machine on one physical host?!!! Where is the advantage of consolidation? Well, the advantage “is” there, and the base is now all set for you, for the same. You can, now, depending on various factors, setup another virtual machine, and bring (migrate) another server over to this machine. You can repeat this process as many times as you want, of-course depending on the physical specs / power / resources of your physical host.
I have personally gone through the pain and agony for one of my clients. For some reason, I had to migrate his servers every six months or so. Recently, we decided to use virtualization on one of our new servers. And the result so far is just great. The system is live. Did not miss a single beat! I am, in-fact, looking forward to migrating six more servers to this one physical host. Performance so far is great. We are glad that we have solved our most painful problem, without spending extra penny by using the free of cost XEN virtualization solution. It is very cost effective too. We recently migrated another server, as a virtual machine, to our new physical host and let go of it’s (migrated server’s) original physical host too. By doing that, our monthly billing has reduced significantly.
I am in love with my job again!
Update: I am putting down links to some training videos, we made on Xen Virtualization.