OpenNebula setup, Part 1

This will be the first of many blog posts to come outlining the process of setting up OpenNebula on a CentOS box and managing a small cluster of VMs.

First, a simple and good definition for OpenNebula:

…the open-source industry standard for data center virtualization, offering the most feature-rich, flexible solution for the comprehensive management of virtualized data centers to enable on-premise IaaS clouds

This diagram clearly shows the role of OpenNebula as far a Cloud infrastructure goes:

Even though the OpenNebula website is very complete and provides lots of good documentation and reference guides, a lot of that information is still out of context for me.
I haven’t dealt with cloud infrastructure before, so it is hard to put all these features and solutions that OpenNebula provides in context.
I guess once we have a small cloud set up it will start becoming clear the problems OpenNebula was designed to solved.

With all that being said lets get started!

I’ll be following the official tutorial posted on

There are a few ways to install OpenNebula, they have prebuilt packages for a few Linux Distros and also provide the source code for whoever wants to build from source.
Later I plan to build from source, for now I’ll be installing from one of their pre-built packages

Download page

I selected the option:
OpenNebula 3.8.1 Download Source, RHEL/CentOS, Debian, openSUSE and Ubuntu Binary Packages Now!

Which took me to the another download page where I selected the distro I was interested in, my case CentOS.

The downloaded tar file came with three packages and the src code:


At first I tried to install the rpm packages by typing:

[diogogmt@localhost opennebula-3.8.1]$ sudo rpm -Uvh opennebula-3.8.1-1.x86_64.rpm
error: Failed dependencies: is needed by opennebula-3.8.1-1.x86_64 is needed by opennebula-3.8.1-1.x86_64 is needed by opennebula-3.8.1-1.x86_64 is needed by opennebula-3.8.1-1.x86_64
    rubygem-json is needed by opennebula-3.8.1-1.x86_64
    rubygem-nokogiri is needed by opennebula-3.8.1-1.x86_64
    rubygem-rack is needed by opennebula-3.8.1-1.x86_64
    rubygem-sequel is needed by opennebula-3.8.1-1.x86_64
    rubygem-sinatra is needed by opennebula-3.8.1-1.x86_64
    rubygem-sqlite3-ruby is needed by opennebula-3.8.1-1.x86_64
    rubygem-thin is needed by opennebula-3.8.1-1.x86_64
    rubygem-uuidtools is needed by opennebula-3.8.1-1.x86_64
    rubygems is needed by opennebula-3.8.1-1.x86_64

However it gave me an error saying the package needed some dependencies.

Instead of installing each dependency by hand, yum has a nice feature that installs all the dependencies automatically:

[diogogmt@localhost opennebula-3.8.1]$ sudo yum localinstall opennebula-3.8.1-1.x86_64.rpm

After installing all the three packages the next step was to install the required ruby gems.

sudo /usr/share/one/install_gems

