Tuesday, August 9, 2011

converting .iso to .img to be used by opennebula

I initially created a blank img file using the following command
$qemu-img create -f qcow2 ubuntu.img 3G
this will create ubuntu.img file with size 3G
then to install ubuntu from the .iso to the .img file which is created in the previous step, use the command:
$ qemu -m 512 -hda ubuntu.img -cdrom /home/eman/ubuntu-10.04.2-desktop-i386.iso -boot d
where /home/eman/ubuntu-10.04.2-desktop-i386.iso is the path of .iso file.
problems during installation:
if the message

pci_add_option_rom: failed to find romfile “pxe-rtl8139.bin”

appears in the terminal, then use the following command to solve it:
$ sudo apt-get install kvm-pxe



OpenNebula installation

Salam alikom
To install OpenNebula Express, you must have at least 2 computers (one for frontend & one for node server). The
node server must be VT-enabled which means Virtualization enabled processors, which is needed by kvm . The
process is described as follows:
1.
Installation of Ubuntu 10.04 on a NodeServer with : 2.10 GHz Intel Core 2 Duo T6570 (VT-
enabled) , 3Gb RAM and a FrontEnd with : 2.0 Ghz Intel T5800 , 2 Go RAM.
2.
Installation of KVM on NodeServer; [1][2]
3.
Installation of Virtual Machine Manager(virt-manager) on NodeServer and FrontEnd
4.
Installation of OpenNebula express on FrontEnd : Lucid+KVM+SSH option [3]
5.
Execution of node-install.sh on NodeServer
6.
The two physical machines are connected to a NetGear modem-router.
(in my case the 2 m/cs are connected by switch)
7. Test of VMs management using virt-manager on NodeServer (qemu:/system): successful.
8.
Test of VMs management using virt-manager on FrontEnd (qemu+ssh): successful.
9.
Configuring Bridge on the node, as follows [4][5]:
brctl addbr br0
ifconfig eth0 0.0.0.0 up
brctl addif br0 eth0
ifconfig br0 192.168.1.2 (old_eth0_ip_address)
You can get old_eth0_ip_address by writing the command “ifconfig” in a terminal & take the ip of eth0.
10. To make this changes persistent, open /etc/network/interfaces using the command “sudo
gedit /etc/network/interfaces” & write in it the following:
# loop back network interface
auto lo
iface lo inet loopback
#Setup interfaces manually, avoiding conflicts with, e.g., network manager
iface eth0 inet static
address 0.0.0.0
#Bridg setup
iface br0 inet static
bridge_ports eth0
address 192.168.1.2
broadcast 192.168.1.255
netmask 255.255.255.0
gateway 192.168.1.1
Note:broadcast ,netmask will be get from eth0 which appears in the o/p of “ifconfig”. Gateway is the
first ip (i.e. the first 3 parts of the ip of eth0 is the same & write 1 in the forth part, e.g. 192.168.1.1)
11. In the node, restart the network using “sudo /etc/init.d/networking/restart” then “ifconfig” to see if
br0 is configured, if yes, it will be displayed in the o/p of ifconfig.
12. in the node, write “sudo ifup br0” to start the bridge. [6]
13. Test of VMs management using virt-manager on FrontEnd (qemu+ssh), with bridge br0
configured: successful.
14. In the node, write “sudo nautilus” this will open the “/” & allow you to create new folder. Go to
/var/lib & create folder called “one” & R click on it ->properties& select permission. Change its owner to
oneadmin & give him create/delete permissions.
15. In the frontend, Downloading ttylinux as described by the official documentation. [7]
Write in the small_network.net file the following:
NAME = "Small network"
TYPE = FIXED
BRIDGE = br0
LEASES = [ IP="192.168.1.5"]
LEASES = [ IP="192.168.1.6"]
LEASES = [ IP="192.168.1.7"]
LEASES = [ IP="192.168.1.8"]
LEASES = [ IP="192.168.1.9"]
Note: leases are set of Ips which are not the ips of node server or frontend, but use any set of free ips
(i.e. non dedicated to a specific computer), this ips will be leased by Vms. In our case, we write 5
leased ips, this means we can run 5 vms on the small network.
16. In the front, go to the place in which small_network.net, “cd /home/mohammed/one-templated”
17. Create the network, “$ onevnet create small_network.net”. To check it use “onevnet list”
18. In order to use the node server, you have to add it to the system (i.e. frontend) as OpenNebula host. You
need the following information:
Hostname of the cluster node or IP
Information Driver to be used to monitor the host, e.g. im_kvm.
Storage Driver to clone, delete, move or copy images into the host, e.g. tm_nfs.
Virtualization Driver to boot, stop, resume or migrate VMs in the host, e.g. vmm_kvm.
Note:Before adding a host check that you can ssh to it from the front without being prompt for a password
In the front create new host by using, “ onehost create 192.168.1.2 im_kvm vmm_kvm tm_nfs”. Where
“192.168.1.2” is the ip of the node server. To check the new host use “onehost list”. Sample of the o/p:
ID NAME CLUSTER RVM TCPU FCPU ACPU TMEM FMEM STAT
0 192.168.1.2 default 0 200 192 200 1.8G 1.5G err
Note: the host state is “err”, but it must be “on”. To solve this problem:
• make sure that br0 is configured probably on the node by using “ifconfig” & start br0 by
       using “sudo ifup br0”. Wait some time because it takes a little time to be up.
