Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

KVM Virtualization With Enomalism 2 On A Fedora 10 Server


Enomalism ECP (Elastic Computing Platform) provides a web-based control panel that lets you design, deploy, and manage virtual machines on one or more host systems (in the case of multiple systems, we speak of a cluster or cloud). This article shows how you can use Enomalism (also know as Enomaly) to manage KVM guests on one Fedora 10 server.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

I’m using a Fedora 10 server with the hostname server1.example.com and the IP address 192.168.0.100 here as my KVM host. The server is located in a private network with a DHCP server (on the router, IP 192.168.0.1). Enomalism usage might be different if you use it in a public network.

Before we start, run

system-config-firewall

and disable the firewall.

Also, make sure that SELinux is disabled. Open /etc/selinux/config

vi /etc/selinux/config

… and set SELINUX to disabled:

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#       targeted - Targeted processes are protected,
#       mls - Multi Level Security protection.
SELINUXTYPE=targeted

Run

setenforce 0

… for the change to take effect.

Please check if your CPU supports hardware virtualization – if this is the case, the command

egrep ‘(vmx|svm)’ –color=always /proc/cpuinfo

should display something, e.g. like this:

[root@server1 ~]# egrep ‘(vmx|svm)’ –color=always /proc/cpuinfo
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall
nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow rep_good nopl pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 3dnowprefetch
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall
nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow rep_good nopl pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 3dnowprefetch
[root@server1 ~]#

If nothing is displayed, then your processor doesn’t support hardware virtualization, and you must stop here.

 

2 Installing Enomalism 2

First do this:

wget http://downloads.sourceforge.net/enomalism/enomalism.public
rpm –import enomalism.public

wget http://downloads.sourceforge.net/enomalism/enomalism001.pubkey.asc
rpm –import enomalism001.pubkey.asc

To install KVM and Qemu, we run

yum install libvirt libvirt-python kvm qemu

ln -s /usr/bin/qemu-kvm /usr/bin/kvm

Then start the libvirt daemon:

/etc/init.d/libvirtd start

To check if KVM has successfully been installed, run

virsh -c qemu:///system list

It should display something like this:

[root@server1 ~]# virsh -c qemu:///system list
Id Name                 State
———————————-

[root@server1 ~]#

If it displays an error instead, then something went wrong.

Next we need to set up a network bridge on our server so that our virtual machines can be accessed from other hosts as if they were physical systems in the network.

To do this, we install the package bridge-utils

yum install bridge-utils

… and configure a bridge. Delete the system startup links for NetworkManager and create system startup links for network:

chkconfig –del NetworkManager
chkconfig –levels 235 network on

Then create the file /etc/sysconfig/network-scripts/ifcfg-virbr0 (please use the BOOTPROTO, DNS1 (plus any other DNS settings, if any), GATEWAY, IPADDR, NETMASK and SEARCH values from the /etc/sysconfig/network-scripts/ifcfg-eth0 file):

vi /etc/sysconfig/network-scripts/ifcfg-virbr0

DEVICE=virbr0
TYPE=Bridge
BOOTPROTO=static
DNS1=145.253.2.75
GATEWAY=192.168.0.1
IPADDR=192.168.0.100
NETMASK=255.255.255.0
ONBOOT=yes
SEARCH="example.com"

Modify /etc/sysconfig/network-scripts/ifcfg-eth0 as follows (comment out BOOTPROTO, DNS1 (and all other DNS servers, if any), GATEWAY, IPADDR, NETMASK, and SEARCH and add BRIDGE=virbr0):

vi /etc/sysconfig/network-scripts/ifcfg-eth0

# nVidia Corporation Unknown (0x0760)
DEVICE=eth0
#BOOTPROTO=static
#DNS1=145.253.2.75
#GATEWAY=192.168.0.1
HWADDR=00:1e:90:f3:f0:02
#IPADDR=192.168.0.100
#NETMASK=255.255.255.0
ONBOOT=yes
#SEARCH="example.com"
BRIDGE=virbr0

Then reboot the system:

reboot

After the reboot, run

ifconfig

It should now show the network bridge (virbr0):

