OpenStack Zed : Trove 利用方法2022/11/14 |
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 | +--------------------------------------+----------------+--------+ | 8367cc21-61f4-480b-8d03-90c057c7a7cf | CentOS-Stream9 | active | | 2cf4cbc8-e58b-44c4-8849-e3e39d7c4e45 | Trove-Ubuntu | active | +--------------------------------------+----------------+--------+[root@dlp ~(keystone)]# openstack volume type create lvm-trove --private +-------------+--------------------------------------+ | Field | Value | +-------------+--------------------------------------+ | description | None | | id | 765b4b10-f6b2-48c6-8b8d-521c23197437 | | 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. # 各データストアのバージョンを登録 # [2cf4cbc8-***] の部分は [2] で作成した Trove 用のイメージ ID [root@network ~]# su -s /bin/sh -c "trove-manage datastore_version_update mariadb 10.3 mariadb 2cf4cbc8-e58b-44c4-8849-e3e39d7c4e45 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 2cf4cbc8-e58b-44c4-8849-e3e39d7c4e45 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 2cf4cbc8-e58b-44c4-8849-e3e39d7c4e45 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.9/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 mariadb 10.5 /usr/lib/python3.9/site-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.9/site-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] | 任意のノードで、データベースインスタンスを作成します。 例として、[admin] ユーザーで MariaDB データベースインスタンスを作成します。 (デフォルトポリシーでは [admin] ユーザーのみがインスタンス作成可) ちなみに、データベースインスタンスは VM イメージ上で Docker コンテナーとして起動します。 |
[root@dlp ~(keystone)]# openstack datastore list +--------------------------------------+---------+ | ID | Name | +--------------------------------------+---------+ | 286fa172-a584-431d-8fa2-3701a51ada3c | mysql | | a8e8ab84-260c-4802-97b7-ef62fbe1d689 | mariadb | +--------------------------------------+---------+[root@dlp ~(keystone)]# openstack datastore version list mariadb +--------------------------------------+------+---------+ | ID | Name | Version | +--------------------------------------+------+---------+ | 467968e8-0710-471b-aaa0-13905cf9d199 | 10.3 | 10.3 | | 4e1411dc-25b2-4360-a90c-9554b1093161 | 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 | +--------------------------------------+---------+--------------------------------------+ | 004ca400-3d79-4c1b-b8fb-bba1e273000e | public | 80213093-ac95-469a-b4d9-8c6adc93cfe1 | | c9c79a1d-136e-4036-8fe0-eaac79f05f5d | private | 85e66c6a-66eb-490f-a4fa-e21f91678c89 | +--------------------------------------+---------+--------------------------------------+ # データベースインスタンス作成 [root@dlp ~(keystone)]# openstack database instance create MariaDB-105 \ --flavor 0 \ --size 10 \ --nic net-id=c9c79a1d-136e-4036-8fe0-eaac79f05f5d \ --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-11-14T07:10:14 | | datastore | mariadb | | datastore_version | 10.5 | | datastore_version_number | 10.5 | | encrypted_rpc_messaging | True | | flavor | 0 | | id | cbadc459-f56f-48d1-99a7-94e1d1106bac | | name | MariaDB-105 | | operating_status | | | public | True | | region | RegionOne | | server_id | None | | service_status_updated | 2022-11-14T07:10:14 | | status | BUILD | | tenant_id | 939974d6fc8e400eb01f7dd749935ea3 | | updated | 2022-11-14T07:10:14 | | volume | 10 | | volume_id | None | +--------------------------+--------------------------------------+ # 作成中は [BUILD] ステータス [root@dlp ~(keystone)]# openstack database instance list +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ | ID | Name | Datastore | Datastore Version | Status | Operating Status | Public | Addresses | Flavor ID | Size | Role | +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ | cbadc459-f56f-48d1-99a7-94e1d1106bac | MariaDB-105 | mariadb | 10.5 | BUILD | | True | | 0 | 10 | | +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ # 作成が正常に完了すると [HEALTHY] ステータス [root@dlp ~(keystone)]# openstack database instance list +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- | ID | Name | Datastore | Datastore Version | Status | Operating Status | Public +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- | cbadc459-f56f-48d1-99a7-94e1d1106bac | MariaDB-105 | mariadb | 10.5 | ACTIVE | HEALTHY | True +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | Addresses | Flavor ID | Size | Role | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | [{'address': '192.168.100.119', 'type': 'private', 'network': 'c9c79a1d-136e-4036-8fe0-eaac79f05f5d'}, {'address': '10.0.0.252', 'type': 'public'}] | 0 | 10 | | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ # アクセスして動作確認 [root@dlp ~(keystone)]# mysql -h 10.0.0.252 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | 45c75500026a | +---------------+--------------+ +--------------------+ | Database | +--------------------+ | MyDB | | information_schema | +--------------------+ # データベースインスタンスを削除する場合は以下 [root@dlp ~(keystone)]# openstack database instance delete MariaDB-105 Request to delete database instance cbadc459-f56f-48d1-99a7-94e1d1106bac has been accepted. |
[4] | MySQL を起動する場合の設定です。 |
[root@dlp ~(keystone)]# openstack datastore list +--------------------------------------+---------+ | ID | Name | +--------------------------------------+---------+ | 286fa172-a584-431d-8fa2-3701a51ada3c | mysql | | a8e8ab84-260c-4802-97b7-ef62fbe1d689 | mariadb | +--------------------------------------+---------+[root@dlp ~(keystone)]# openstack datastore version list mysql
+--------------------------------------+------+---------+
| ID | Name | Version |
+--------------------------------------+------+---------+
| 0969eac4-9b5a-417d-b321-b3d4ab6e5e8c | 8.0 | 8.0 |
+--------------------------------------+------+---------+
[root@dlp ~(keystone)]# openstack database instance create MySQL-8 \
--flavor 0 \
--size 10 \
--nic net-id=c9c79a1d-136e-4036-8fe0-eaac79f05f5d \
--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 +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- | 873d3cf4-ef04-48a6-8d08-fd81001ce69d | MySQL-8 | mysql | 8.0 | ACTIVE | HEALTHY | True +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- +----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | Addresses | Flavor ID | Size | Role | +----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | [{'address': '192.168.100.73', 'type': 'private', 'network': 'c9c79a1d-136e-4036-8fe0-eaac79f05f5d'}, {'address': '10.0.0.238', 'type': 'public'}] | 0 | 10 | | +----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+[root@dlp ~(keystone)]# mysql -h 10.0.0.238 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | d5577014f237 | +---------------+--------------+ +--------------------+ | Database | +--------------------+ | MyDB | | information_schema | | performance_schema | +--------------------+ |
Sponsored Link |