Thursday, November 19, 2015

Build Trove Guest Image Manually in OpenStack

I came up with this solution to manually building an image for OpenStack Trove based on my knowledge and intuition, after struggling with using Disk Image Builder on my OpenStack environment.

The first step to use Trove is to obtain or build a Trove image. Compared to regular OpenStack virtual machine image used for Nova, there are two extra essential components on a Trove image: Trove guest agent (or the ability of getting Trove guest agent) and a database server package.

If you already have an OpenStack environment set up, you can build a Trove guest image following the below steps.

1. Launch a Nova instance with a flavor that satisfies the system requirements (CPU, RAM, swap disk, etc) of the database server you want to install. Perform step 2-6  on this Nova instance.

2.  Install and configure cloud-init on the Nova instance launched in Step 1.

# apt-get install cloud-init cloud-utils cloud-initramfs-growroot cloud-initramfs-rescuevol
# echo 'manage_etc_hosts: True' > /etc/cloud/cloud.cfg.d/10_etc_hosts.cfg

3. Set up basic environment for trove-guestagent on the Nova instance launched in Step 1.

# apt-get update
# apt-get install ubuntu-cloud-keyring
# echo "deb http://ubuntu-cloud.archive.canonical.com/ubuntu" \
    "trusty-updates/kilo main" > /etc/apt/sources.list.d/cloudarchive-kilo.list

(Note: change "kilo" to the version of your OpenStack.)

# apt-get update && apt-get dist-upgrade

4. Install Trove and Trove-guestagent on the Nova instance launched in Step 1.

# apt-get install python-trove python-troveclient trove-common trove-guestagent

5. Configure Trove-guestagent on the Nova instance launched in Step 1.

Edit /etc/trove/trove-guestagent.conf.

  [DEFAULT]
    rabbit_host = controller
    rabbit_userid = RABBIT_USER
    rabbit_password =  RABBIT_PASS
    nova_proxy_admin_user = admin
    nova_proxy_admin_pass = admin
    nova_proxy_admin_tenant_name = admin
    trove_auth_url = http://controller:35357/v2.0
    log_file = trove-guestagent.log

( Change RABBIT_USER, RABBIT_PASS)
Refer to Step 1 in the database chapter of OpenStack Administration Guide.

6. Upload the database server package to the Nova instance launched in Step 1.

Note: After uploading the database server package, you can choose to install it manually or not. If you don't install it, Trove-guestagent should install it at the boot time of a Trove instance. But different database servers have different scenarios. Refer to the source code of the database you want to use under /trove/guestagent/datastore to find out the default path of the database server package, where the package should be uploaded to. For example, if you use Vertica, the default path that Vertica package should be uploaded to is root directory '/' based on the value of option "INSTALL_VERTICA" in the source file /trove/guestagent/datastore/experimental/vertica/system.py. And the community edition of Vertica is free and can be downloaded here.

7. In the OpenStack dashboard, shut off this Nova instance, take a snapshot of it.

Note: In OpenStack, a snapshot is an image.

8. Through trove client, add the snapshot to datastore.

Refer to Step 2-6 in the database chapter of OpenStack Administration Guide.

9. Restart all trove service on the controller node.

# service trove-api restart
# service trove-taskmanager restart
# service trove-conductor restart

10. Launch a Trove instance.

Refer to OpenStack Command Line Reference.