Ubuntu 20.04
Sponsored Link

OpenStack Victoria : How to use Trove2020/10/27

 
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  |   |      Linux Bridge     |   |        Libvirt        |
|  Memcached  httpd     |   |   L2 Agent L3 Agent   |   |     Nova Compute      |
|  Keystone   Glance    |   |     Metadata Agent    |   |      Linux Bridge     |
|  Nova API  Cinder API |   |     Cinder Volume     |   |        L2 Agent       |
|  Neutron Server       |   |        Heat API       |   |                       |
|  Metadata Agent       |   |      Heat Engine      |   |                       |
|                       |   |    Trove Services     |   |                       |
+-----------------------+   +-----------------------+   +-----------------------+

[1]
Create a VM image for Trove on the Node Trove API is running. (it's Network Node on this example)
It needs to satisfy requiremetns below when creating.
* The working user is an common user, not root user, and also he can use root privilege with [sudo].
* The working username and the username you specify for ${guest_username} below must be the same name. (it's [ubuntu] on this example)
* The directory you execute [git clone] below must be the own home directory.
ubuntu@network:~$
git clone https://opendev.org/openstack/trove

ubuntu@network:~$
cd trove/integration/scripts
# trovestack build-image ${guest_os} ${guest_os_release} ${dev_mode} ${guest_username} ${output_image_path}

# if not specify args at all, following default values are set

ubuntu@network:~/trove/integration/scripts$
./trovestack build-image ubuntu bionic true ubuntu

*******************************************************************************
Params for cmd_build_image function: ubuntu bionic true ubuntu
*******************************************************************************
[sudo] password for ubuntu:
Ensuring we have all packages needed to build image.
.....
.....
2020-10-27 05:16:52.279 | Build completed successfully
*******************************************************************************
Image /home/ubuntu/images/trove-guest-ubuntu-bionic-dev.qcow2 was built successfully.
*******************************************************************************
[2] Copy the VM image created in [1] to a Node Openstack's [admin] user can authenticate and add it to Glance.
Also Create a Cinder volume type configured in [trove.conf].
root@dlp ~(keystone)#
openstack image create Trove-Ubuntu --file=trove-guest-ubuntu-bionic-dev.qcow2 --disk-format=qcow2 --container-format=bare --tag=trove --private
root@dlp ~(keystone)#
openstack image list

+--------------------------------------+--------------+--------+
| ID                                   | Name         | Status |
+--------------------------------------+--------------+--------+
| 6c287889-9a1c-4f24-bb2f-f7e786fcf677 | Trove-Ubuntu | active |
| 7ba71e53-e270-4d2a-bbe9-0d642a6c019c | Ubuntu2004   | active |
+--------------------------------------+--------------+--------+

root@dlp ~(keystone)#
openstack volume type create lvm-trove --private

+-------------+--------------------------------------+
| Field       | Value                                |
+-------------+--------------------------------------+
| description | None                                 |
| id          | 70494ce9-0c45-4585-a523-65e139943a6f |
| is_public   | False                                |
| name        | lvm-trove                            |
+-------------+--------------------------------------+
[3] 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, 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 mysql ''"

Datastore 'mysql' updated.
root@network:~#
su -s /bin/bash trove -c "trove-manage datastore_update postgresql ''"

Datastore 'postgresql' updated.
# add versions for each datastore

# for [6c287889-***], 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 6c287889-9a1c-4f24-bb2f-f7e786fcf677 mariadb 1" trove

Datastore version '10.2' updated.
root@network:~#
su -s /bin/sh -c "trove-manage datastore_version_update mariadb 10.3 mariadb 6c287889-9a1c-4f24-bb2f-f7e786fcf677 mariadb 1" trove

Datastore version '10.3' updated.
root@network:~#
su -s /bin/sh -c "trove-manage datastore_version_update mysql 5.7 mysql 6c287889-9a1c-4f24-bb2f-f7e786fcf677 mysql 1" trove

Datastore version '5.7' updated.
root@network:~#
su -s /bin/sh -c "trove-manage datastore_version_update postgresql 10 postgresql 6c287889-9a1c-4f24-bb2f-f7e786fcf677 postgresql 1" trove

Datastore version '10' updated.
root@network:~#
su -s /bin/sh -c "trove-manage datastore_version_update postgresql 12 postgresql 6c287889-9a1c-4f24-bb2f-f7e786fcf677 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/dist-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/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 mysql 5.7 /usr/lib/python3/dist-packages/trove/templates/mysql/validation-rules.json"

Loading config parameters for datastore (mysql) version (5.7)
root@network:~#
su -s /bin/bash trove -c "trove-manage db_load_datastore_config_parameters postgresql 10 /usr/lib/python3/dist-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/dist-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

root@network:~#
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

[4] 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       |
+--------------------------------------+------------+
| a9241925-b246-4462-bd4c-859c347e3833 | postgresql |
| ae93dd0e-4ead-403f-a14e-8d317e19f9cd | mysql      |
| bf97a535-8e29-49b4-b4e4-8ea4ea6f6c9a | mariadb    |
+--------------------------------------+------------+

root@dlp ~(keystone)#
openstack datastore version list mariadb

+--------------------------------------+------+
| ID                                   | Name |
+--------------------------------------+------+
| 72bac071-d80c-411b-9e86-b4a2d56070f9 | 10.2 |
| e2a37f93-0d21-405b-b360-4dfc79fc38dc | 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           |
+--------------------------------------+----------------+--------------------------------------+------------------+
| 7aa5fca7-efe4-4a30-b1f0-0653cc743a1c | public-subnet  | 5d7b1b73-602d-40e2-a82f-352991de37e0 | 10.0.0.0/24      |
| e7e82cb2-29c0-4eea-a459-e212a2bc3650 | private-subnet | 9f39959f-2f70-400c-aa80-5de54e92cf27 | 192.168.100.0/24 |
+--------------------------------------+----------------+--------------------------------------+------------------+

root@dlp ~(keystone)#
openstack network list

+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 5d7b1b73-602d-40e2-a82f-352991de37e0 | public  | 7aa5fca7-efe4-4a30-b1f0-0653cc743a1c |
| 9f39959f-2f70-400c-aa80-5de54e92cf27 | private | e7e82cb2-29c0-4eea-a459-e212a2bc3650 |
+--------------------------------------+---------+--------------------------------------+

# create database instance
root@dlp ~(keystone)# openstack database instance create MariaDB-103 \
--flavor 0 \
--size 10 \
--nic net-id=9f39959f-2f70-400c-aa80-5de54e92cf27 \
--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                 | 2020-10-28T00:50:45                  |
| datastore               | mariadb                              |
| datastore_version       | 10.3                                 |
| encrypted_rpc_messaging | True                                 |
| flavor                  | 0                                    |
| id                      | 75817dd0-d6dd-41cf-8623-99447a97cdc0 |
| name                    | MariaDB-103                          |
| public                  | True                                 |
| region                  | RegionOne                            |
| server_id               | None                                 |
| service_status_updated  | 2020-10-28T00:50:45                  |
| status                  | BUILD                                |
| tenant_id               | b573c9e160864f028fc2d681a929f5af     |
| updated                 | 2020-10-28T00:50:45                  |
| 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 |
+--------------------------------------+-------------+-----------+-------------------+--------+--------+-----------+-----------+------+------+
| 75817dd0-d6dd-41cf-8623-99447a97cdc0 | 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 
+--------------------------------------+-------------+-----------+-------------------+---------+--------
| 75817dd0-d6dd-41cf-8623-99447a97cdc0 | MariaDB-103 | mariadb   | 10.3              | HEALTHY | True   
+--------------------------------------+-------------+-----------+-------------------+---------+--------
+--------------------------------------------------------------------------------------------------+-----------+------+------+
| Addresses                                                                                        | Flavor ID | Size | Role |
+--------------------------------------------------------------------------------------------------+-----------+------+------+
| [{'address': '192.168.100.183', 'type': 'private'}, {'address': '10.0.0.239', 'type': 'public'}] | 0         |   10 |      |
+--------------------------------------------------------------------------------------------------+-----------+------+------+

# verify accesses

root@dlp ~(keystone)#
mysql -h 10.0.0.239 -u serverworld -p

Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 10.3.25-MariaDB-1:10.3.25+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 75817dd0-d6dd-41cf-8623-99447a97cdc0 has been accepted.
[5] This is for the case to create MySQL instance.
root@dlp ~(keystone)#
openstack datastore list

+--------------------------------------+------------+
| ID                                   | Name       |
+--------------------------------------+------------+
| a9241925-b246-4462-bd4c-859c347e3833 | postgresql |
| ae93dd0e-4ead-403f-a14e-8d317e19f9cd | mysql      |
| bf97a535-8e29-49b4-b4e4-8ea4ea6f6c9a | mariadb    |
+--------------------------------------+------------+

root@dlp ~(keystone)#
openstack datastore version list mysql

+--------------------------------------+------+
| ID                                   | Name |
+--------------------------------------+------+
| 0acb7e6b-247d-48dc-a38b-d1b79d6bff19 | 5.7  |
+--------------------------------------+------+

root@dlp ~(keystone)# openstack database instance create MySQL-57 \
--flavor 0 \
--size 10 \
--nic net-id=9f39959f-2f70-400c-aa80-5de54e92cf27 \
--databases MyDB --users serverworld:password \
--datastore mysql --datastore-version 5.7 \
--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  | Public 
+--------------------------------------+----------+-----------+-------------------+---------+--------
| 708ccbfd-09c5-4f55-b571-04f20925adba | MySQL-57 | mysql     | 5.7               | HEALTHY | True   
+--------------------------------------+----------+-----------+-------------------+---------+--------
+------------------------------------------------------------------------------------------------+-----------+------+------+
| Addresses                                                                                      | Flavor ID | Size | Role |
+------------------------------------------------------------------------------------------------+-----------+------+------+
| [{'address': '192.168.100.7', 'type': 'private'}, {'address': '10.0.0.245', 'type': 'public'}] | 0         |   10 |      |
+------------------------------------------------------------------------------------------------+-----------+------+------+

root@dlp ~(keystone)#
mysql -h 10.0.0.245 -u serverworld -p -e "show variables like 'version';"

Enter password:
+---------------+--------+
| Variable_name | Value  |
+---------------+--------+
| version       | 5.7.32 |
+---------------+--------+
[6] This is for the case to create PostgreSQL instance.
root@dlp ~(keystone)#
openstack datastore list

+--------------------------------------+------------+
| ID                                   | Name       |
+--------------------------------------+------------+
| a9241925-b246-4462-bd4c-859c347e3833 | postgresql |
| ae93dd0e-4ead-403f-a14e-8d317e19f9cd | mysql      |
| bf97a535-8e29-49b4-b4e4-8ea4ea6f6c9a | mariadb    |
+--------------------------------------+------------+

root@dlp ~(keystone)#
openstack datastore version list postgresql

+--------------------------------------+------+
| ID                                   | Name |
+--------------------------------------+------+
| 43c0bad3-d384-419c-b9d8-f81a7149de5f | 10   |
| 5a0c7b53-a3d0-4b2c-b8e0-f558b545e2a0 | 12   |
+--------------------------------------+------+

root@dlp ~(keystone)# openstack database instance create PostgreSQL-12 \
--flavor 0 \
--size 10 \
--nic net-id=9f39959f-2f70-400c-aa80-5de54e92cf27 \
--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 

root@dlp ~(keystone)#
openstack database instance list

+--------------------------------------+---------------+------------+-------------------+---------+--------
| ID                                   | Name          | Datastore  | Datastore Version | Status  | Public 
+--------------------------------------+---------------+------------+-------------------+---------+--------
| 87263bee-57ad-45ed-b2f2-096348e53e39 | PostgreSQL-12 | postgresql | 12                | HEALTHY | True   
+--------------------------------------+---------------+------------+-------------------+---------+--------
+--------------------------------------------------------------------------------------------------+-----------+------+------+
| Addresses                                                                                        | Flavor ID | Size | Role |
+--------------------------------------------------------------------------------------------------+-----------+------+------+
| [{'address': '192.168.100.216', 'type': 'private'}, {'address': '10.0.0.238', 'type': 'public'}] | 0         |   10 |      |
+--------------------------------------------------------------------------------------------------+-----------+------+------+

root@dlp ~(keystone)#
psql -h 10.0.0.238 -d MyDB -U serverworld -c "SELECT version();"

Password for user serverworld:
                                                     version
------------------------------------------------------------------------------------------------------------------
 PostgreSQL 12.4 (Debian 12.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
(1 row)
Matched Content