CentOS Stream 9
Sponsored Link

OpenStack Caracal : How to use Trove2024/08/08

 

This is how to use Trove.

This example is based on the environment like follows.

------------+--------------------------+--------------------------+------------
            |                          |                          |
        eth0|10.0.0.30             eth0|10.0.0.50             eth0|10.0.0.51
+-----------+-----------+  +-----------+-----------+  +-----------+-----------+
|   [ dlp.srv.world ]   |  | [ network.srv.world ] |  |  [ node01.srv.world ] |
|     (Control Node)    |  |     (Network Node)    |  |     (Compute Node)    |
|                       |  |                       |  |                       |
|  MariaDB    RabbitMQ  |  |      Open vSwitch     |  |        Libvirt        |
|  Memcached  Nginx     |  |     Neutron Server    |  |      Nova Compute     |
|  Keystone   httpd     |  |      OVN-Northd       |  |      Open vSwitch     |
|  Glance     Nova API  |  |  Nginx  iSCSI Target  |  |   OVN Metadata Agent  |
|  Cinder API           |  |     Cinder Volume     |  |     OVN-Controller    |
|                       |  |     Trove Services    |  |                       |
+-----------------------+  +-----------------------+  +-----------------------+

[1] Download a VM image for Trove and add it to Glance.
Also Create a Cinder volume type configured in [trove.conf].
[root@dlp ~(keystone)]#
wget https://tarballs.opendev.org/openstack/trove/images/trove-master-guest-ubuntu-jammy.qcow2

[root@dlp ~(keystone)]#
openstack image create Trove-Ubuntu --file=trove-master-guest-ubuntu-jammy.qcow2 --disk-format=qcow2 --container-format=bare --tag=trove --private
[root@dlp ~(keystone)]#
openstack image list

+--------------------------------------+----------------+--------+
| ID                                   | Name           | Status |
+--------------------------------------+----------------+--------+
| cfa9783d-ca91-4e3b-8016-81e3336bd5f0 | CentOS-Stream9 | active |
| 3dd6fdee-cda5-4d92-8d46-1052b4d41ab5 | Trove-Ubuntu   | active |
+--------------------------------------+----------------+--------+

[root@dlp ~(keystone)]#
openstack volume type create lvm-trove --private

+-------------+--------------------------------------+
| Field       | Value                                |
+-------------+--------------------------------------+
| description | None                                 |
| id          | e294e28d-2ed9-4716-846f-c43940a0a1bd |
| is_public   | False                                |
| name        | lvm-trove                            |
+-------------+--------------------------------------+
[2] Add Datastore you'd like to use on the Node Trove API is running. (it's Network Node on this example)
For example, add MariaDB, PostgreSQL on here.
# add datastore

[root@network ~]#
su -s /bin/bash trove -c "trove-manage datastore_update mariadb ''"

Datastore 'mariadb' updated.
[root@network ~]#
su -s /bin/bash trove -c "trove-manage datastore_update postgresql ''"

Datastore 'postgresql' updated.
# add versions for each datastore

# for [3dd6fdee-***], that's the image ID of Trove you created in [2]

[root@network ~]#
su -s /bin/sh -c "trove-manage datastore_version_update mariadb 10.5 mariadb 3dd6fdee-cda5-4d92-8d46-1052b4d41ab5 mariadb 1" trove

Datastore version '10.5(10.5)' updated.
[root@network ~]#
su -s /bin/sh -c "trove-manage datastore_version_update postgresql 12 postgresql 3dd6fdee-cda5-4d92-8d46-1052b4d41ab5 postgresql 1" trove

Datastore version '12(12)' updated.
# add parameters for each version of datastore

[root@network ~]#
su -s /bin/bash trove -c "trove-manage db_load_datastore_config_parameters mariadb 10.5 /usr/lib/python3.9/site-packages/trove/templates/mariadb/validation-rules.json"

Loading config parameters for datastore (mariadb) version (10.5)
[root@network ~]#
su -s /bin/bash trove -c "trove-manage db_load_datastore_config_parameters postgresql 12 /usr/lib/python3.9/site-packages/trove/templates/postgresql/validation-rules.json"

