Building a database guest image for OpenStack Trove

Trove is the database as a service component of OpenStack that lets administrators and DevOps manage multiple instances of different database management systems (DBMS), both relational and NoSQL, using a common infrastructure. It makes database capacity available that can be consumed on-demand. This makes it much easier and faster to select and operate a database – while retaining all its capabilities – in a secure private or public cloud. The result is that routine tasks like provisioning, and managing regular administrative tasks like clustering, replication, backup and restore are handled in a simple, unified way.


A PDF of the Fall 2015 issue of Big Data Quarterly magazine is available for download now. To become a subscriber to the print magazine, go to www.dbta.com/BigDataQuarterly/Subscribe.aspx


A common question that newcomers to OpenStack Trove ask is this, “How do I build a guest image for a database?”

Some other closely related variants of this question include “Should a guest agent be on a Trove instance?” and, “How do I register a guest image with Trove?”

All of these questions are quite typically the “teething pains” of someone new to Trove, and something that we at Tesora have considerably simplified in our Tesora DBaaS Platform. This includes distributing pre-built and pre-tested guest images for a number of databases and versions, and simplified scripts for Trove and guest image installation.

For users of OpenStack Trove, here are some tips that can be very useful:

1. To iron out the kinks in your installation, start with a pre-built guest image.

The OpenStack Trove community makes available reference images for a number of databases at http://tarballs.openstack.org/trove/images/ubuntu/. Don’t be fooled by the ubuntu in the name; these images can be used even if you are running OpenStack on some other operating system.

The community images give you MySQL, Percona Server and MongoDB guest databases and any one of these will allow you to iron out the kinks in your installation. These images are built in a way to facilitate development activities and are not intended for production use.

These images are intended for use with devstack based systems; they do not have a guest agent on the image; instead they look to copy the guest image from the host machine from a predetermined location on launch. This makes it ideal for use in development.


If you are installing your system using devstack, add the following lines to your localrc file in order to configure Trove.

ENABLED_SERVICES+=,trove,tr-api,tr-tmgr,tr-cond

enable_plugin trove git://git.openstack.org/openstack/trove

enable_plugin python-troveclient git://git.openstack.org/openstack/python-troveclient

# Trove also requires Swift to be enabled for backup / restore

ENABLED_SERVICES+=,s-proxy,s-object,s-container,s-account

SWIFT_HASH=6f70656e737461636b2074726f766520627920616d72697468202620646f7567

The complete localrc file that I use is:

# Sample localrc file

# For use in installing Trove with devstack

# The various passwords below are just 20 character random passwords

# produced with makepasswd. The SWIFT_HASH is a unique string for a

# swift cluster and cannot be changed once established.

MYSQL_PASSWORD=07f1bff15e1cd3907c0f

RABBIT_PASSWORD=654a2b9115e9e02d6b8a

SERVICE_TOKEN=fd77e3eadc57a57d5470

ADMIN_PASSWORD=882f520bd67212bf9670

SERVICE_PASSWORD=96438d6980886000f90b

PUBLIC_INTERFACE=eth0

ENABLED_SERVICES+=,trove,tr-api,tr-tmgr,tr-cond

enable_plugin trove git://git.openstack.org/openstack/trove

enable_plugin python-troveclient git://git.openstack.org/openstack/python-troveclient

# Trove also requires Swift to be enabled for backup / restore

ENABLED_SERVICES+=,s-proxy,s-object,s-container,s-account

SWIFT_HASH=6f70656e737461636b2074726f766520627920616d72697468202620646f7567

It will install the guest image for you automatically. However, should you want to install a new guest image from tarballs.openstack.org, you can do that with these commands. Shown below are the commands to install a Percona guest image.

First register the downloaded percona.qcow2 file with Glance. This command will provide you with the Glance Image ID. You will use that later. 

glance image-create --name percona --disk-format qcow2 \

--container-format bare --is-public True < ./percona.qcow2

Now register a datastore called percona with Trove.

trove-manage datastore_update percona ''

Now relate the percona 5.5 datastore with the Glance Image ID you received earlier.

trove-manage datastore_version_update percona 5.5 percona \
<insert Glance Image ID here> \

"percona-server-server-5.5" 1

Now indicate that the default percona datastore is the newly registered version 5.5.

trove-manage datastore_update percona 5.5

Now register the validation-rules to be used by the configuration groups feature in Trove. The validation-rules.json file is available in the Trove source tree which devstack would have downloaded for you.

trove-manage db_load_datastore_config_parameters \

percona 5.5 ./validation_rules.json

Another source of guest images is Tesora. The Tesora images are production ready and tested for proper operation. Download those images at the Tesora website in the Downloads section http://www.tesora.com/downloads/. In addition to the databases supported by the OpenStack Trove project, Tesora also provides software and images for the Oracle 11g and Oracle 12c databases.

2. Build your own guest image using reference elements provided by the Trove project.

Next, you build a guest image using tools and files that are provided by the Trove project. This will help you get the required tools for building guest images working on your machine.

Trove reference elements are written in a way to facilitate development activities and are not intended for production use.

These reference elements are distributed as part of the trove-integration project. You can clone that project at http://git.openstack.org/openstack/trove-integration.

The simplest way to build the reference elements provided with the trove-integration project is to use the ‘redstack’ tool.

You do this with the build-image command line option. The trove-integration project provides reference elements for a number of databases like MySQL, MongoDB, Percona Server, PostgreSQL, Redis, Cassandra, Couchbase, CouchDB, DB2 and Vertica.

To build a guest image for MongoDB (for example) you would execute the command:

redstack build-image mongodb

This command utilizes references elements that are provided in the trove-integration project. These reference elements are used by the Disk Image Builder (DIB) command that does the actual building of the guest images.

These reference elements require the setting of several environment variables that are used to fine-tune the image that is built. The Trove also provides a tutorial on how to build guest images as part of the developer documentation at http://docs.openstack.org/developer/trove/dev/building_guest_images.html

3. Build your own customized guest images

Once you have been able to successfully build and launch an image using the reference elements, you are better equipped to build your own customized images.

To do this, you can use any tool that will generate an image understood by your OpenStack hypervisor. The most widely used tool by Trove developers and users is Disk Image Builder (DIB).

A detailed description of the DIB tool and its use in building Trove images is available in the recently published book “OpenStack Trove” available from leading booksellers.

For more details about building guest images, you can contact members of the Trove community on IRC at #openstack-trove. Additional help and support are also available to users of Tesora’s Enterprise Edition software on IRC at #tesora.

Image courtesy of Shutterstock.



Newsletters

Subscribe to Big Data Quarterly E-Edition