• In the front, write “ssh 192.168.1.2” where 192.168.1.2 is the ip of the node
19. Modify the vm template, ttylinux.one. Write the following in it:
NAME = "ttylinux"
CPU = 0.5
MEMORY = 256
# --- disks ---
DISK = [
source = "/home/mohammed/one-templates/ttylinux.img",
target = "hda",
readonly="no"]
# --- 1 NIC ---
NIC = [ NETWORK="Small network"]
FEATURES=[ acpi="no" ]
# --- VNC server ---
GRAPHICS = [
type = "vnc",
listen = "0.0.0.0"]
20. The deployment means to create a virtual machine on the node according to the template
files you already configured.
So you need to have enough preveliges on the NODE for the user oneadmin in order to
create files on the directory : /var/lib/one/ & this done In step# 14
Deploying the vm, i.e. create the vm using, “onevm create ttylinux.one”. To check it write “onevm list”
sample of the o/p :
ID USER NAME STAT CPU MEM
1 oneadmin ttylinux pend 0
0K
HOSTNAME
00 00:50:33
TIME
Note: the state of the vm is pending (this is a problem), it must be changed to be running. Also, a copy
of .img will be transfered to the node in the folder /var/lib/one/
Now for the state of the VM, go to /var/lib/one/ on the FRONT, you will find a set of folders, each one is
related to a VM you tried to create and have a name which is the id of the VM, usually numbers. For
Example /var/lib/one/2/ will contain files related to the deployment of the VM with id=2. Look in these files,
especially the deployment file and you may find the cause of the problem.
If there exist any problem, you can delete the vm using “onevm delete 1” where 1 is the id of the vm &
then add it again.
21. In the front, to find a solution to any problem, place your eye on the file /var/log/one/oned.log.
Also try in the front, log as oneadmin by using “sudo -iu oneadmin”. Then try “one stop” , “one start” to
restart the one process.
22. After the state of the vm becomes running, try “onevm show 1” where 1 is the id of the vm. In the o/p you
will find the ip of the vm (Note: this ip is one of the leased ips & it differs from the ip of the node).
23. In the front, try “ssh root@192.168.1.5” where 192.168.1.5 is the ip of the vm.
You will be asked for password, the password is “password”
24. Managing the VM using virt-manager from the front.
In the front to open the virt-manager, Applications->System tools->Virtual machine manager.
To Add new connection, File->Add connection. In the add connection window select hypervisor:
QEMU/kVM & Connection: Remote tunnel over SSH.
It will display the available hosts, select the node server from the available hosts. Enter the Hostname:
eman@eman-laptop for example. The click on Connect button.
25. Also, you can monitor the vms in the node server, by doing the previous step but in this case the
connection will be local.
-------------------------------
[1] http://www.techotopia.com/index.php/Installing_and_Configuring_Ubuntu_10.x_KVM_Virtualization
[2] http://glm-webdesign.com/blog/?p=93
[3] http://opennebula.org/software:addons:express
[4] http://www.mail-archive.com/users@lists.opennebula.org/msg03181.html
[5] [http://tldp.org/HOWTO/BRIDGE-STP-HOWTO/]
[6] http://wiki.debian.org/BridgeNetworkConnections
[7] http://www.opennebula.org/documentation:rel2.2:vmg