MySQL Setup

The MySQL/MariaDB back-end is an alternative to the default SQLite back-end. In this guide and in the rest of OpenNebula’s documentation and configuration files we will refer to this database as the MySQL, however OpenNebula you can use either MySQL or MariaDB.

The two back-ends cannot coexist (SQLite and MySQL), and you will have to decide which one is going to be used while planning your OpenNebula installation.


If you are planning to install OpenNebula with MySQL back-end, please follow this guide prior to start OpenNebula the first time to avoid problems with oneadmin and serveradmin credentials.


First of all, you need a working MySQL server. You can either deploy one for the OpenNebula installation or reuse any existing MySQL already deployed and accessible by the Front-end.

Configuring MySQL

You need to add a new user and grant it privileges on the opennebula database. This new database doesn’t need to exist, OpenNebula will create it the first time you run it.

Assuming you are going to use the default values, log in to your MySQL server and issue the following commands:

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. [...]

mysql> GRANT ALL PRIVILEGES ON opennebula.* TO 'oneadmin' IDENTIFIED BY '<thepassword>';
Query OK, 0 rows affected (0.00 sec)

Visit the MySQL documentation to learn how to manage accounts.

Now configure the transaction isolation level:


Configuring OpenNebula

Before you run OpenNebula for the first time, you need to set in oned.conf the connection details, and the database you have granted privileges on.

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


  • server: URL of the machine running the MySQL server.
  • port: port for the connection to the server. If set to 0, the default port is used.
  • user: MySQL user-name.
  • passwd: MySQL password.
  • db_name: Name of the MySQL database OpenNebula will use.

Using OpenNebula with MySQL

After this installation and configuration process you can use OpenNebula as usual.

MySQL database maintenance

For an optimal database performance there are some tasks that should be done periodically depending on the load of the environment. They are listed below.

Search index

In order to be able to search VMs by different attributes, OpenNebula’s database have a FTS index, the size of this index can increase fast depending on the cloud load. For freeing some space it is needed to perform the following maintenance task periodically:

alter table vm_pool drop index ftidx;
alter table vm_pool add fulltext index ftidx (search_token);

VMs in DONE state

When a VM is terminated OpenNebula change it’s state to DONE but it keep the VM in the database in case the VM information is required in the future (e.g. to generate accounting reports). In order to reduce the size of the VM table, it is recommended to periodically delete the VM in DONE state when not needed. For this task it is available the onedb purge-done tool.