OpenStack Zed : How to use Trove2022/11/14 |
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 | +--------------------------------------+----------------+--------+ | 8367cc21-61f4-480b-8d03-90c057c7a7cf | CentOS-Stream9 | active | | 2cf4cbc8-e58b-44c4-8849-e3e39d7c4e45 | Trove-Ubuntu | active | +--------------------------------------+----------------+--------+[root@dlp ~(keystone)]# openstack volume type create lvm-trove --private +-------------+--------------------------------------+ | Field | Value | +-------------+--------------------------------------+ | description | None | | id | 765b4b10-f6b2-48c6-8b8d-521c23197437 | | 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 [2cf4cbc8-***], 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 2cf4cbc8-e58b-44c4-8849-e3e39d7c4e45 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 2cf4cbc8-e58b-44c4-8849-e3e39d7c4e45 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 2cf4cbc8-e58b-44c4-8849-e3e39d7c4e45 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] | Create a Database instance on a Node. For example, create a MariaDB Database instance with [admin] user on here. (by default policy, only [admin] user can create Trove instances) By the way, Database instance runs as a Docker container inside a VM instance. |
[root@dlp ~(keystone)]# openstack datastore list +--------------------------------------+---------+ | ID | Name | +--------------------------------------+---------+ | 286fa172-a584-431d-8fa2-3701a51ada3c | mysql | | a8e8ab84-260c-4802-97b7-ef62fbe1d689 | mariadb | +--------------------------------------+---------+[root@dlp ~(keystone)]# openstack datastore version list mariadb +--------------------------------------+------+---------+ | ID | Name | Version | +--------------------------------------+------+---------+ | 467968e8-0710-471b-aaa0-13905cf9d199 | 10.3 | 10.3 | | 4e1411dc-25b2-4360-a90c-9554b1093161 | 10.5 | 10.5 | +--------------------------------------+------+---------+[root@dlp ~(keystone)]# openstack flavor list +----+----------+------+------+-----------+-------+-----------+ | ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public | +----+----------+------+------+-----------+-------+-----------+ | 0 | m1.small | 2048 | 10 | 0 | 1 | True | +----+----------+------+------+-----------+-------+-----------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 004ca400-3d79-4c1b-b8fb-bba1e273000e | public | 80213093-ac95-469a-b4d9-8c6adc93cfe1 | | c9c79a1d-136e-4036-8fe0-eaac79f05f5d | private | 85e66c6a-66eb-490f-a4fa-e21f91678c89 | +--------------------------------------+---------+--------------------------------------+ # create database instance [root@dlp ~(keystone)]# openstack database instance create MariaDB-105 \ --flavor 0 \ --size 10 \ --nic net-id=c9c79a1d-136e-4036-8fe0-eaac79f05f5d \ --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 | 2022-11-14T07:10:14 | | datastore | mariadb | | datastore_version | 10.5 | | datastore_version_number | 10.5 | | encrypted_rpc_messaging | True | | flavor | 0 | | id | cbadc459-f56f-48d1-99a7-94e1d1106bac | | name | MariaDB-105 | | operating_status | | | public | True | | region | RegionOne | | server_id | None | | service_status_updated | 2022-11-14T07:10:14 | | status | BUILD | | tenant_id | 939974d6fc8e400eb01f7dd749935ea3 | | updated | 2022-11-14T07:10:14 | | volume | 10 | | volume_id | None | +--------------------------+--------------------------------------+ # [BUILD] status during creation [root@dlp ~(keystone)]# openstack database instance list +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ | ID | Name | Datastore | Datastore Version | Status | Operating Status | Public | Addresses | Flavor ID | Size | Role | +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ | cbadc459-f56f-48d1-99a7-94e1d1106bac | MariaDB-105 | mariadb | 10.5 | BUILD | | True | | 0 | 10 | | +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ # if successfully created, status turns to [HEALTHY] [root@dlp ~(keystone)]# openstack database instance list +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- | ID | Name | Datastore | Datastore Version | Status | Operating Status | Public +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- | cbadc459-f56f-48d1-99a7-94e1d1106bac | MariaDB-105 | mariadb | 10.5 | ACTIVE | HEALTHY | True +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | Addresses | Flavor ID | Size | Role | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | [{'address': '192.168.100.119', 'type': 'private', 'network': 'c9c79a1d-136e-4036-8fe0-eaac79f05f5d'}, {'address': '10.0.0.252', 'type': 'public'}] | 0 | 10 | | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ # verify accesses [root@dlp ~(keystone)]# mysql -h 10.0.0.252 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | 45c75500026a | +---------------+--------------+ +--------------------+ | Database | +--------------------+ | MyDB | | information_schema | +--------------------+ # to delete a database instance, do like follows [root@dlp ~(keystone)]# openstack database instance delete MariaDB-105 Request to delete database instance cbadc459-f56f-48d1-99a7-94e1d1106bac has been accepted. |
[4] | This is for the case to create MySQL instance. |
[root@dlp ~(keystone)]# openstack datastore list +--------------------------------------+---------+ | ID | Name | +--------------------------------------+---------+ | 286fa172-a584-431d-8fa2-3701a51ada3c | mysql | | a8e8ab84-260c-4802-97b7-ef62fbe1d689 | mariadb | +--------------------------------------+---------+[root@dlp ~(keystone)]# openstack datastore version list mysql
+--------------------------------------+------+---------+
| ID | Name | Version |
+--------------------------------------+------+---------+
| 0969eac4-9b5a-417d-b321-b3d4ab6e5e8c | 8.0 | 8.0 |
+--------------------------------------+------+---------+
[root@dlp ~(keystone)]# openstack database instance create MySQL-8 \
--flavor 0 \
--size 10 \
--nic net-id=c9c79a1d-136e-4036-8fe0-eaac79f05f5d \
--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
[root@dlp ~(keystone)]# openstack database instance list +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- | ID | Name | Datastore | Datastore Version | Status | Operating Status | Public +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- | 873d3cf4-ef04-48a6-8d08-fd81001ce69d | MySQL-8 | mysql | 8.0 | ACTIVE | HEALTHY | True +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- +----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | Addresses | Flavor ID | Size | Role | +----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | [{'address': '192.168.100.73', 'type': 'private', 'network': 'c9c79a1d-136e-4036-8fe0-eaac79f05f5d'}, {'address': '10.0.0.238', 'type': 'public'}] | 0 | 10 | | +----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+[root@dlp ~(keystone)]# mysql -h 10.0.0.238 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | d5577014f237 | +---------------+--------------+ +--------------------+ | Database | +--------------------+ | MyDB | | information_schema | | performance_schema | +--------------------+ |
Sponsored Link |
|