OpenNebula Installation on CentOS 5.5 Prerequisites You need to enable EPEL repo for installing some packages, e.g. rubygems. See Fedora project wiki on how to enable this. http://www.thegeekstuff.com/2012/06/enable-epel-repository/ Step 1: Install required packages using yum sudo yum -y install glibc glibc-common glibc-devel cpp glibc-headers kernelheaders libgomp libstdc++-devel nscd gcc-c++ rpm-build yum-utils pkgconfig sudo yum -y install libxml2 libxml2-devel expat expat-devel libxslt libxsltdevel openssl openssl-devel curl curl-devel sudo yum -y install ruby ruby-libs ruby-devel ruby-irb ruby-docs ruby-rdoc ruby-ri rubygems cmake Step 2: Install sqlite db from source wget http://www.sqlite.org/sqlite-amalgamation-3.6.17.tar.gz -P /tmp sudo tar xvzf /tmp/sqlite-amalgamation-3.6.17.tar.gz -C /usr/local/src pushd /usr/local/src/sqlite-3.6.17/ sudo ./configure sudo make sudo make install popd Now we have to install the ruby bindings for sqlite. Unfortunately SL has poor support for ruby. First install ruby-rdoc yum install ruby-rdoc Download and install rubygems, ruby's package management tool from EPEL (Fedora packages ported to RHEL) # wget http://download.fedora.redhat.com/pub/epel/5/i386/rubygems-1.3.11.el5.noarch.rpm # rpm -i rubygems-1.3.1-1.el5.noarch.rpm Finally download and install the bindings themselves # wget http://download.fedora.redhat.com/pub/epel/5/i386/rubygem-sqlite3ruby-1.2.4-1.el5.i386.rpm # rpm -i rubygem-sqlite3-ruby-1.2.4-1.el5.i386.rpm Step 3: Install xmlrpc mkdir -p /usr/local/src cd /usr/local/src wget http://downloads.sourceforge.net/project/xmlrpc-c/Xmlrpcc%20Super%20Stable/1.16.35/xmlrpc-c-1.16.35.tgz tar xvzf xmlrpc-c-1.16.35.tgz cd xmlrpc-c-1.16.35 ./configure make make install wget -P /tmp http://centos.karan.org/el5/extras/testing/SRPMS/xmlrpc-c1.06.18-1.el5.kb.src.rpm rpmbuild --rebuild /tmp/xmlrpc-c-1.06.18-1.el5.kb.src.rpm sudo yum -y --nogpgcheck localinstall /usr/src/redhat/RPMS/x86_64/xmlrpc-c*.rpm yum install xmlrpc-c-devel. yum install curl-devel gsm-devel git yasm subversion gcc gcc-c++ automake autobuild libtool yum install libxml2-devel Install the rpms # rpm -i xmlrpc-c-1.06.18-1.el5.kb.i386.rpm Step 4: Install scons wget -P /tmp http://prdownloads.sourceforge.net/scons/scons-2.0.11.noarch.rpm sudo yum -y --nogpgcheck localinstall /tmp/scons-2.0.1-1.noarch.rpm Step 5: Install RVM http://www.betaquest.com/2011/07/how-to-install-rvm-ruby-version-manager-andruby-1-8-7-and-1-9-2-ree-on-centos-5-6-64bit/ Step 6: Install gems sudo gem install nokogiri rake xmlparser Step 7: Add oneadmin user sudo /usr/sbin/useradd -u50000 oneadmin Step 8: User Accounts Add an one user to run OpenNebula and note the uid and the gid # useradd one # id one Passwordless ssh must be set up for one. As one generate a key pair. Use the default key location and press enter when asked for a pass phrase. # su one $ ssh-keygen -t rsa $cp ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys Step 9: Create OpenNebula install directory sudo mkdir -p /srv/cloud/one sudo chown -R oneadmin:oneadmin /srv/cloud sudo chown -R oneadmin:oneadmin /tmp/opennebula-2..0.1 Step 10: Download and install OpenNebula wget -P /tmp http://dev.opennebula.org/attachments/download/264/opennebula2.0.1.tar.gz pushd /tmp tar xvzf opennebula-2.0.1.tar.gz pushd opennebula-2.0.1 scons ./install.sh -u oneadmin -g oneadmin -d /srv/cloud/one popd popd Step 11: Configure shell environment Add following to ~/.bashrc file cat >> # User export export export export EOF source $HOME/.bashrc <<\EOF specific aliases and functions ONE_LOCATION=/srv/cloud/one ONE_AUTH=$HOME/.one_auth ONE_XMLRPC=http://localhost:2633/RPC2 PATH=/srv/cloud/one/bin:$PATH ~/.bashrc Step 12: Add username and password to ONE_AUTH file We need to create an account using $ONE_AUTH file – specifying username and password separated by a colon ‘:’. The first account created will run as an administrator account. echo "oneadmin:secretpassword" >> $ONE_AUTH Step 13: Start OpenNebula as ‘oneadmin’ system user one start Step 14: Start the OpenNebula daemon $ $ONE_LOCATION/bin/one start oned and scheduler started Step 15: Start Up Script Add the following to /home/one/.bash_profile ONE_LOCATION=/usr/local/one/ ONE_XMLRPC=http://localhost:2633/RPC2 PATH=$ONE_LOCATION/bin:$PATH:$HOME/bin export PATH export ONE_LOCATION export ONE_XMLRPC Create /etc/init.d/one with the following #!/bin/sh -e # chkconfig: 2345 20 80 # description: Starts the OpenNebula service case "$1" in start) su - one /usr/local/one/bin/one start ;; stop) su - one /usr/local/one/bin/one stop ;; restart) su - one /usr/local/one/bin/one stop su - one /usr/local/one/bin/one start ;; *) echo "Usage: one {start|stop|restart}" >&2 exit 1 ;; esac exit 0 Mark /etc/init.d/one as an executable chmod +x /etec/init.d/one Add to services started at boot chkconfig --add one Step 16: Firewall Settings for XMLRPC Acess Add the following lines to /etc/sysconf/iptables to allow remote RPC control -A RH-Firewall-1-INPUT -p udp -m udp --dport 2633 -j ACCEPT -A RH-Firewall-1-INPUT -p tcp -m tcp --dport 2633 -j ACCEPT Worker Nodes Software Requirements ruby >= 1.8.5 Ruby is available via yum. # yum install ruby Step 17: User Accounts Add an one user to run OpenNebula with the same uid and gid as the head node # groupadd -g 500 one # useradd -g 500 -u 500 one Set up passwordless ssh by copying over the head node's public key #su one $ cd $ scp root@ugdev05:/home/one/.ssh/id_rsa.pub . $ cat id_rsa.pub >> .ssh/authorized_keys $ rm id_rsa.pub $ chmod 600 .ssh/authorized_keys The one account need sudo access to some of the xen commands. Add the following to /etc/sudoers ## OpenNebula access to the Xen commands one ALL=(ALL) NOPASSWD: /usr/sbin/xm * one ALL=(ALL) NOPASSWD: /usr/sbin/xentop * Comment out the following line in /etc/sudoers Defaults requiretty Step 18: Set Up On the head node add the worker node to OpenNebula $ onehost create ugdev06 im_xen vmm_xen tm_ssh Create an $ONE_LOCATION on the worker node and change it ownership to one # mkdir /usr/local/one # chown one:one /usr/local/one Step 19: Xen Setup This is assuming Xen is not set up on the worker node Install the Xen kernel yum install kernel-xen Reboot # reboot Install the xen package to provide the Xen daemon yum install xen Comment out the non xen kernel in /boot/grup/menu.lst The scheduler counts the memory assigned to dom0 as used when considering whether to run a VM on a machine. You need to lower the amount of memory used by the dom0 with xm mem-set 0 256. Do not set it lower than 256 MB! Besides Step 20: Networking OpenNebula needs to have some sort of virtual network set up. This creates machines with IP addresses in the range 10.0.1.0 - 10.0.1.254 with MAC adresses of the form 00:03:0a:00:01:01. However the ip address supplied is not the one which the VM boots with as our VMs use DHCP to acquire a ip address. Save the following in test.net NAME = "test" TYPE = RANGED BRIDGE = xenbr0 NETWORK_SIZE = C NETWORK_ADDRESS = 10.0.1.0 Create this network with the following command onevnet create test.net