Ubuntu 22.04
Sponsored Link

OpenStack Antelope : How to use Trove2023/03/29

 
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-focal.qcow2

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

+--------------------------------------+--------------+--------+
| ID                                   | Name         | Status |
+--------------------------------------+--------------+--------+
| de2d8750-dbd6-4b97-aa28-a920a2309718 | Trove-Ubuntu | active |
| 00ea6e97-0e97-4cb4-8ac4-2409c28f0289 | Ubuntu2204   | active |
+--------------------------------------+--------------+--------+

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

+-------------+--------------------------------------+
| Field       | Value                                |
+-------------+--------------------------------------+
| description | None                                 |
| id          | c0913e9c-285a-42e9-93a9-32d68b50c866 |
| 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, MySQL 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 mysql ''"

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

# for [de2d8750-***], 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.3 mariadb de2d8750-dbd6-4b97-aa28-a920a2309718 mariadb 1" trove

Datastore version '10.3(10.3)' updated.
root@network:~#
su -s /bin/sh -c "trove-manage datastore_version_update mariadb 10.5 mariadb de2d8750-dbd6-4b97-aa28-a920a2309718 mariadb 1" trove

Datastore version '10.5(10.5)' updated.
root@network:~#
su -s /bin/sh -c "trove-manage datastore_version_update mysql 8.0 mysql de2d8750-dbd6-4b97-aa28-a920a2309718 mysql 1" trove

Datastore version '8.0(8.0)' 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.3 /usr/lib/python3/dist-packages/trove/templates/mariadb/validation-rules.json"

Loading config parameters for datastore (mariadb) version (10.3)
root@network:~#
su -s /bin/bash trove -c "trove-manage db_load_datastore_config_parameters mariadb 10.5 /usr/lib/python3/dist-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 mysql 8.0 /usr/lib/python3/dist-packages/trove/templates/mysql/validation-rules.json"

Loading config parameters for datastore (mysql) version (8.0)
# 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/mysql.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.
ubuntu@dlp ~(keystone)$
openstack datastore list

+--------------------------------------+------------+
| ID                                   | Name       |
+--------------------------------------+------------+
| 6efdd4f6-9532-4f61-8ff8-c90c5c351e1e | mariadb    |
| fa217b97-6598-4586-8200-14f899689c0b | mysql      |
+--------------------------------------+------------+

ubuntu@dlp ~(keystone)$
openstack datastore version list mariadb

+--------------------------------------+------+---------+
| ID                                   | Name | Version |
+--------------------------------------+------+---------+
| e6e070a8-39e8-4366-8126-163399b573b7 | 10.3 | 10.3    |
| 0c2c0c0d-e0a4-444b-91d5-1c002a7dc75d | 10.5 | 10.5    |
+--------------------------------------+------+---------+

ubuntu@dlp ~(keystone)$
openstack flavor list

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

ubuntu@dlp ~(keystone)$
openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 5352e6c0-47b3-4df2-84f4-ca048f141e1d | public  | ca5539a8-0291-4684-9fb3-0f448efacebf |
| ce6e88bc-107a-446b-b2ab-255bab7269fe | private | feb337ec-215e-406e-8871-196fed2c4207 |
+--------------------------------------+---------+--------------------------------------+

# create database instance
ubuntu@dlp ~(keystone)$ openstack database instance create MariaDB-105 \
--flavor 2 \
--size 10 \
--nic net-id=ce6e88bc-107a-446b-b2ab-255bab7269fe \
--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                  | 2023-03-29T06:03:27                  |
| datastore                | mariadb                              |
| datastore_version        | 10.5                                 |
| datastore_version_number | 10.5                                 |
| flavor                   | 2                                    |
| id                       | efc1853a-a72d-4194-b6a0-bf89155d6a91 |
| name                     | MariaDB-105                          |
| operating_status         |                                      |
| public                   | True                                 |
| region                   | RegionOne                            |
| service_status_updated   | 2023-03-29T06:03:27                  |
| status                   | BUILD                                |
| updated                  | 2023-03-29T06:03:27                  |
| volume                   | 10                                   |
+--------------------------+--------------------------------------+

# [BUILD] status during creation

ubuntu@dlp ~(keystone)$
openstack database instance list