Loading config parameters for datastore (postgresql) version (12)
# create [cloudinit] files for VM image

[root@network ~]#
mkdir /etc/trove/cloudinit

[root@network ~]#
vi /etc/trove/cloudinit/mariadb.cloudinit
# create new
# specify Trove API host for [CONTROLLER]

#cloud-config
runcmd:
  - echo 'CONTROLLER=network.srv.world' > /etc/trove/controller.conf
  - chmod 644 /etc/trove/controller.conf

[root@network ~]#
cp /etc/trove/cloudinit/mariadb.cloudinit /etc/trove/cloudinit/postgresql.cloudinit

[root@network ~]#
chown -R trove /etc/trove/cloudinit

[3] Login as any Openstack user and create a Database instance on a Node.
By the way, Database instance runs as a Docker container inside a VM instance.
[cent@dlp ~(keystone)]$
openstack datastore list

+--------------------------------------+------------+
| ID                                   | Name       |
+--------------------------------------+------------+
| 7c791499-9c10-4716-9623-1f586dc3e21d | postgresql |
| c521cf2e-06eb-4084-8362-3fcf96660d01 | mariadb    |
+--------------------------------------+------------+

[cent@dlp ~(keystone)]$
openstack datastore version list mariadb

+--------------------------------------+------+---------+
| ID                                   | Name | Version |
+--------------------------------------+------+---------+
| d7445fb4-3481-43d7-8717-124b9c7585dd | 10.5 | 10.5    |
+--------------------------------------+------+---------+

[cent@dlp ~(keystone)]$
openstack flavor list

+----+-----------+-------+------+-----------+-------+-----------+
| ID | Name      |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+-----------+-------+------+-----------+-------+-----------+
| 1  | m1.tiny   |  2048 |   10 |         0 |     1 | True      |
| 2  | m1.small  |  4096 |   10 |         0 |     2 | True      |
| 3  | m1.medium |  8192 |   10 |         0 |     4 | True      |
| 4  | m1.large  | 16384 |   10 |         0 |     8 | True      |
| 5  | m2.large  | 16384 |   10 |        10 |     8 | True      |
+----+-----------+-------+------+-----------+-------+-----------+

[cent@dlp ~(keystone)]$
openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 5bf02aae-1fef-4303-937a-74b8412bf90a | private | e32f2074-d33b-4b13-9605-1a29301f93a1 |
| cedf14f5-e8ef-4577-a226-022f289f45fb | public  | c8fcf916-a102-412a-8809-92f31bd3955e |
+--------------------------------------+---------+--------------------------------------+

# create database instance
[cent@dlp ~(keystone)]$ openstack database instance create MariaDB-105 \
--flavor 2 \
--size 10 \
--nic net-id=5bf02aae-1fef-4303-937a-74b8412bf90a \
--databases MyDB --users serverworld:password \
--datastore mariadb --datastore-version 10.5 \
--is-public \
--allowed-cidr 10.0.0.0/24 \
--allowed-cidr 192.168.100.0/24 
+--------------------------+--------------------------------------+
| Field                    | Value                                |
+--------------------------+--------------------------------------+
| allowed_cidrs            | ['10.0.0.0/24', '192.168.100.0/24']  |
| created                  | 2024-08-08T00:07:44                  |
| datastore                | mariadb                              |
| datastore_version        | 10.5                                 |
| datastore_version_number | 10.5                                 |
| flavor                   | 2                                    |
| id                       | 63db5a32-6cec-4186-b605-98c7bc0275c6 |
| name                     | MariaDB-105                          |
| operating_status         |                                      |
| public                   | True                                 |
| region                   | RegionOne                            |
| service_status_updated   | 2024-08-08T00:07:44                  |
| status                   | BUILD                                |
| updated                  | 2024-08-08T00:07:44                  |
| volume                   | 10                                   |
+--------------------------+--------------------------------------+

# [BUILD] status during creation

[cent@dlp ~(keystone)]$
openstack database instance list

