×
Community Blog How to Install and Configure OpenNebula on Ubuntu 18.04

How to Install and Configure OpenNebula on Ubuntu 18.04

In this tutorial, we will learn how to install and configure OpenNebula on an Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 18.04 server.

By Hitesh Jethva, Alibaba Cloud Community Blog author.

Introduction

OpenNebula is a free, open source, simple yet powerful and flexible cloud computing platform for the management of virtualized data centers. It is easy to use and combines existing virtualization technologies with advanced features for multi-tenancy and elasticity.

In this tutorial, we will learn how to install and configure OpenNebula on an Alibaba Cloud Elastic Compute Service (ECS) Ubuntu 18.04 server.

Prerequisites

  • Two fresh Alibaba Cloud instances with Ubuntu 18.04 server installed.
  • A static IP address 192.168.0.102 is configured on OpenNebula front-end instance and 192.168.0.249 is configured on OpenNebula KVM node instance.
  • Root password is set up on both instances.

Create a new ECS instance and connect to your instance as the root user.

Once you are logged into your Ubuntu 18.04 instance, run the following command to update your base system with the latest available packages.

apt-get update -y

Install and Configure MariaDB

First, you will need to install MariaDB database server to your OpenNebula front-end instance. You can install it with the following command:

apt-get install mariadb-server -y

After installing MariaDB, you will need to secure it first. You can secure it by running the following command:

mysql_secure_installation

Answer all the questions as shown below:

    Enter current password for root (enter for none):
    Set root password? [Y/n]: N
    Remove anonymous users? [Y/n]: Y
    Disallow root login remotely? [Y/n]: Y
    Remove test database and access to it? [Y/n]:  Y
    Reload privilege tables now? [Y/n]:  Y

Once the MariaDB server is secured, log in to MariaDB shell with the following command:

mysql -u root -p

Enter your root password, then create a database and user for OpenNebula with the following command:

MariaDB [(none)]> CREATE DATABASE opennebuladb;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON opennebuladb.* TO 'openadmin' IDENTIFIED BY 'password';

Next, flush the privileges and exit from the MariaDB shell with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> QUIT;

Next, restart MariaDB service with the following command:

systemctl restart mariadb

Next, check the status of MariaDB service with the following command:

systemctl status mariadb

Install OpenNebula

By default, OpenNebula is not available in the Ubuntu 18.04 default repository. So, you will need to add OpenNebula repository to your OpenNebula front-end instance.

First, download and add the GPG key with the following command:

wget -q -O- https://downloads.opennebula.org/repo/repo.key | apt-key add -

Next, add the repository with the following command:

echo "deb https://downloads.opennebula.org/repo/5.6/Ubuntu/18.04 stable opennebula" | tee /etc/apt/sources.list.d/opennebula.list

Next, update the repository and install OpenNebula with the following command:

apt-get update -y
apt-get install opennebula opennebula-sunstone opennebula-gate opennebula-flow -y

After installing OpenNebula, you will also need to install Ruby libraries to your instance. You can install them by running the following command:

/usr/share/one/install_gems

Configure OpenNebula

Next, you will need to open /etc/one/oned.conf file and defined database credentials in the file.

nano /etc/one/oned.conf

Make the following changes:

LISTEN_ADDRESS = "0.0.0.0"

#DB = [ BACKEND = "sqlite" ]

# Sample configuration for MySQL
 DB = [ BACKEND = "mysql",
        SERVER  = "localhost",
        PORT    = 0,
        USER    = "openadmin",
        PASSWD  = "password",
        DB_NAME = "opennebuladb",
        CONNECTIONS = 50 ]

Save and close the file. Then, you will need to define OpenNebula authentication credential in one_auth file. You can do it with the following command:

nano /var/lib/one/.one/one_auth

Make the following changes as per your need:

oneadmin:admin@123   

Save and close the file. When you are finished.

Finally, start OpenNebula service and enable it to start on boot with the following command:

systemctl start opennebula
systemctl enable opennebula
systemctl start opennebula-sunstone
systemctl enable opennebula-sunstone

You can now check the status of OpenNebula with the following command:

systemctl status opennebula

And

systemctl status opennebula-sunstone

Access OpenNebula Web Interface

First, you will need to verify the OpenNebula installation on OpenNebula front-end instance.

You can do it with the following command:

su - oneadmin -c "oneuser show"

Now, open your web browser and type the URL http://192.18.0.102:9869. You will be redirected to the following page:

1

Provide your administrator username and password which you have define in one_auth file and click on the Login button. You should see the OpenNebula dashboard in the following page:

2

Install OpenNebula KVM Node

KVM is an open source hypervisor for OpenNebula's Open Cloud Architecture. By default, OpenNebula KVM package is not available in the Ubuntu 18.04 repository. So, you will need to add OpenNebula repository to your OpenNebula KVM instance.

First, download and add the GPG key with the following command:

wget -q -O- https://downloads.opennebula.org/repo/repo.key | apt-key add -

Next, add the repository with the following command:

echo "deb https://downloads.opennebula.org/repo/5.6/Ubuntu/18.04 stable opennebula" | tee /etc/apt/sources.list.d/opennebula.list

Next, update the repository and install OpenNebula KVM package with the following command:

apt-get install opennebula-node -y

Next, you will need to edit /etc/libvirt/libvirtd.conf for OpenNebula to work well with KVM.

nano /etc/libvirt/libvirtd.conf

Make the following changes:

unix_sock_group = "oneadmin"
unix_sock_rw_perms = "0777"

Save and close the file. Then, restart libvirtd service with the following command:

systemctl restart libvirtd
systemctl restart libvirt-bin

Configure Key-base SSH Authentication on OpenNebula Front-end

OpenNebula Front-end connects to the OpenNebula KVM node using SSH. So, you will need to configure passwordless ssh authentication between them. You can do this by distributing the public key of the user oneadmin from both machines to the file /var/lib/one/.ssh/authorized_keys.

First, create the known_hosts file with the following command:

ssh-keyscan 192.168.0.102 >> /var/lib/one/.ssh/known_hosts
ssh-keyscan 192.168.0.249 >> /var/lib/one/.ssh/known_hosts

Next, copy /var/lib/one/.ssh directory to OpenNebula KVM node with the following command:

scp -rp /var/lib/one/.ssh root@192.168.0.249:/var/lib/one/

Next, test ssh connection from Front-end, you should not be prompted for a password:

ssh 192.168.0.249

Add KVM Host to OpenNebula Front-end

Next, you will need to add KVM host to OpenNebula front-end so that OpenNebula can launch VMs on it.

On the OpenNebula web interface, open Infrastructure >> Hosts and Click on the + button. You should see the following page:

3

Select KVM for type field and IP address of KVM node. Then, click on the Create button. You should see the following page:

4

Now, click on the Hosts. You should see the detail information of KVM node in the following page:

5

Congratulations! You have successfully installed and configured OpenNebula on an ECS Ubuntu18.04 server.

1 0 0
Share on

Hiteshjethva

24 posts | 3 followers

You may also like

Comments

5491783352582057 March 4, 2020 at 8:28 pm

Hi, Great Reading ! Is there any way to deploy VMs with public IPs from sunstone. Regards.

Hiteshjethva

24 posts | 3 followers

Related Products