+--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+
| ID                                   | Name        | Datastore | Datastore Version | Status | Operating Status | Public | Addresses | Flavor ID | Size | Role |
+--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+
| efc1853a-a72d-4194-b6a0-bf89155d6a91 | MariaDB-105 | mariadb   | 10.5              | BUILD  |                  | True   |           | 2         |   10 |      |
+--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+

# if successfully created, status turns to [HEALTHY]

ubuntu@dlp ~(keystone)$
openstack database instance list

+--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------
| ID                                   | Name        | Datastore | Datastore Version | Status | Operating Status | Public 
+--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------
| efc1853a-a72d-4194-b6a0-bf89155d6a91 | MariaDB-105 | mariadb   | 10.5              | ACTIVE | HEALTHY          | True   
+--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------
+-----------------------------------------------------------------------------------------------------------------------------------------------------
| Addresses                                                                                                                                           
+-----------------------------------------------------------------------------------------------------------------------------------------------------
| [{'address': '192.168.100.112', 'type': 'private', 'network': 'ce6e88bc-107a-446b-b2ab-255bab7269fe'}, {'address': '10.0.0.246', 'type': 'public'}] 
+-----------------------------------------------------------------------------------------------------------------------------------------------------
+-----------+------+------+
| Flavor ID | Size | Role |
+-----------+------+------+
| 2         |   10 |      |
+-----------+------+------+

# verify accesses

ubuntu@dlp ~(keystone)$
mysql -h 10.0.0.246 -u serverworld -p -e "show variables like 'hostname'; show databases;"

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

# to delete a database instance, do like follows

ubuntu@dlp ~(keystone)$
openstack database instance delete MariaDB-105

Request to delete database instance efc1853a-a72d-4194-b6a0-bf89155d6a91 has been accepted.
[4] This is for the case to create MySQL instance.
ubuntu@dlp ~(keystone)$
openstack datastore list

+--------------------------------------+------------+
| ID                                   | Name       |
+--------------------------------------+------------+
| 6efdd4f6-9532-4f61-8ff8-c90c5c351e1e | mariadb    |
| fa217b97-6598-4586-8200-14f899689c0b | mysql      |
+--------------------------------------+------------+

ubuntu@dlp ~(keystone)$
openstack datastore version list mysql

+--------------------------------------+------+---------+
| ID                                   | Name | Version |
+--------------------------------------+------+---------+
| cb2f2cbf-5813-4a60-a2fa-bf075ee97b7b | 8.0  | 8.0     |
+--------------------------------------+------+---------+

ubuntu@dlp ~(keystone)$ openstack database instance create MySQL-8 \
--flavor 2 \
--size 10 \
--nic net-id=ce6e88bc-107a-446b-b2ab-255bab7269fe \
--databases MyDB --users serverworld:password \
--datastore mysql --datastore-version 8.0 \
--is-public \
--allowed-cidr 10.0.0.0/24 \
--allowed-cidr 192.168.100.0/24 

ubuntu@dlp ~(keystone)$
openstack database instance list

+--------------------------------------+---------+-----------+-------------------+--------+------------------+--------
| ID                                   | Name    | Datastore | Datastore Version | Status | Operating Status | Public 
+--------------------------------------+---------+-----------+-------------------+--------+------------------+--------
| c8a2a186-1cbe-4d2a-88a5-90b634dbf522 | MySQL-8 | mysql     | 8.0               | ACTIVE | HEALTHY          | True   
+--------------------------------------+---------+-----------+-------------------+--------+------------------+--------
+-----------------------------------------------------------------------------------------------------------------------------------------------------
| Addresses                                                                                                                                           
+-----------------------------------------------------------------------------------------------------------------------------------------------------
| [{'address': '192.168.100.150', 'type': 'private', 'network': 'ce6e88bc-107a-446b-b2ab-255bab7269fe'}, {'address': '10.0.0.216', 'type': 'public'}] 
+-----------------------------------------------------------------------------------------------------------------------------------------------------
+-----------+------+------+
| Flavor ID | Size | Role |
+-----------+------+------+
| 2         |   10 |      |
+-----------+------+------+

ubuntu@dlp ~(keystone)$
mysql -h 10.0.0.216 -u serverworld -p -e "show variables like 'hostname'; show databases;"

Enter password:
+---------------+--------------+
| Variable_name | Value        |
+---------------+--------------+
| hostname      | 87e615253fcb |
+---------------+--------------+
+--------------------+
| Database           |
+--------------------+
| MyDB               |
| information_schema |
| performance_schema |
+--------------------+
Matched Content