[root@server1 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1E:90:F3:F0:02
inet6 addr: fe80::21e:90ff:fef3:f002/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:1611 errors:0 dropped:0 overruns:0 frame:0
TX packets:1986 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:133898 (130.7 KiB)  TX bytes:2092110 (1.9 MiB)
Interrupt:22 Base address:0xa000

lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:17 errors:0 dropped:0 overruns:0 frame:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1040 (1.0 KiB)  TX bytes:1040 (1.0 KiB)

virbr0    Link encap:Ethernet  HWaddr 00:1E:90:F3:F0:02
inet addr:192.168.0.100  Bcast:192.168.0.255  Mask:255.255.255.0
inet6 addr: fe80::21e:90ff:fef3:f002/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:1533 errors:0 dropped:0 overruns:0 frame:0
TX packets:1936 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:95507 (93.2 KiB)  TX bytes:2076556 (1.9 MiB)

[root@server1 ~]#

Also, the KVM kernel module should now be loaded:

lsmod | grep -i kvm

[root@server1 ~]# lsmod | grep -i kvm
kvm_amd                37644  2
kvm                   137976  1 kvm_amd
[root@server1 ~]#

(This output is from a system with an AMD-V processor. If your system uses an Intel VT CPU, it should display something like kvm_intel.)

Now we download the latest Enomalism .rpm package from http://sourceforge.net/project/showfiles.php?group_id=164855&package_id=186866&release_id=667675, e.g. as follows (please make sure you grab the PY2.5 package, not PY2.4!):

wget http://dfn.dl.sourceforge.net/sourceforge/enomalism/enomalism2-2.2.3.noarch.PY2.5.rpm

After the download has finished, we install Enomalism as follows:

yum install enomalism2-2.2.3.noarch.PY2.5.rpm

Then we create the system startup links for MySQL (so that MySQL starts automatically whenever the system boots) and start the MySQL server:

chkconfig –levels 235 mysqld on
/etc/init.d/mysqld start

Run

mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpassword

to set a password for the user root (otherwise anybody can access your MySQL database!).

If the last command throws an error at you…

[root@server1 named]# mysqladmin -h server1.example.com -u root password yourrootsqlpassword
mysqladmin: connect to server at ‘server1.example.com’ failed
error: ‘Access denied for user ‘root’@’localhost’ (using password: NO)’
[root@server1 named]#

… we can set the password as follows: connect to MySQL:

mysql -u root -p

Type in the password for the MySQL root user. Then, on the MySQL shell, do this:

mysql> USE mysql;

mysql> UPDATE user SET Password = password(‘yourrootsqlpassword’) WHERE Host = ‘server1.example.com’ AND User = ‘root’;

mysql> UPDATE user SET Password = password(‘yourrootsqlpassword’) WHERE Host = ‘127.0.0.1’ AND User = ‘root’;

Run

mysql> SELECT * FROM user;

to make sure that all rows where the user is root have a password.

If everything is looking ok, run

mysql> FLUSH PRIVILEGES;

… and leave the MySQL shell:

mysql> quit;

Now we must configure Enomalism. Run

cd /opt/enomalism2
scripts/init-db.sh yourrootsqlpassword enomalism enomalismpassword

Replace yourrootsqlpassword with your MySQL root password. enomalism is the name of the database user that Enomalism will use to connect to the MySQL database, and enomalismpassword is the database password for the user enomalism. Replace both with a username/passsword of your choice.

In the /opt/enomalism2 directory, there should be a file called server1.example.com.cfg. We copy that file to the /opt/enomalism2/config directory:

cp server1.example.com.cfg config/server1.example.com.cfg

Run

uuidgen

and write down the ID that the command generates (we need it in the next step where we modify /opt/enomalism2/config/server1.example.com.cfg):

[root@server1 enomalism2]# uuidgen
2d54480f-66c6-4c15-aafc-7242208456e0
[root@server1 enomalism2]#

Now we edit /opt/enomalism2/config/server1.example.com.cfg:

vi config/server1.example.com.cfg

Please adjust the following four values:

[...]
sqlobject.dburi="mysql://enomalism:enomalismpassword@localhost:3306/enomalism2"
[...]
enomalism2.baseurl="http://192.168.0.100:8080/rest/"
[...]
enomalism2.ip_addr="192.168.0.100"
[...]
enomalism2.self="2d54480f-66c6-4c15-aafc-7242208456e0"
[...]

Make sure you use the correct database user and password for the MySQL database and the correct IP address for the next two settings. In the enomalism2.self line, you should use the ID generated by uuidgen.

You will also find the settings enomalism2.drivestorage=’file’ and enomalism2.storagetarget=’file:///xen/’ in that file. Currently, Enomalism doesn’t support LVM, so you should not change these settings!

Next edit /etc/libvirt/qemu.conf

vi /etc/libvirt/qemu.conf

… and uncomment the line vnc_listen = “0.0.0.0”:

[...]
vnc_listen = "0.0.0.0"
[...]

(Otherwise you won’t be able to connect to the KVM guests via VNC from a remote machine!)

Restart libvirtd afterwards:

/etc/init.d/libvirtd restart

Now we create the system startup links for Enomalism and start it:

chkconfig –levels 235 enomalism2.sh on
/etc/init.d/enomalism2.sh start

Now open a browser and go to http://192.168.0.100:8080. This should finish the Enomalism installation:

1

Click on the Click here to use Enomalism2! link:

2

3 Using Enomalism

You should now be at the Enomalism login prompt. The default username is admin, and the password is password (you should change this after the first login):

3

This is how the Enomalism control panel looks. The Dashboard lists all transactions and tells you if they were successful or not:

4

To run KVM guests, we can either create our own virtual machines or download preconfigured virtual machines from the public Enomalism repository. I will describe both methods in this tutorial. Right now I’m going to show how to use a preconfigured virtual machine from the public Enomalism repository.

There are one or two things to note about the preconfigured appliances. First, they have a disk space of only 1 GB, so they are probably not for production use, and second, it is possible that they won’t be able to bring up their eth0 interface, i.e., they will have no networking (this happened to me when I downloaded the Ubuntu 8.04 KVM appliance; however, when I downloaded the CentOS 5.2 KVM appliance, networking was working fine).

 

3.1 Using Preconfigure Appliances

Go to Repository > REMOTE APPLIANCES. Find the virtual machine that you’d like to use and click on the plus sign in front of it (I’m going to download the CentOS 5.2 KVM guest – make sure you select a KVM guest and not a Xen guest!):

5

Confirm your selection:

6

The appliance is now being downloaded in the background. This can take a few minutes. You can see the download status on the Dashboard (click on the blue refresh icon to update the status):

7

This is how it looks after the download has finished:

8

You should now find the appliance under Repository > LOCAL APPLIANCES:

9

Before we start the appliance, we have to provision it (this means, the appliance is just a template from which we create KVM guests). Go to Virtual Infrastructure > ELASTIC VALET and select the CentOS 5.2 KVM appliance. In the other drop-down menus, select default, then scroll down:

10

Right now, we want to create just one guest, so we select 1 in the Number of machines to provision drop-down menu. Click on Provision afterwards:

11

The template is now being unzipped. Again, this can take some minutes, and you can check the status on the Dashboard:

12

13

Afterwards, go to Virtual Infrastructure > INFRASTRUCTURE. Click on the refresh button in the left frame. You should find that server1.example.com is a member of the cluster named default, and that there’s one virtual machine on server1.example.com (named 814f4b… in this example). Click on that virtual machine in the left frame, and the virtual machine summary should load in the main frame:

14

It’s a good idea to rename the virtual machine to something less cryptic, so click on the pencil left of the virtual machine name…

14a

… and give the virtual machine a new name:

15

You can now start that virtual machine by clicking on the start this virtual machine link:

16

Confirm that you want to start the virtual machine:

17

In the virtual machine summary, there should now be some new links (e.g. suspend, poweroff, reboot). The interesting link is the one that reads VNC to this VM (via the parent). This will open Enomalism’s built-in VNC client (written in JAVA). (Of course, you can use any other VNC client to connect to the virtual machine, e.g. TightVNC. In the lower right corner of the summary, you will find details how to do this (IP and port).)

18

This is how the JAVA VNC client looks (the default login for the public Enomalism appliances is root:password):

19

3.2 Creating Our Own Virtual Machines

Instead of using the preconfigured appliances, we can also create our own virtual machines. Go to Repository > VM CREATOR. Click on the Browse… button…

20

… select an operating system ISO image from your local hard drive (I’m going to install a Debian Lenny guest, so I select the debian-500-amd64-netinst.iso from my local hard drive):

21

Next select KVM Machine in the VM Type drop-down menu and specify the size of the guest image (e.g. 4048 MB) as well as the memory that you want to allocate to the guest:

22

If your host system has more than one CPU core, you can specify the number of virtual CPUs for the guest. Click on Create afterwards:

23

The ISO image is now being uploaded to the Fedora 10 KVM host:

24

25

Afterwards, you can find the ISO image under Repository > LOCAL APPLIANCES. It has a cryptic name, so you should rename it to something more intuitive:

26

27

28

To create a virtual machine from the ISO image, go to Virtual Infrastructure > ELASTIC VALET, select the ISO image and click on Provision:

29

The ISO image is now being unpacked – this can take some minutes, and you can check the status on the Dashboard:

30

Afterwards, go to Virtual Infrastructure > INFRASTRUCTURE and click on the refresh button in the left frame. There should now be a new guest:

31

Rename that guest to something less cryptic:

32

In the virtual machine summary, click on Select boot device

41

… and choose DVD/CD-ROM:

34

Then start the virtual machine:

43

Click on the VNC to this VM (via the parent) link to start Enomalism’s built-in JAVA VNC client (or use your own VNC client)…

35

… and install the guest operating system, as you would usually do on a physical system:

36

Please note that at the end of the installation, the Debian guest needs a reboot:

37

The guest will then try to boot from CD-ROM again which results in a failure:

38

To fix this problem, power down the guest (using the poweroff this virtual machine link):

39

40

Then click on Select boot device again…

41

… and select Hard drive:

42

Now start the guest again using the start this virtual machine link:

43

You can now connect to the guest via VNC again, and it should now boot without any problem:

44

If you are experiencing any problems with Enomalism, you can take a look at the Enomalism logs in the /opt/enomalism2/logs directory.

 

  • Enomalism/Enomaly: http://www.enomalism.com/
  • Fedora: http://fedoraproject.org/

 

 

Comments

comments