OpenStack Xena : How to use Trove2021/11/25 |
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 +-----------+-----------+ +-----------+-----------+ +-----------+-----------+ | [ Control Node ] | | [ Network Node ] | | [ Compute Node ] | | | | | | | | MariaDB RabbitMQ | | Open vSwitch | | Libvirt | | Memcached httpd | | Neutron Server | | Nova Compute | | Keystone Glance | | OVN-Northd | | Open vSwitch | | Nova API | | Cinder Volume | | OVN Metadata Agent | | Cinder API | | iSCSI Target | | OVN-Controller | | | | Heat API/Engine | | | | | | 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)]# curl -O https://tarballs.opendev.org/openstack/trove/images/trove-master-guest-ubuntu-bionic.qcow2
[root@dlp ~(keystone)]#
[root@dlp ~(keystone)]# openstack image create Trove-Ubuntu --file=trove-master-guest-ubuntu-bionic.qcow2 --disk-format=qcow2 --container-format=bare --tag=trove --private
openstack image list +--------------------------------------+-----------------+--------+ | ID | Name | Status | +--------------------------------------+-----------------+--------+ | cfce605e-151b-43dd-b743-2c7988d69e96 | CentOS-Stream-8 | active | | 9aaec62a-c522-47ef-9924-cc5c804b18e4 | Trove-Ubuntu | active | +--------------------------------------+-----------------+--------+[root@dlp ~(keystone)]# openstack volume type create lvm-trove --private +-------------+--------------------------------------+ | Field | Value | +-------------+--------------------------------------+ | description | None | | id | faa68d41-3b38-4776-affe-7bd47d1251ca | | 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 [9aaec62a-***], that's the image ID of Trove you created in [2] # OK to ignore warning when running commands [root@network ~]# su -s /bin/sh -c "trove-manage datastore_version_update mariadb 10.2 mariadb 9aaec62a-c522-47ef-9924-cc5c804b18e4 mariadb 1" trove Datastore version '10.2' updated. [root@network ~]# su -s /bin/sh -c "trove-manage datastore_version_update mariadb 10.3 mariadb 9aaec62a-c522-47ef-9924-cc5c804b18e4 mariadb 1" trove Datastore version '10.3' updated. [root@network ~]# su -s /bin/sh -c "trove-manage datastore_version_update postgresql 10 postgresql 9aaec62a-c522-47ef-9924-cc5c804b18e4 postgresql 1" trove Datastore version '10' updated. [root@network ~]# su -s /bin/sh -c "trove-manage datastore_version_update postgresql 12 postgresql 9aaec62a-c522-47ef-9924-cc5c804b18e4 postgresql 1" trove Datastore version '12' updated. # add parameters for each version of datastore # OK to ignore warning when running commands [root@network ~]# su -s /bin/bash trove -c "trove-manage db_load_datastore_config_parameters mariadb 10.2 /usr/lib/python3.6/site-packages/trove/templates/mariadb/validation-rules.json" Loading config parameters for datastore (mariadb) version (10.2) [root@network ~]# su -s /bin/bash trove -c "trove-manage db_load_datastore_config_parameters mariadb 10.3 /usr/lib/python3.6/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 postgresql 10 /usr/lib/python3.6/site-packages/trove/templates/postgresql/validation-rules.json" Loading config parameters for datastore (postgresql) version (10) [root@network ~]# su -s /bin/bash trove -c "trove-manage db_load_datastore_config_parameters postgresql 12 /usr/lib/python3.6/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 write_files: - path: /etc/trove/controller.conf content: | CONTROLLER=10.0.0.50 runcmd: - chmod 644 /etc/trove/controller.conf cp /etc/trove/cloudinit/mariadb.cloudinit /etc/trove/cloudinit/postgresql.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 Dockder container inside a VM instance. |
[root@dlp ~(keystone)]# openstack datastore list +--------------------------------------+------------+ | ID | Name | +--------------------------------------+------------+ | 7ccefd35-8eb2-4df4-862e-a345abcb1527 | mariadb | | 917083f0-c85e-4bc2-9784-5e58e51c397e | postgresql | +--------------------------------------+------------+[root@dlp ~(keystone)]# openstack datastore version list mariadb +--------------------------------------+------+---------+ | ID | Name | Version | +--------------------------------------+------+---------+ | f3afb219-f1e0-4540-a658-b1bbdc95455f | 10.2 | 10.2 | | b64d668a-7244-41ff-8c27-a5ddbf82bdb4 | 10.3 | 10.3 | +--------------------------------------+------+---------+[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 subnet list +--------------------------------------+----------------+--------------------------------------+------------------+ | ID | Name | Network | Subnet | +--------------------------------------+----------------+--------------------------------------+------------------+ | 61bf3654-bef1-4ddd-8d23-f2fd41166f4e | public-subnet | ac8911e7-afd7-4913-997e-2f0412f1271b | 10.0.0.0/24 | | 9724f8a3-4c59-4d7d-9838-82bc682a551c | private-subnet | 3adf0a70-6446-4095-916d-17d9f753bbe6 | 192.168.100.0/24 | +--------------------------------------+----------------+--------------------------------------+------------------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 3adf0a70-6446-4095-916d-17d9f753bbe6 | private | 9724f8a3-4c59-4d7d-9838-82bc682a551c | | ac8911e7-afd7-4913-997e-2f0412f1271b | public | 61bf3654-bef1-4ddd-8d23-f2fd41166f4e | +--------------------------------------+---------+--------------------------------------+ # create database instance [root@dlp ~(keystone)]# openstack database instance create MariaDB-103 \ --flavor 0 \ --size 10 \ --nic net-id=3adf0a70-6446-4095-916d-17d9f753bbe6 \ --databases MyDB --users serverworld:password \ --datastore mariadb --datastore-version 10.3 \ --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 | 2021-11-25T02:26:31 | | datastore | mariadb | | datastore_version | 10.3 | | datastore_version_number | 10.3 | | encrypted_rpc_messaging | True | | flavor | 0 | | id | 30adafc1-ccd5-426d-b42a-6e02b9009096 | | name | MariaDB-103 | | operating_status | | | public | True | | region | RegionOne | | server_id | None | | service_status_updated | 2021-11-25T02:26:31 | | status | BUILD | | tenant_id | b12f95625664420ca31949963b75b74f | | updated | 2021-11-25T02:26:31 | | 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 | +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ | 30adafc1-ccd5-426d-b42a-6e02b9009096 | MariaDB-103 | mariadb | 10.3 | 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 +--------------------------------------+-------------+-----------+-------------------+--------+------------------ | 30adafc1-ccd5-426d-b42a-6e02b9009096 | MariaDB-103 | mariadb | 10.3 | ACTIVE | HEALTHY +--------------------------------------+-------------+-----------+-------------------+--------+------------------ +--------+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | Public | Addresses | Flavor ID | Size | Role | +--------+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | True | [{'address': '192.168.100.70', 'type': 'private', 'network': '3adf0a70-6446-4095-916d-17d9f753bbe6'}, {'address': '10.0.0.208', 'type': 'public'}] | 0 | 10 | | +--------+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ # verify accesses [root@dlp ~(keystone)]# mysql -h 10.0.0.208 -u serverworld -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 16 Server version: 10.3.32-MariaDB-1:10.3.32+maria~focal mariadb.org binary distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show variables like 'hostname'; +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | 0c6d397576e0 | +---------------+--------------+ 1 row in set (0.003 sec) MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | MyDB | | information_schema | +--------------------+ 2 rows in set (0.003 sec) MariaDB [(none)]> exit Bye # to delete a database instance, do like follows [root@dlp ~(keystone)]# openstack database instance delete MariaDB-103 Request to delete database instance 30adafc1-ccd5-426d-b42a-6e02b9009096 has been accepted. |
[4] | This is for the case to create PostgreSQL instance. |
[root@dlp ~(keystone)]# openstack datastore list +--------------------------------------+------------+ | ID | Name | +--------------------------------------+------------+ | 7ccefd35-8eb2-4df4-862e-a345abcb1527 | mariadb | | 917083f0-c85e-4bc2-9784-5e58e51c397e | postgresql | +--------------------------------------+------------+[root@dlp ~(keystone)]# openstack datastore version list postgresql
+--------------------------------------+------+---------+
| ID | Name | Version |
+--------------------------------------+------+---------+
| e1e0e514-78ea-4166-8d0b-15f6fc92d9ec | 10 | 10 |
| e84ff018-7540-4f00-96b5-f1ac6b4a313c | 12 | 12 |
+--------------------------------------+------+---------+
[root@dlp ~(keystone)]# openstack database instance create PostgreSQL-12 \
--flavor 0 \
--size 10 \
--nic net-id=3adf0a70-6446-4095-916d-17d9f753bbe6 \
--databases MyDB --users serverworld:password \
--datastore postgresql --datastore-version 12 \
--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 | 2021-11-25T02:32:32 |
| datastore | postgresql |
| datastore_version | 12 |
| datastore_version_number | 12 |
| encrypted_rpc_messaging | True |
| flavor | 0 |
| id | 3a2783e1-3bc2-401d-ba2f-309c99821dd6 |
| name | PostgreSQL-12 |
| operating_status | |
| public | True |
| region | RegionOne |
| server_id | None |
| service_status_updated | 2021-11-25T02:32:32 |
| status | BUILD |
| tenant_id | b12f95625664420ca31949963b75b74f |
| updated | 2021-11-25T02:32:32 |
| volume | 10 |
| volume_id | None |
+--------------------------+--------------------------------------+
[root@dlp ~(keystone)]# openstack database instance list +--------------------------------------+---------------+------------+-------------------+--------+------------------ | ID | Name | Datastore | Datastore Version | Status | Operating Status +--------------------------------------+---------------+------------+-------------------+--------+------------------ | 3a2783e1-3bc2-401d-ba2f-309c99821dd6 | PostgreSQL-12 | postgresql | 12 | ACTIVE | HEALTHY +--------------------------------------+---------------+------------+-------------------+--------+------------------ +--------+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | Public | Addresses | Flavor ID | Size | Role | +--------+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | True | [{'address': '192.168.100.33', 'type': 'private', 'network': '3adf0a70-6446-4095-916d-17d9f753bbe6'}, {'address': '10.0.0.211', 'type': 'public'}] | 0 | 10 | | +--------+----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+[root@dlp ~(keystone)]# psql -h 10.0.0.211 -d MyDB -U serverworld -c "SELECT version();" Password for user serverworld: version ------------------------------------------------------------------------------------------------------------------ PostgreSQL 12.6 (Debian 12.6-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit (1 row) |
Sponsored Link |