OpenStack Victoria : How to use Trove2021/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 +-----------+-----------+ +-----------+-----------+ +-----------+-----------+ | [ 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-victoria-guest-ubuntu-bionic.qcow2
[root@dlp ~(keystone)]#
[root@dlp ~(keystone)]# openstack image create Trove-Ubuntu --file=trove-victoria-guest-ubuntu-bionic.qcow2 --disk-format=qcow2 --container-format=bare --tag=trove --private
openstack image list +--------------------------------------+-----------------+--------+ | ID | Name | Status | +--------------------------------------+-----------------+--------+ | 4d7293af-be5b-471b-9507-2a32f1955b11 | CentOS-Stream-8 | active | | b625e80e-14c5-4e67-babc-378f9bf5e819 | Trove-Ubuntu | active | +--------------------------------------+-----------------+--------+[root@dlp ~(keystone)]# openstack volume type create lvm-trove --private +-------------+--------------------------------------+ | Field | Value | +-------------+--------------------------------------+ | description | None | | id | f019a9b4-5f7e-4d86-b9b9-cc38bc84ac61 | | 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 [b625e80e-***], 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.2 mariadb b625e80e-14c5-4e67-babc-378f9bf5e819 mariadb 1" trove Datastore version '10.2' updated. [root@network ~]# su -s /bin/sh -c "trove-manage datastore_version_update mariadb 10.3 mariadb b625e80e-14c5-4e67-babc-378f9bf5e819 mariadb 1" trove Datastore version '10.3' updated. [root@network ~]# su -s /bin/sh -c "trove-manage datastore_version_update postgresql 10 postgresql b625e80e-14c5-4e67-babc-378f9bf5e819 postgresql 1" trove Datastore version '10' updated. [root@network ~]# su -s /bin/sh -c "trove-manage datastore_version_update postgresql 12 postgresql b625e80e-14c5-4e67-babc-378f9bf5e819 postgresql 1" trove Datastore version '12' 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.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/mysql.cloudinit [root@network ~]# 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 | +--------------------------------------+------------+ | 6928b0c6-8b36-48e6-8a87-127b4a412ff8 | postgresql | | 9a7c8915-f11f-49cd-ada5-6f3ddb6bb77d | mariadb | +--------------------------------------+------------+[root@dlp ~(keystone)]# openstack datastore version list mariadb +--------------------------------------+------+ | ID | Name | +--------------------------------------+------+ | fcc41f71-fb87-43bc-bbe2-58455879f60f | 10.2 | | 6e592fb0-de8d-4795-b2a2-65a1e2da6f3e | 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 | +--------------------------------------+----------------+--------------------------------------+------------------+ | 63c29d7b-e870-477d-819b-e5dfe41af1d0 | public-subnet | ea9725cf-a8bc-4eb5-a374-7d7d0e11453c | 10.0.0.0/24 | | 94afb0cc-1d58-4615-8fef-8852271bfc16 | private-subnet | 9f53c3b1-ec6b-499d-854a-588d3b0b96d6 | 192.168.100.0/24 | +--------------------------------------+----------------+--------------------------------------+------------------+[root@dlp ~(keystone)]# openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 9f53c3b1-ec6b-499d-854a-588d3b0b96d6 | private | 94afb0cc-1d58-4615-8fef-8852271bfc16 | | ea9725cf-a8bc-4eb5-a374-7d7d0e11453c | public | 63c29d7b-e870-477d-819b-e5dfe41af1d0 | +--------------------------------------+---------+--------------------------------------+ # create database instance [root@dlp ~(keystone)]# openstack database instance create MariaDB-103 \ --flavor 0 \ --size 10 \ --nic net-id=9f53c3b1-ec6b-499d-854a-588d3b0b96d6 \ --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-03-29T06:44:56 | | datastore | mariadb | | datastore_version | 10.3 | | encrypted_rpc_messaging | True | | flavor | 0 | | id | d4a77738-727b-4555-9619-42a41c53b9eb | | name | MariaDB-103 | | public | True | | region | RegionOne | | server_id | None | | service_status_updated | 2021-03-29T06:44:56 | | status | BUILD | | tenant_id | b9bf51c6436a4c5aa7a2df05688afb49 | | updated | 2021-03-29T06:44:56 | | volume | 10 | | volume_id | None | +-------------------------+--------------------------------------+ # [BUILD] status during creation [root@dlp ~(keystone)]# openstack database instance list +--------------------------------------+-------------+-----------+-------------------+--------+--------+-----------+-----------+------+------+ | ID | Name | Datastore | Datastore Version | Status | Public | Addresses | Flavor ID | Size | Role | +--------------------------------------+-------------+-----------+-------------------+--------+--------+-----------+-----------+------+------+ | d4a77738-727b-4555-9619-42a41c53b9eb | 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 | Public +--------------------------------------+-------------+-----------+-------------------+---------+-------- | d4a77738-727b-4555-9619-42a41c53b9eb | MariaDB-103 | mariadb | 10.3 | HEALTHY | True +--------------------------------------+-------------+-----------+-------------------+---------+-------- +--------------------------------------------------------------------------------------------------+-----------+------+------+ | Addresses | Flavor ID | Size | Role | +--------------------------------------------------------------------------------------------------+-----------+------+------+ | [{'address': '192.168.100.177', 'type': 'private'}, {'address': '10.0.0.224', 'type': 'public'}] | 0 | 10 | | +--------------------------------------------------------------------------------------------------+-----------+------+------+ # verify accesses [root@dlp ~(keystone)]# mysql -h 10.0.0.224 -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.28-MariaDB-1:10.3.28+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 | mariadb-103 | +---------------+-------------+ 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 d4a77738-727b-4555-9619-42a41c53b9eb has been accepted. |
[4] | This is for the case to create PostgreSQL instance. |
[root@dlp ~(keystone)]# openstack datastore list +--------------------------------------+------------+ | ID | Name | +--------------------------------------+------------+ | 6928b0c6-8b36-48e6-8a87-127b4a412ff8 | postgresql | | 9a7c8915-f11f-49cd-ada5-6f3ddb6bb77d | mariadb | +--------------------------------------+------------+[root@dlp ~(keystone)]# openstack datastore version list postgresql
+--------------------------------------+------+
| ID | Name |
+--------------------------------------+------+
| 1847b8b7-7344-4e77-9910-37d79f0cdffc | 10 |
| 708f1c38-3ead-4123-98d0-75181d65c57a | 12 |
+--------------------------------------+------+
[root@dlp ~(keystone)]# openstack database instance create PostgreSQL-12 \
--flavor 0 \
--size 10 \
--nic net-id=9f53c3b1-ec6b-499d-854a-588d3b0b96d6 \
--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-03-29T06:56:36 |
| datastore | postgresql |
| datastore_version | 12 |
| encrypted_rpc_messaging | True |
| flavor | 0 |
| id | cf8eb410-7ed1-47ae-a897-c25d93332124 |
| name | PostgreSQL-12 |
| public | True |
| region | RegionOne |
| server_id | None |
| service_status_updated | 2021-03-29T06:56:36 |
| status | BUILD |
| tenant_id | b9bf51c6436a4c5aa7a2df05688afb49 |
| updated | 2021-03-29T06:56:36 |
| volume | 10 |
| volume_id | None |
+-------------------------+--------------------------------------+
[root@dlp ~(keystone)]# openstack database instance list +--------------------------------------+---------------+------------+-------------------+---------+-------- | ID | Name | Datastore | Datastore Version | Status | Public +--------------------------------------+---------------+------------+-------------------+---------+-------- | cf8eb410-7ed1-47ae-a897-c25d93332124 | PostgreSQL-12 | postgresql | 12 | HEALTHY | True +--------------------------------------+---------------+------------+-------------------+---------+-------- +-------------------------------------------------------------------------------------------------+-----------+------+------+ | Addresses | Flavor ID | Size | Role | +-------------------------------------------------------------------------------------------------+-----------+------+------+ | [{'address': '192.168.100.34', 'type': 'private'}, {'address': '10.0.0.201', 'type': 'public'}] | 0 | 10 | | +-------------------------------------------------------------------------------------------------+-----------+------+------+[root@dlp ~(keystone)]# psql -h 10.0.0.201 -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 |
|