KVM & OpenVZ Virtualization And Cloud Computing With Proxmox VE

Version 1.0 Author: Falko Timme <ft [at] falkotimme [dot] com> Last edited 01/29/2009 Proxmox VE (virtual environment) is a distribution based on Debian Etch (x86_64); it provides an OpenSource virtualization platform for running virtual machines (OpenVZ and KVM) and comes with a powerful, webbased control panel (it includes a web-based graphical console that you can use to connect to the virtual machines). With Proxmox VE, you can even create a cluster of virtualization hosts and create/control virtual machines on remote hosts from the control panel. Proxmox VE also supports live migration of virtual machines from one host to the other. This guide shows how you can use Proxmox VE to control KVM and OpenVZ virtual machines and how to create a small computing cloud with it. I do not issue any guarantee that this will work for you!

1 Preliminary Note
Proxmox VE is an x86_64 distribution, so you cannot install it on an i386 system. Also, if you want to use KVM, your CPU must support hardware virtualization (Intel VT or AMD-V) - this is not needed if you ust want to use OpenVZ. In this tutorial I will create a small cluster of two machines, the Proxmox master (server1.example.com with the IP 192.168.0.100) and a slave (server2.example.com, IP: 192.168.0.101) so that I can demonstrate the live migration feature and also the creation and management of virtual machines on remote hosts through Proxmox VE. Of course, it is perfectly fine to run Proxmox VE on just one host.

2 Installing Proxmox VE On server1.example.com (Master)
Download the latest Proxmox VE ISO image from http://pve.proxmox.com/wiki/Downloads, burn it onto a CD, and boot your system from it. Press ENTER at the boot prompt:

Accept the Proxmox license agreement (GPL):

Select the hard drive on which you want to install Proxmox. Please note that all existing partitions and data will be lost!

Select your country, time zone, and keyboard layout:

Type in a password (this is the root password that allows you to log in on the shell and also to the Proxmox web interface) and your email address:

Now we come to the network configuration. Type in the hostname (server1.example.com in this example), IP address (e.g. 192.168.0.100), netmask (e.g. 255.255.255.0), gateway (e.g. 192.168.0.1), and a nameserver (e.g. 145.253.2.75):

Afterwards, Proxmox is installed. The installer will automatically partition your hard drive using LVM - that's why there is no partition dialogue in the installer. Proxmox uses LVM because that allows to create snapshot backups of virtual machines.

Reboot the system afterwards:

After server1 has rebooted, you can open a browser and go to http://192.168.0.100/ - this will redirect you to https://192.168.0.100/. If you're using Firefox 3 and use HTTPS, Firefox will complain about the self-signed certificate, therefore you must tell Firefox to accept the certificate - to do this, click on the Or you can add an exception... link:

Click on Add Exception...:

The Add Security Exception window opens. In that window, click on the Get Certificate button first and then on the Confirm Security Exception button:

Afterwards, you will see the Proxmox login form. Type in root and the password you've created during the installation:

This is how the Proxmox control panel looks:

3 Creating A Cluster By Adding A Slave (server2.example.com) (Optional)
(You can skip this chapter if you want to run Proxmox on just one host.) You can create a cluster or computing cloud by adding one or multiple slave servers to the Proxmox master (server1.example.com). Such a cloud allows you to create and manage virtual machines on remote hosts from the Proxmox control panel, and you can even do live migration of virtual machines from one host to another. I will now show you how to add a second host, server2.example.com, and create a cluster. Install Proxmox on server2.example.com, just as you did on server1. When you come to the networking section, fill in server2.example.com and make sure you use a different IP (e.g. 192.168.0.101):

After the installation has finished, and the system has successfully rebooted, log in on the command line (e.g. using PuTTY) on both server1 and server2. On server1, run the following command:
server1: pveca -c server1:~# pveca -c Generating public/private rsa key pair. 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: ce:bf:a2:cd:69:23:e4:78:fc:05:db:fc:55:ef:52:1d root@server1 cluster master successfully created server1:~#

Then check the state of the cluster:
server1: pveca -l server1:~# pveca -l CID----IPADDRESS----ROLE-STATE--------UPTIME---LOAD----MEM---ROOT---DATA 1 : 192.168.0.100 M A 00:14 0.00 5% 1% 0% server1:~#

On server2, do the following:
server2: pveca -a -h 192.168.0.100 server2:~# pveca -a -h 192.168.0.100 Generating public/private rsa key pair. 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: ea:ad:21:fc:5d:9b:af:ab:fb:0d:72:72:c7:94:23:ca root@server2 The authenticity of host '192.168.0.100 (192.168.0.100)' can't be established. RSA key fingerprint is 7c:17:8c:35:9c:be:60:6b:56:97:2a:0b:72:60:57:09. Are you sure you want to continue connecting (yes/no)? <-- yes Warning: Permanently added '192.168.0.100' (RSA) to the list of known hosts. root@192.168.0.100's password: <-- root password of server1.example.com cluster node successfully created server2:~#

That's it, you've just created a cluster. You can check that by running: server2:
pveca -l

