OpenStack Antelope : How to use Trove2023/04/20 |
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)]#
[root@dlp ~(keystone)]# openstack image create Trove-Ubuntu --file=trove-master-guest-ubuntu-focal.qcow2 --disk-format=qcow2 --container-format=bare --tag=trove --private
openstack image list +--------------------------------------+----------------+--------+ | ID | Name | Status | +--------------------------------------+----------------+--------+ | 17d50b54-c009-45ff-96ed-58086f79065f | CentOS-Stream9 | active | | d89904d0-c4ca-47cc-abcc-19aca966ffba | Trove-Ubuntu | active | +--------------------------------------+----------------+--------+[root@dlp ~(keystone)]# openstack volume type create lvm-trove --private +-------------+--------------------------------------+ | Field | Value | +-------------+--------------------------------------+ | description | None | | id | 4cee9671-6b97-40f3-96eb-7d9dc866ff9c | | 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 [d89904d0-***], 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 d89904d0-c4ca-47cc-abcc-19aca966ffba 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 d89904d0-c4ca-47cc-abcc-19aca966ffba 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 d89904d0-c4ca-47cc-abcc-19aca966ffba 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.9/site-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.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 mysql 8.0 /usr/lib/python3.9/site-packages/trove/templatess/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 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. |
[cent@dlp ~(keystone)]$ openstack datastore list +--------------------------------------+---------+ | ID | Name | +--------------------------------------+---------+ | 1e37c0d2-d1a9-448b-91c3-f01a732797e5 | mariadb | | e1654ce5-86dc-47ab-8b95-a3e3e51fd8b1 | mysql | +--------------------------------------+---------+[cent@dlp ~(keystone)]$ openstack datastore version list mariadb +--------------------------------------+------+---------+ | ID | Name | Version | +--------------------------------------+------+---------+ | d0796e3a-f0ed-42e7-899b-5308c08e6e43 | 10.3 | 10.3 | | b7cb5645-a0f1-43e4-976d-4816c37e4d52 | 10.5 | 10.5 | +--------------------------------------+------+---------+[cent@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 | 0 | 4 | True | +----+-----------+------+------+-----------+-------+-----------+[cent@dlp ~(keystone)]$ openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 913ec733-5a60-4df0-b182-49a393675bca | private | bd8d7602-95e4-4540-971e-a0104dd8b658 | | c1c6a4c6-776e-4c4f-b557-b9efc4a43ee8 | public | 68cec7d2-f12f-4272-ac16-8dba6148888b | +--------------------------------------+---------+--------------------------------------+ # create database instance [cent@dlp ~(keystone)]$ openstack database instance create MariaDB-105 \ --flavor 2 \ --size 10 \ --nic net-id=913ec733-5a60-4df0-b182-49a393675bca \ --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-04-20T04:36:18 | | datastore | mariadb | | datastore_version | 10.5 | | datastore_version_number | 10.5 | | flavor | 2 | | id | ff74638c-a063-47a6-af67-651ee5ae9f38 | | name | MariaDB-105 | | operating_status | | | public | True | | region | RegionOne | | service_status_updated | 2023-04-20T04:36:18 | | status | BUILD | | updated | 2023-04-20T04:36:18 | | 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 | +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ | ff74638c-a063-47a6-af67-651ee5ae9f38 | 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 +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- | ff74638c-a063-47a6-af67-651ee5ae9f38 | MariaDB-105 | mariadb | 10.5 | ACTIVE | HEALTHY | True +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | Addresses | Flavor ID | Size | Role | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | [{'address': '192.168.100.108', 'type': 'private', 'network': '913ec733-5a60-4df0-b182-49a393675bca'}, {'address': '10.0.0.209', 'type': 'public'}] | 2 | 10 | | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ # verify accesses [cent@dlp ~(keystone)]$ mysql -h 10.0.0.209 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | 9d11b975e6ec | +---------------+--------------+ +--------------------+ | 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 ff74638c-a063-47a6-af67-651ee5ae9f38 has been accepted. |
[4] | This is for the case to create MySQL instance. |
[cent@dlp ~(keystone)]$ openstack datastore list +--------------------------------------+---------+ | ID | Name | +--------------------------------------+---------+ | 1e37c0d2-d1a9-448b-91c3-f01a732797e5 | mariadb | | e1654ce5-86dc-47ab-8b95-a3e3e51fd8b1 | mysql | +--------------------------------------+---------+[cent@dlp ~(keystone)]$ openstack datastore version list mysql
+--------------------------------------+------+---------+
| ID | Name | Version |
+--------------------------------------+------+---------+
| bbcdbf43-46d7-434a-b36f-2fdbedc6cec5 | 8.0 | 8.0 |
+--------------------------------------+------+---------+
[cent@dlp ~(keystone)]$ openstack database instance create MySQL-8 \
--flavor 2 \
--size 10 \
--nic net-id=913ec733-5a60-4df0-b182-49a393675bca \
--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
[cent@dlp ~(keystone)]$ openstack database instance list +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- | ID | Name | Datastore | Datastore Version | Status | Operating Status | Public +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- | f3772767-61ac-4dea-9745-78d90a775fc7 | MySQL-8 | mysql | 8.0 | ACTIVE | HEALTHY | True +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- +----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | Addresses | Flavor ID | Size | Role | +----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | [{'address': '192.168.100.77', 'type': 'private', 'network': '913ec733-5a60-4df0-b182-49a393675bca'}, {'address': '10.0.0.243', 'type': 'public'}] | 2 | 10 | | +----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+[cent@dlp ~(keystone)]$ mysql -h 10.0.0.243 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | d9cb461b8cda | +---------------+--------------+ +--------------------+ | Database | +--------------------+ | MyDB | | information_schema | | performance_schema | +--------------------+ |
Sponsored Link |