OpenStack Zed : How to use Trove2022/10/12 |
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 | +--------------------------------------+--------------+--------+ | 13992db5-8056-4d23-8411-15403d0cd5b8 | Trove-Ubuntu | active | | 126bc335-fc00-478d-b84a-a9e79eba2574 | Ubuntu2204 | active | +--------------------------------------+--------------+--------+[root@dlp ~(keystone)]# openstack volume type create lvm-trove --private +-------------+--------------------------------------+ | Field | Value | +-------------+--------------------------------------+ | description | None | | id | 2059cde5-9f29-4c53-8f3f-c234176d4ad2 | | 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 [13992db5-***], 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 13992db5-8056-4d23-8411-15403d0cd5b8 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 13992db5-8056-4d23-8411-15403d0cd5b8 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 13992db5-8056-4d23-8411-15403d0cd5b8 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 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 | +--------------------------------------+------------+ | 249f318b-e209-44b4-a24a-d320dc38a1d3 | mysql | | 2d921feb-319b-4dac-aaa3-4e814ef2b9c6 | mariadb | +--------------------------------------+------------+root@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 | +--------------------------------------+------+---------+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 | +--------------------------------------+---------+--------------------------------------+ | 394ec727-7e9a-473e-8068-45aa841a9ac2 | public | ea6cb6cb-74ed-4007-bd25-b3fb84111e84 | | 7336a271-bec9-4d33-8dc5-e9f3a9892ed7 | private | a454cf3e-fef5-46f6-8468-4a26cbd14983 | +--------------------------------------+---------+--------------------------------------+ # create database instance root@dlp ~(keystone)# openstack database instance create MariaDB-105 \ --flavor 0 \ --size 10 \ --nic net-id=7336a271-bec9-4d33-8dc5-e9f3a9892ed7 \ --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-10-12T06:16:45 | | datastore | mariadb | | datastore_version | 10.5 | | datastore_version_number | 10.5 | | encrypted_rpc_messaging | True | | flavor | 0 | | id | 6f5a4b8a-b9b1-4c3c-bcdf-52a0e9993c5d | | name | MariaDB-105 | | operating_status | | | public | True | | region | RegionOne | | server_id | None | | service_status_updated | 2022-10-12T06:16:45 | | status | BUILD | | tenant_id | 231a529f51394426b07c56f2c5ec580e | | updated | 2022-10-12T06:16:45 | | 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 | +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ | 6f5a4b8a-b9b1-4c3c-bcdf-52a0e9993c5d | 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 +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- | 6f5a4b8a-b9b1-4c3c-bcdf-52a0e9993c5d | MariaDB-105 | mariadb | 10.5 | ACTIVE | HEALTHY | True +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | Addresses | Flavor ID | Size | Role | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | [{'address': '192.168.100.199', 'type': 'private', 'network': '7336a271-bec9-4d33-8dc5-e9f3a9892ed7'}, {'address': '10.0.0.231', 'type': 'public'}] | 0 | 10 | | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ # verify accesses root@dlp ~(keystone)# mysql -h 10.0.0.231 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | 8ea041de4188 | +---------------+--------------+ +--------------------+ | 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 6f5a4b8a-b9b1-4c3c-bcdf-52a0e9993c5d has been accepted. |
[4] | This is for the case to create MySQL instance. |
root@dlp ~(keystone)# openstack datastore list +--------------------------------------+------------+ | ID | Name | +--------------------------------------+------------+ | 249f318b-e209-44b4-a24a-d320dc38a1d3 | mysql | | 2d921feb-319b-4dac-aaa3-4e814ef2b9c6 | mariadb | +--------------------------------------+------------+root@dlp ~(keystone)# openstack datastore version list mysql
+--------------------------------------+------+---------+
| ID | Name | Version |
+--------------------------------------+------+---------+
| d3ba7a2b-851e-4f58-8a80-4e830ce5b635 | 8.0 | 8.0 |
+--------------------------------------+------+---------+
root@dlp ~(keystone)# openstack database instance create MySQL-8 \
--flavor 0 \
--size 10 \
--nic net-id=7336a271-bec9-4d33-8dc5-e9f3a9892ed7 \
--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 +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- | 41590807-86f5-4d8e-99f6-3a8904fca8c4 | MySQL-8 | mysql | 8.0 | ACTIVE | HEALTHY | True +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | Addresses | Flavor ID | Size | Role | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | [{'address': '192.168.100.216', 'type': 'private', 'network': '7336a271-bec9-4d33-8dc5-e9f3a9892ed7'}, {'address': '10.0.0.215', 'type': 'public'}] | 0 | 10 | | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+root@dlp ~(keystone)# mysql -h 10.0.0.215 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | 8d51d5837578 | +---------------+--------------+ +--------------------+ | Database | +--------------------+ | MyDB | | information_schema | | performance_schema | +--------------------+ |
Sponsored Link |
|