+--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+
| ID                                   | Name        | Datastore | Datastore Version | Status | Operating Status | Public | Addresses | Flavor ID | Size | Role |
+--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+
| 63db5a32-6cec-4186-b605-98c7bc0275c6 | MariaDB-105 | mariadb   | 10.5              | BUILD  |                  | True   |           | 2         |   10 |      |
+--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+

# if successfully created, status turns to [HEALTHY]

[cent@dlp ~(keystone)]$
openstack database instance list

+--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------
| ID                                   | Name        | Datastore | Datastore Version | Status | Operating Status | Public 
+--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------
| 63db5a32-6cec-4186-b605-98c7bc0275c6 | MariaDB-105 | mariadb   | 10.5              | ACTIVE | HEALTHY          | True   
+--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------
+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+
| Addresses                                                                                                                                          | Flavor ID | Size | Role |
+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+
| [{'address': '192.168.100.64', 'type': 'private', 'network': '5bf02aae-1fef-4303-937a-74b8412bf90a'}, {'address': '10.0.0.239', 'type': 'public'}] | 2         |   10 |      |
+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+

# verify accesses

[cent@dlp ~(keystone)]$
mysql -h 10.0.0.239 -u serverworld -p -e "show variables like 'hostname'; show databases;"

Enter password:
+---------------+--------------+
| Variable_name | Value        |
+---------------+--------------+
| hostname      | a230dbb3be8f |
+---------------+--------------+
+--------------------+
| Database           |
+--------------------+
| MyDB               |
| information_schema |
+--------------------+

# to delete a database instance, do like follows

[cent@dlp ~(keystone)]$
openstack database instance delete MariaDB-105

Request to delete database instance 63db5a32-6cec-4186-b605-98c7bc0275c6 has been accepted.
[4] This is for the case to create PostgreSQL instance.
[cent@dlp ~(keystone)]$
openstack datastore list

+--------------------------------------+------------+
| ID                                   | Name       |
+--------------------------------------+------------+
| 7c791499-9c10-4716-9623-1f586dc3e21d | postgresql |
| c521cf2e-06eb-4084-8362-3fcf96660d01 | mariadb    |
+--------------------------------------+------------+

[cent@dlp ~(keystone)]$
openstack datastore version list postgresql

+--------------------------------------+------+---------+
| ID                                   | Name | Version |
+--------------------------------------+------+---------+
| 6412daf5-b0d0-44f3-bd0a-4fa42850ee38 | 12   | 12      |
+--------------------------------------+------+---------+

[cent@dlp ~(keystone)]$ openstack database instance create PostgreSQL-12 \
--flavor 2 \
--size 10 \
--nic net-id=5bf02aae-1fef-4303-937a-74b8412bf90a \
--databases MyDB --users serverworld:password \
--datastore postgresql --datastore-version 12 \
--datastore-version-number 12 --is-public \
--is-public \
--allowed-cidr 10.0.0.0/24 \
--allowed-cidr 192.168.100.0/24 

[cent@dlp ~(keystone)]$
openstack database instance list

+--------------------------------------+---------------+------------+-------------------+--------+------------------+--------
| ID                                   | Name          | Datastore  | Datastore Version | Status | Operating Status | Public 
+--------------------------------------+---------------+------------+-------------------+--------+------------------+--------
| 99973b91-f7bc-4e02-93e8-dce7333510f8 | PostgreSQL-12 | postgresql | 12                | ACTIVE | HEALTHY          | True   
+--------------------------------------+---------------+------------+-------------------+--------+------------------+--------
+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+
| Addresses                                                                                                                                          | Flavor ID | Size | Role |
+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+
| [{'address': '192.168.100.46', 'type': 'private', 'network': '5bf02aae-1fef-4303-937a-74b8412bf90a'}, {'address': '10.0.0.241', 'type': 'public'}] | 2         |   10 |      |
+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+

[cent@dlp ~(keystone)]$
psql -h 10.0.0.241 -d MyDB -U serverworld -c "SELECT version();"

Password for user serverworld:
                                                        version
-----------------------------------------------------------------------------------------------------------------------
 PostgreSQL 12.19 (Debian 12.19-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
(1 row)
Matched Content