« Previous 1 2 3 Next »
Setting up an OpenNebula Cloud
New Nebula
OpenNebula Configuration File
You can specify the configuration for your OpenNebula setup in the oned.conf
file. This file is critical to your OpenNebula deployment. The folks at OpenNebula provide all possible configurations for existing drivers that ship with the standard OpenNebula distribution. You can comment and uncomment as required for your environment. If, for example, you are interested in using Xen, just uncomment the relevant section in the oned.conf
file (Listing 2).
Listing 2
Xen Hypervisor Settings
01 #IM_MAD = [ 02 # name = "im_xen", 03 # executable = "one_im_ssh", 04 # arguments = "im_xen/im_xen.conf", 05 # default = "im_xen/im_xen.conf" ] 06 07 #VM_MAD = [ 08 # name = "vmm_xen", 09 # executable = "one_vmm_xen", 10 # default = "vmm_xen/vmm_xen.conf", 11 # type = "xen" ]
The IM_MAD section relates to the information monitoring driver for the status monitoring. The VM_MAD section deals with the hypervisor driver.
Similarly, if you were using a global shared NFS storage between all your nodes, you would uncomment the relevant configuration variables. Listing 3 shows the portion you need to uncomment.
Listing 3
NFS Transfer Driver Section
01 #--------------------------------------------------------------- 02 # NFS Transfer Manager Driver sample configuration 03 #--------------------------------------------------------------- 04 # TM_MAD = [ 05 # name = "tm_nfs", 06 # executable = "one_tm", 07 # arguments = "tm_nfs/tm_nfs.conf", 08 # default = "tm_nfs/tm_nfs.conf" ]
After you have added the worker nodes, your private three-node cloud is ready. However, before you can start launching virtual machines, you need to define a virtual network and then create and launch a virtual machine.
Virtual Networks
You can define custom private networks in OpenNebula, and virtual machines can be associated with several of these virtual networks. Different networks can link a specific set of virtual machines together. You could also permit some machines access to the Internet by connecting them to a specific virtual network.
To define your own virtual network, you need to write a template file. Fortunately, the syntax of a virtual network template file is pretty simple. In OpenNebula, you can define a " fixed" virtual network or a " ranged" network. A fixed network specifies certain IP addresses against specific virtual machines identified by their MAC addresses. On the other hand, a ranged network is more like a DHCP configuration, where a base network address is specified and all addresses follow that same pattern. A sample fixed network configuration template is shown in Listing 4, and Listing 5 shows a sample ranged network configuration.
Listing 4
Fixed Network Template
01 NAME = "Private Cloud" 02 TYPE = FIXED 03 BRIDGE = vbr0 04 LEASES = [IP=192.168.0.1, MAC=50:20:20:20:20:20]
Listing 5
Ranged Network Template
01 NAME = "wanNetwork" 02 TYPE = RANGED 03 BRIDGE = vbr0 04 NETWORK_SIZE = C 05 NETWORK_ADDRESS = 192.168.0.0
In creating a virtual network, I will use the fixed network template file specified in Listing 4, save the contents of Listing 4 to a file called network.template, and enter the commands shown in Listing 6.
Listing 6
Creating a Virtual Network
01 nebula-user@nebula-cloud-server:~$ onevnet create network.template 02 nebula-user@nebula-cloud-server:~$ onevnet list 03 NID NAME TYPE BRIDGE 04 0 Private Cloud Fixed eth0
Creating a KVM Virtual Machine
The VM used to test the three-node cloud infrastructure is available for download [5]; however, you can create your own. To create your own KVM virtual machine, you would start by creating the disk file:
dd if=/dev/zero of= ubuntu_server.img bs=1M count=4096
Use the kvm
command to start the installation from the Ubuntu ISO file:
kvm -m 512 -cdrom /isos/ubuntu.iso -boot d ubuntu_server.img
After you run this command, a QEMU window should pop up and launch the Ubuntu CD boot screen. Select Install Ubuntu and follow the instructions. After the virtual machine is created, the next step is to submit the VM to OpenNebula.
Before you can submit your VM to OpenNebula, you need to carry out a few tasks. To begin, you must copy the ubuntu_server.img
created in the last section to the virtual machine repository location. This location is specified in the oned.conf
file. The variable is called VM_DIR, and it is commented by default. You'll need to store all images in /opt/vmImages/
on the front end and update the configuration file accordingly, keeping in mind that you must restart the daemon after every configuration change.
After you've saved the image to the appropriate directory, you can write a VM description for OpenNebula. VM descriptions are mostly hypervisor specific; however, some general fields are required (Listing 7).
Listing 7
VM Description File
01 NAME = kvmVM #specify the name 02 CPU = 1 # How many CPUs required? 03 MEMORY = 512 # RAM in MB 04 OS = [ 05 KERNAL = "/boot/vmlinuz-2.6.32-24-generic", # Kernel to use 06 INITRD = "/boot/initrd.img-2.6.32-24-generic", # initrd to use 07 ROOT = "sda1", #Root partition 08 BOOT = hd #boot form harddisk 09 ] 10 DISK = [ 11 SOURCE = "/opt/vmImages/ubuntu_server.img", #location of source image 12 TARGET = "sda1", # mount as partition ] 13 DISK = [ 14 TYPE = "swap", #swap drive 15 SIZE = 1024, # size of swap drive 16 TARGET = "sdb" #mount to partition 17 ] 18 NIC = [ NETWORK = "Private Cloud" ] #connect to specified virtual network, several NIC can be specified, is you want to connect to several VNs
Save the VM description file to kvmVM.template
, but don't forget to remove the comments, which have been inserted to explain the contents of the template and will produce parsing errors if left in the file.
To submit this virtual machine, use the openvm
command. Just as the onehost
command deals with host management, onevm
deals with VM management
onevm [options] subcommand [parameters]
and uses the same set of command options (Figure 2). The subcommand arguments associated with openvm
can be any of the following: create, deploy, shutdown, livemigrate, migrate, hold, release, stop, cancel, suspend, resume, delete, list, show, top, and history. See the OpenNebula documentation for more on these commands.
The create
command allows you to submit a new VM to the OpenNebula cluster. This command requires the user to pass the VM template file. Once you submit a VM, you can watch its status with show
. You will also know the ID assigned to the VM. To apply commands like shutdown, stop, cancel, suspend, and resume to a VM, just specify the VM ID.
OpenNebula allows a user to migrate a VM from one host in the cluster to another. With migrate, the VM is first stopped before it is redeployed on another machine, whereas livemigrate
migrates the VM without stopping and redeploying it. To specify a migration, you need to specify both the host ID and the VM ID.
To list all VMs currently running, use vm list
. To launch the virtual machine, type the commands in Listing 8, which shows the VM in the scheduling queue. The private cloud setup is complete.
Listing 8
Launching a Virtual Machine
01 nebula-user@nebula-cloud-server:~$ onevm create kvmVM.template 02 nebula-user@nebula-cloud-server:~$ onevm list 03 ID NAME STAT CPU MEM HOSTNAME TIME 04 0 kvmVM pend 0 0 00 00:00:07
« Previous 1 2 3 Next »