installs_gems is nothing more than a ruby script.
A snippet of the script:

    :debian => {
        :id => ['Ubuntu', 'Debian'],
        :dependencies => {
            SQLITE      => ['gcc', 'libsqlite3-dev'],
            'mysql'     => ['gcc', 'libmysqlclient-dev'],
            'curb'      => ['gcc', 'libcurl4-openssl-dev'],
            'nokogiri'  => %w{gcc rake libxml2-dev libxslt1-dev},
            'xmlparser' => ['gcc', 'libexpat1-dev'],
            'thin'      => ['g++'],
            'json'      => ['make', 'gcc']
        :install_command => 'apt-get install',
        :gem_env    => {
            'rake'      => '/usr/bin/rake'
    :redhat => {
        :id => ['CentOS', /^RedHat/],
        :dependencies => {
            SQLITE      => ['gcc', 'sqlite-devel'],
            'mysql'     => ['gcc', 'mysql-devel'],
            'curb'      => ['gcc', 'curl-devel'],
            'nokogiri'  => %w{gcc rubygem-rake libxml2-devel libxslt-devel},
            'xmlparser' => ['gcc', 'expat-devel'],
            'thin'      => ['gcc-c++'],
            'json'      => ['make', 'gcc']
        :install_command => 'yum install'
    :suse => {
        :id => [/^SUSE/],
        :dependencies => {
            SQLITE      => ['gcc', 'sqlite3-devel'],
            'mysql'     => ['gcc', 'libmysqlclient-devel'],
            'curb'      => ['gcc', 'libcurl-devel'],
            'nokogiri'  => %w{rubygem-rake gcc rubygem-rake libxml2-devel libxslt-devel},
            'xmlparser' => ['gcc', 'libexpat-devel'],
            'thin'      => ['rubygem-rake', 'gcc-c++'],
            'json'      => ['make', 'gcc']
        :install_command => 'zypper install'

It checks which distro you are running and then install the correct packages for it.

When I tried to run the script I bumped into two problems:

[diogogmt@localhost opennebula-3.8.1]$ sudo /usr/share/one/install_gems
mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h
ruby development package is needed to install gems

[diogogmt@localhost opennebula-3.8.1]$ sudo /usr/share/one/install_gems
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31: command not found: lsb_release -a
lsb_release command not found. If you are using a RedHat based
distribution install redhat-lsb

To fix those problems I installed the following packages:

  • ruby-devel
  • redhat-lsb

This time running the install_gems script installed all the dependencies, without errors.

The next sections from the official OpenNebula tutorial explained how to configure the user oneadmin in the FronteEnd and Hosts.

They refer to FrontEnd when talking about the machine that has OpenNebula installed and Hosts for the machines belonging to the cloud setup.

An important point to mention is that OpenNebula only needs to be installed on the FronteEnd, all the hosts only need to a ssh server, hypervisors and ruby installed.

For the oneadmin user configuration I followed the steps listed on the tutorial but I didn’t have a chance to look deeper on what is actually happening.

I’ll go over that configuration steps again once I configure a host computer.
Since right now there are no other computers with hypervisors installed in the network it is hard to test if the oneamdin is properly configured.

The last part of the tutorial was to actually start OpenNebula and test if everything was installed:

*All the interaction of OpenNebula needs to be done via the oneadmin user

So before running the commands below I needed to switch the terminal session to the oneadmin user:

su oneadmin

First set the credentials for oneadmin user

$ mkdir ~/.one
$ echo "oneadmin:password" > ~/.one/one_auth
$ chmod 600 ~/.one/one_auth

To start opennebula:

one start

However OpenNebula didn’t start, I got an error instead

[oneadmin@localhost ~]$ one start
Could not open database.
oned failed to start

Well, it turns out that I couldn’t even start mysql, no wonder why OpenNebula wasn’t able to open the database

[diogogmt@localhost opennebula-3.8.1]$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

Searching about the error above, I actually found out mysql wasn’t fully installed on my machine. I wasn’t able to start mysql as a service.

I thought that OpenNebula had installed mysql before, but I guess it didn’t, either way I just installed the mysql pakcages again:

yum install mysql-server mysql mysql-client

Then configured mysql to start on boot

chkconfig --levels 235 mysqld on
service mysqld start

After running those commands I was able to start mysql.

I then tried one more time to start OpenNebula

[oneadmin@localhost ~]$ one start
Could not open database.
oned failed to start

But again I got the same error.

I started looking online for possible solutions for the error I was getting but didn’t have any luck.

I remembered reading at beginning of the tutorial that all the logs for OpenNebula are saved.
They have a very good diagram explaining all the directories used by OpenNebula:

I took a look on the /var/log/one/one.d file
That provided some very good information:

     OpenNebula Configuration File
DATASTORE_MAD=ARGUMENTS=-t 15 -d fs,vmware,vmfs,iscsi,lvm,EXECUTABLE=one_datastore

The DB was set to sqlite.
I didn’t have sqlite installed, no wonder why the OpenNebula wasn’t being able to Open the DB

I went to the configuration file where all the settings for OpenNebula are defined:


Indeed the DB was set to sqlite:

DB = [ backend = "sqlite" ]
# Sample configuration for MySQL
# DB = [ backend = "mysql",
#        server  = "localhost",
#        port    = 0,
#        user    = "oneadmin",
#        passwd  = "oneadmin",
#        db_name = "opennebula" ]

I uncommented the configuration for mysql and commented out the one for sqlite

The last thing left to do was to create the database and user for mysql:

mysql> CREATE DATABASE opennebula;

mysql> GRANT ALL ON opennebula.* TO oneadmin@localhost IDENTIFIED BY ‘oneadmin’;

This time when I tried to run OpenNebula everything worked as expected!

[oneadmin@localhost diogogmt]$ one start
[oneadmin@localhost diogogmt]$ onevm list
    ID USER     GROUP    NAME            STAT UCPU    UMEM HOST             TIME

Next step is to understand how the ssh configuration works for the Front-End and Hosts and try to set up a small cluster of Hypervisors and use OpenNebula to manage them.

About these ads

2 thoughts on “OpenNebula setup, Part 1

  1. nice post. can you share also upgrade procedure from 3.6 to 3.8 in CentOS 6.3 x86_64bit the safest way considering I already have a running VM on my two (2) nodes? thank you.

Comments are closed.