OpenStack Antelope : Trove 利用方法2023/03/29 |
OpenStack Database Service(Trove)の利用方法です。
当例では以下のような環境を例に Trove をインストールしています。
------------+--------------------------+--------------------------+------------ | | | 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] | Trove 用の VM イメージを公式サイトからダウンロードして Glance に登録します。 また、[trove.conf] で [cinder_volume_type] に設定したボリュームタイプを作成しておきます。 |
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 | +--------------------------------------+--------------+--------+ | de2d8750-dbd6-4b97-aa28-a920a2309718 | Trove-Ubuntu | active | | 00ea6e97-0e97-4cb4-8ac4-2409c28f0289 | Ubuntu2204 | active | +--------------------------------------+--------------+--------+[root@dlp ~(keystone)]# openstack volume type create lvm-trove --private +-------------+--------------------------------------+ | Field | Value | +-------------+--------------------------------------+ | description | None | | id | c0913e9c-285a-42e9-93a9-32d68b50c866 | | is_public | False | | name | lvm-trove | +-------------+--------------------------------------+ |
[2] | Trove API が稼働するノード (当例では Network ノード) で、使用したいデータストアを登録しておきます。 当例では、MariaDB, MySQL をデータストアとして登録します。 |
# データストア登録 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. # 各データストアのバージョンを登録 # [de2d8750-***] の部分は [2] で作成した Trove 用のイメージ ID root@network:~# su -s /bin/sh -c "trove-manage datastore_version_update mariadb 10.3 mariadb de2d8750-dbd6-4b97-aa28-a920a2309718 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 de2d8750-dbd6-4b97-aa28-a920a2309718 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 de2d8750-dbd6-4b97-aa28-a920a2309718 mysql 1" trove Datastore version '8.0(8.0)' updated. # 各データストアのバージョン用の設定パラメーターを登録 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) # VM イメージ用の [cloudinit] ファイル作成 root@network:~# mkdir /etc/trove/cloudinit
root@network:~#
vi /etc/trove/cloudinit/mariadb.cloudinit # 新規作成 # [CONTROLLER] に Trove API ホストを指定 #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] | Openstack システムを利用可能な任意のユーザーで認証して、任意のノードで、データベースインスタンスを作成します。 ちなみに、データベースインスタンスは VM イメージ上で Docker コンテナーとして起動します。 |
ubuntu@dlp ~(keystone)$ openstack datastore list +--------------------------------------+------------+ | ID | Name | +--------------------------------------+------------+ | 6efdd4f6-9532-4f61-8ff8-c90c5c351e1e | mariadb | | fa217b97-6598-4586-8200-14f899689c0b | mysql | +--------------------------------------+------------+ubuntu@dlp ~(keystone)$ openstack datastore version list mariadb +--------------------------------------+------+---------+ | ID | Name | Version | +--------------------------------------+------+---------+ | 9977c6e7-29ef-4a1f-a870-e7fce996c734 | 10.3 | 10.3 | | c24bacc9-5571-4a23-9979-c819b2c701b4 | 10.5 | 10.5 | +--------------------------------------+------+---------+ubuntu@dlp ~(keystone)$ openstack flavor list +----+-----------+------+------+-----------+-------+-----------+ | ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public | +----+-----------+------+------+-----------+-------+-----------+ | 1 | m1.small | 2048 | 10 | 0 | 1 | True | | 2 | m1.medium | 4096 | 10 | 0 | 2 | True | | 3 | m1.large | 8192 | 20 | 10 | 4 | True | +----+-----------+------+------+-----------+-------+-----------+ubuntu@dlp ~(keystone)$ openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | 5352e6c0-47b3-4df2-84f4-ca048f141e1d | public | ca5539a8-0291-4684-9fb3-0f448efacebf | | ce6e88bc-107a-446b-b2ab-255bab7269fe | private | feb337ec-215e-406e-8871-196fed2c4207 | +--------------------------------------+---------+--------------------------------------+ # データベースインスタンス作成 ubuntu@dlp ~(keystone)$ openstack database instance create MariaDB-105 \ --flavor 2 \ --size 10 \ --nic net-id=ce6e88bc-107a-446b-b2ab-255bab7269fe \ --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 | 2023-03-29T06:03:27 | | datastore | mariadb | | datastore_version | 10.5 | | datastore_version_number | 10.5 | | flavor | 2 | | id | efc1853a-a72d-4194-b6a0-bf89155d6a91 | | name | MariaDB-105 | | operating_status | | | public | True | | region | RegionOne | | service_status_updated | 2023-03-29T06:03:27 | | status | BUILD | | updated | 2023-03-29T06:03:27 | | volume | 10 | +--------------------------+--------------------------------------+ # 作成中は [BUILD] ステータス ubuntu@dlp ~(keystone)$ openstack database instance list +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ | ID | Name | Datastore | Datastore Version | Status | Operating Status | Public | Addresses | Flavor ID | Size | Role | +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ | efc1853a-a72d-4194-b6a0-bf89155d6a91 | MariaDB-105 | mariadb | 10.5 | BUILD | | True | | 2 | 10 | | +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ # 作成が正常に完了すると [HEALTHY] ステータス ubuntu@dlp ~(keystone)$ openstack database instance list +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- | ID | Name | Datastore | Datastore Version | Status | Operating Status | Public +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- | efc1853a-a72d-4194-b6a0-bf89155d6a91 | MariaDB-105 | mariadb | 10.5 | ACTIVE | HEALTHY | True +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- +----------------------------------------------------------------------------------------------------------------------------------------------------- | Addresses +----------------------------------------------------------------------------------------------------------------------------------------------------- | [{'address': '192.168.100.112', 'type': 'private', 'network': 'ce6e88bc-107a-446b-b2ab-255bab7269fe'}, {'address': '10.0.0.246', 'type': 'public'}] +----------------------------------------------------------------------------------------------------------------------------------------------------- +-----------+------+------+ | Flavor ID | Size | Role | +-----------+------+------+ | 2 | 10 | | +-----------+------+------+ # アクセスして動作確認 ubuntu@dlp ~(keystone)$ mysql -h 10.0.0.246 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | 0803075444c4 | +---------------+--------------+ +--------------------+ | Database | +--------------------+ | MyDB | | information_schema | +--------------------+ # データベースインスタンスを削除する場合は以下 ubuntu@dlp ~(keystone)$ openstack database instance delete MariaDB-105 Request to delete database instance efc1853a-a72d-4194-b6a0-bf89155d6a91 has been accepted. |
[4] | MySQL を起動する場合の設定です。 |
ubuntu@dlp ~(keystone)$ openstack datastore list +--------------------------------------+------------+ | ID | Name | +--------------------------------------+------------+ | 6efdd4f6-9532-4f61-8ff8-c90c5c351e1e | mariadb | | fa217b97-6598-4586-8200-14f899689c0b | mysql | +--------------------------------------+------------+ubuntu@dlp ~(keystone)$ openstack datastore version list mysql
+--------------------------------------+------+---------+
| ID | Name | Version |
+--------------------------------------+------+---------+
| cb2f2cbf-5813-4a60-a2fa-bf075ee97b7b | 8.0 | 8.0 |
+--------------------------------------+------+---------+
ubuntu@dlp ~(keystone)$ openstack database instance create MySQL-8 \
--flavor 2 \
--size 10 \
--nic net-id=ce6e88bc-107a-446b-b2ab-255bab7269fe \
--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
ubuntu@dlp ~(keystone)$ openstack database instance list +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- | ID | Name | Datastore | Datastore Version | Status | Operating Status | Public +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- | c8a2a186-1cbe-4d2a-88a5-90b634dbf522 | MySQL-8 | mysql | 8.0 | ACTIVE | HEALTHY | True +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- +----------------------------------------------------------------------------------------------------------------------------------------------------- | Addresses +----------------------------------------------------------------------------------------------------------------------------------------------------- | [{'address': '192.168.100.150', 'type': 'private', 'network': 'ce6e88bc-107a-446b-b2ab-255bab7269fe'}, {'address': '10.0.0.216', 'type': 'public'}] +----------------------------------------------------------------------------------------------------------------------------------------------------- +-----------+------+------+ | Flavor ID | Size | Role | +-----------+------+------+ | 2 | 10 | | +-----------+------+------+ubuntu@dlp ~(keystone)$ mysql -h 10.0.0.216 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | 87e615253fcb | +---------------+--------------+ +--------------------+ | Database | +--------------------+ | MyDB | | information_schema | | performance_schema | +--------------------+ |
Sponsored Link |
|