Red Hat Training
A Red Hat training course is available for Red Hat OpenStack Platform
Chapter 2. Using Database-as-a-Service
2.1. Automate the Creation and Configuration of Database-as-a-Service Guest Images
Red Hat recommends using the trove-image-create
tool for generating automated DBaaS-compatible images for supported datastores.
To get the trove-image-create
tool, install the openstack-trove-images
package:
# yum install openstack-trove-images
The following basic options are available:
Option | Description, parameters |
---|---|
| The base image that you are going to use. QEMU images (qcow2) are supported. Specify the image file name (and, optionally, its path) as a pamaterer. |
|
The OpenStack version you want to use. Specify either |
| The datastore you want to deploy. Supported datastores are listed in the Preface, and potential parameters are:
|
Example 2.1. Customize an Image
For example, you can use the tool this way:
# trove-image-create -s mysql -r liberty -i myimage.qcow2
This will customize the image stored in the myimage.qcow2 file in the current working directory by adding MariaDB 5.5 and trove
from Red Hat OpenStack Platform 8 (Liberty) to it.
There are additional options that must be used if you are working with a RHEL 7 image:
Option | Recognized parameters and their syntax | Description |
---|---|---|
|
USER | Register with Subscription Manager using your Red Hat credentials. |
|
| Attach a specified or automatically determined subscription pool to the system. |
Example 2.2. Customize a RHEL 7 Image
For example:
# trove-image-create -s mysql -r liberty -i ../../images/rhel-mariadb55.qcow2 --sm-register admin@example.com:password:123456 --sm-pool auto
This will customize the image in a manner similar to the previous example but also register the system using Red Hat login name admin@example.com, password 123456, and the best-matching subscription.
2.1.1. Loading the Image to Database-as-a-Service Management
When the customization of the image is complete, perform the following steps:
Upload the image to the Image service. To do so, run a command similar to this one:
# openstack image create rhel7-mariadb55 --disk-format qcow2 --container-format bare --public < myimage.qcow2
Get the ID of the uploaded image from the output of the previous command, which should look like the following:
+------------------+------------------------------------------------------+ | Field | Value | +------------------+------------------------------------------------------+ | checksum | dec3f16054739459d03984b7a552cd9c | | container_format | bare | | created_at | 2016-01-27T20:10:36Z | | disk_format | qcow2 | | file | /v2/images/c637391b-e00f-47fb-adb5-e8dfc4e224d4/file | | id | c637391b-e00f-47fb-adb5-e8dfc4e224d4 | | min_disk | 0 | | min_ram | 0 | | name | rhel7-mariadb55 | | owner | 483cae7de00c4f029e19eef5983c67a9 | | protected | False | | schema | /v2/schemas/image | | size | 1910767616 | | status | active | | updated_at | 2016-01-27T20:10:46Z | | virtual_size | None | | visibility | public | +------------------+------------------------------------------------------+
The ID would be c637391b-e00f-47fb-adb5-e8dfc4e224d4 in this case.
Update the DBaaS management datastore to have the record of the new image that will be used to launch instances for the datastore and version you want:
# export DATASTORE=mariadb # export DATASTORE_VERSION=5.5 # export IMAGE_ID=c637391b-e00f-47fb-adb5-e8dfc4e224d4 # export PACKAGES=mariadb-server # # trove-manage datastore_update ${DATASTORE} "" # trove-manage datastore_version_update ${DATASTORE} ${DATASTORE_VERSION} ${DATASTORE} ${IMAGE_ID} ${PACKAGES} 1 # trove-manage datastore_update ${DATASTORE} ${DATASTORE_VERSION}
ImportantThe value of the
PACKAGES
variable depends on the datastore you are using. For MySQL (any version), usemysql-community-server
. For MariaDB 10.0, useMariaDB-server
.
2.1.2. Troubleshooting
In the event of an instance failing on launch, an image with an SSH key can be created and used for troubleshooting. The trove-image-create
tool has the --root-ssh-key
option for this purpose. This option takes the path to a public key as a parameter, and injects the key into the image. For example:
# trove-image-create -i myimage.qcow2 -r liberty -s mysql --root-ssh-key ~/.ssh/id_rsa.pub
In order to be able to access an instance based on this image, follow these steps:
- Edit the security group associated with the instance.
- Open the SSH port.
- Consider allowing ICMP as well.
- If the instance is in a private network, you will need to add a floating IP to the instance.
After completing these steps, you should be able to run the following command to log in to the instance:
# ssh root@INSTANCE_IP