This should display both servers in the output:
server2:~# pveca -l CID----IPADDRESS----ROLE-STATE--------UPTIME---LOAD----MEM---ROOT---DATA 1 : 192.168.0.100 M S 00:15 0.00 5% 1% 0% 2 : 192.168.0.101 N S 00:04 0.08 15% 1% 0% server2:~#

Now go back to the Proxmox control panel on http://192.168.0.100/ (you don't need the control panel on server2.example.com!) and go to Cluster, and it should list both servers:

4 Adding Appliance Templates
Before we can create OpenVZ containers, we must add at least one OS template to our system (for KVM guests, you can add ISO files, although this is not necessary - KVM guests can as well be installed directly from an OS CD or DVD). Go to Appliance Templates. You will see two tabs, Local and Download:

On the Download tab, you will see a list of templates provided by the Proxmox project that you can download directly to the system...

... - at least theoretically - the problem is that the links are too old and not working anymore:

That's why we have to use the Local tab. You can go to http://download.proxmox.com/appliances/ and then to the admin, mail, system, or www folders...

... and download the desired templates to your local hard drive:

On the Local tab, you can then upload the templates to the Proxmox master:

You can as well upload ISO images that can be used for the creation of KVM guests. To delete a template or ISO file, click on the red arrow in front of it and select Delete:

5 Creating OpenVZ Containers
To create an OpenVZ container, go to Virtual Machines > Create...

... and fill in the form. Select Container (OpenVZ) and then the template that you want to use. Specify a hostname (e.g. vm1.example.com), the amount of memory and swap, a root password, select Virtual Network (venet) and specify an IP address for the container (e.g. 192.168.0.102), fill in a VMID, select a cluster node (if you haven't created a cluster (see chapter 3), you can select only the master, not any remote systems), specify if the container should automatically be started when the host boots, and fill in one or two DNS servers (e.g. 145.253.2.75 and 213.191.92.86). Then click on create:

The container is then created...

... and it should be listed on the List tab afterwards. The container is stoppped; to start it, click on the container:

This will open a page where you can control that container. To start it, click on the Start button:

You should then see the link Open VNC console - if you click on it...

... a browser-based console opens from where you can control the virtual machine (this is especially useful for desktop machines; if the virtual machine is a server, you can as well connect to it using SSH (e.g. with PuTTY)).

6 Creating Virtual Machines On Remote Systems In The Cluster

If you've created a cluster (see chapter 3), you can also create virtual machines on remote systems that belong to the cluster - just select a remote node under Cluster Node when you create a virtual machine (the screenshot shows this for OpenVZ, however, this works for KVM guests as well as long as the node supports hardware virtualization):

The List tab should then show that the virtual machine is running on a different node:

7 Creating KVM Guests

If the CPU supports hardware virtualization (Intel VT or AMD-V), you have the possibility to create KVM guests in addition to OpenVZ containers. Just select Fully virtualized (KVM) in the Type drop-down menu, and then either select the cdrom device or one of the ISO images that you've uploaded (if any) from the Installation Media drop-down menu. There are no network settings to be set as this will have to be done directly in the KVM guest. Make sure you select the correct Guest Type (Linux 2.6, Windows XP, etc.):

The KVM guest should be listed on the List tab afterwards; as always with new guests, it is stopped. Click on it...

... to get to its management page; click on the Start button there (if you've selected to install the guest from CDROM, please insert the OS CD or DVD into the target system's CD drive before you click on Start):

Then click on the Open VNC console link...

... to connect ot the graphical console of the guest; you should now be able to complete the OS installation just as if it was a physical system:

7.1 Installing Windows XP
KVM allows you also to install Windows guests. Select cdrom device from the Installation Media drop-down menu and Windows XP from the Guest Type drop-down menu:

Insert the Windows XP CD into the target system's CD drive, start the guest, and connect to its graphical console. You can now follow the Windows installation wizard to install a Windows XP guest:

8 Live Migration
If you've set up a Proxmox cluster (see chapter 3), you can migrate running guests from one node to the other. Just go to Virtual Machines > Migrate, select the guest, the source and target node, check Online migration and click on migrate:

The guest is migrated while it is running:

Afterwards, the List page shows that it's now running on another node:

9 Backups
With Proxmox VE, you can create cron jobs to back up your virtual machines. Before we can create backups, we need to create a backup directory, e.g. /backup. Go to the command line of server1 and run: server1:
mkdir /backup

In the Proxmox control panel, go to Backup and click on the red arrow in front of Backup Jobs; then select Create new job:

Select the cluster node and then the virtual machines from that node that you'd like to back up. Specify /backup as the destination directory, and select the days and the time when you want the backups to be created. Under Mode, you can select snapshot (LVM snapshots, zero downtime), suspend (virtual machines will be suspended for a short period of time when the backup is created) and stop (virtual machine will be completely stopped). I recommend to use snapshot here, especially if you cannot afford any downtime:

Afterwards, you can see the backup cron job on the Backup page:

10 Links
  

Proxmox VE: http://pve.proxmox.com/wiki/Main_Page OpenVZ: http://wiki.openvz.org/ KVM: http://kvm.qumranet.com/kvmwiki

Sign up to vote on this title
UsefulNot useful