Tuesday, August 9, 2011

Things I learnt with ESXi

I have been using a Vmware server at work to run virtual machines. The server (2.1) is running on one of our Kubuntu boxes. I never liked the Web Access for it, and the whole thing seems buggy and some times just doesn't work properly. Anyway, I decided to give a go to ESXi (4.1), which is another free product from Vmware. Basically its a linux-based distribution which is optimized to run virtual machines. You install it as you would install you regular Linux distro. I did it from a CD that you can download from Vmware we pages. You will need to create an account first.

Direct control over the ESXi box once installed is very limited. You can change some things like the password and network access, but full control is intended to be achieved by using the Vmware vSphere Client. Unfortunately, the client only works in Windows, and furthermore there is no Web Access for the free ESXi. Some things to think about before installing it I suppose.

The first thing you might want to do is to create a virtual machine or import one. In my case, I have installed two so far: one imported from the vmware server that I'm already running, and the other one from Bitnami, which gives free virtual appliances (virtual machines) with specific pieces of software already installed. In both cases, the easiest way to deploy your VM to the new ESXi is using the vmware converter, which luckily runs also on Linux. It will allow you not only to convert VM formats, but also to import and deploy VM from a one server to the other. It will even handle the case when your VM is running. The converter software can independently run in a different machine than your VM servers.

Once you have deployed your VMs to ESXi, you surely will want to back them up. Free vmware products do not have fancy back up support, but for some of them, the guys from the vmware community have been nice enough to provide command line scripts. On the Vmware server, I had my backup set up so I would manually stop the VM, rsync them with my NAS, and start them again when the syncing is finished. For that I used the vmrun utility from the vmware server 2.1 and set up the script as a cron job. Not very intuitive, but after some trying it worked all right. Something like this:
  • sudo vmrun -T server -h https://127.0.0.1:8333/sdk -u user -p password suspend "[standard] machineName/machineName.vmx"
  • rsync -a --password-file=/etc/rsyncd.scrt /var/lib/vmware user@IP_of_NAS::volume_name
  • sudo vmrun -T server -h https://127.0.0.1:8333/sdk -u user -p password start "[standard] machineName/machineName.vmx"
The ESXi, unfortunately, is not running a standard Linux distribution, and also does not support the same commands as the vmware server, so I can not use the same method. After some digging, there is a script called ghettoVCB which basically does the same thing and more. The trouble is that you need access to the console of the ESXi server for that. To enable that, you need to enable what they call Tech Support Mode (TSM) like here. You can now follow the instructions in the ghettoVCB web site to configure and back up your VM. A few highlights:
  • To backup through NFS, you need to add an NFS data storage to your ESXi server using the vSphere client. Once you do that, make sure that you point your configuration files to there.
  • Once you manually test that your configuration works, don't forget to set up a cron job as explained in the same web page.
  • You will need to install vmware tools on your VMs so the script can stop your VM before starting the backup. If your host is Ubuntu, make sure you read this for doing that.