OpenStack Zed : Trove 利用方法2022/10/12 |
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 | +--------------------------------------+--------------+--------+ | 13992db5-8056-4d23-8411-15403d0cd5b8 | Trove-Ubuntu | active | | 126bc335-fc00-478d-b84a-a9e79eba2574 | Ubuntu2204 | active | +--------------------------------------+--------------+--------+[root@dlp ~(keystone)]# openstack volume type create lvm-trove --private +-------------+--------------------------------------+ | Field | Value | +-------------+--------------------------------------+ | description | None | | id | 2059cde5-9f29-4c53-8f3f-c234176d4ad2 | | 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. # 各データストアのバージョンを登録 # [13992db5-***] の部分は [2] で作成した Trove 用のイメージ ID root@network:~# su -s /bin/sh -c "trove-manage datastore_version_update mariadb 10.3 mariadb 13992db5-8056-4d23-8411-15403d0cd5b8 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 13992db5-8056-4d23-8411-15403d0cd5b8 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 13992db5-8056-4d23-8411-15403d0cd5b8 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] | 任意のノードで、データベースインスタンスを作成します。 例として、[admin] ユーザーで MariaDB データベースインスタンスを作成します。 (デフォルトポリシーでは [admin] ユーザーのみがインスタンス作成可) ちなみに、データベースインスタンスは VM イメージ上で Docker コンテナーとして起動します。 |
root@dlp ~(keystone)# openstack datastore list +--------------------------------------+------------+ | ID | Name | +--------------------------------------+------------+ | 249f318b-e209-44b4-a24a-d320dc38a1d3 | mysql | | 2d921feb-319b-4dac-aaa3-4e814ef2b9c6 | mariadb | +--------------------------------------+------------+root@dlp ~(keystone)# openstack datastore version list mariadb +--------------------------------------+------+---------+ | ID | Name | Version | +--------------------------------------+------+---------+ | e6e070a8-39e8-4366-8126-163399b573b7 | 10.3 | 10.3 | | 0c2c0c0d-e0a4-444b-91d5-1c002a7dc75d | 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 | +--------------------------------------+---------+--------------------------------------+ | 394ec727-7e9a-473e-8068-45aa841a9ac2 | public | ea6cb6cb-74ed-4007-bd25-b3fb84111e84 | | 7336a271-bec9-4d33-8dc5-e9f3a9892ed7 | private | a454cf3e-fef5-46f6-8468-4a26cbd14983 | +--------------------------------------+---------+--------------------------------------+ # データベースインスタンス作成 root@dlp ~(keystone)# openstack database instance create MariaDB-105 \ --flavor 0 \ --size 10 \ --nic net-id=7336a271-bec9-4d33-8dc5-e9f3a9892ed7 \ --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-10-12T06:16:45 | | datastore | mariadb | | datastore_version | 10.5 | | datastore_version_number | 10.5 | | encrypted_rpc_messaging | True | | flavor | 0 | | id | 6f5a4b8a-b9b1-4c3c-bcdf-52a0e9993c5d | | name | MariaDB-105 | | operating_status | | | public | True | | region | RegionOne | | server_id | None | | service_status_updated | 2022-10-12T06:16:45 | | status | BUILD | | tenant_id | 231a529f51394426b07c56f2c5ec580e | | updated | 2022-10-12T06:16:45 | | 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 | +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ | 6f5a4b8a-b9b1-4c3c-bcdf-52a0e9993c5d | 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 +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- | 6f5a4b8a-b9b1-4c3c-bcdf-52a0e9993c5d | MariaDB-105 | mariadb | 10.5 | ACTIVE | HEALTHY | True +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | Addresses | Flavor ID | Size | Role | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | [{'address': '192.168.100.199', 'type': 'private', 'network': '7336a271-bec9-4d33-8dc5-e9f3a9892ed7'}, {'address': '10.0.0.231', 'type': 'public'}] | 0 | 10 | | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ # アクセスして動作確認 root@dlp ~(keystone)# mysql -h 10.0.0.231 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | 8ea041de4188 | +---------------+--------------+ +--------------------+ | Database | +--------------------+ | MyDB | | information_schema | +--------------------+ # データベースインスタンスを削除する場合は以下 root@dlp ~(keystone)# openstack database instance delete MariaDB-105 Request to delete database instance 6f5a4b8a-b9b1-4c3c-bcdf-52a0e9993c5d has been accepted. |
[4] | MySQL を起動する場合の設定です。 |
root@dlp ~(keystone)# openstack datastore list +--------------------------------------+------------+ | ID | Name | +--------------------------------------+------------+ | 249f318b-e209-44b4-a24a-d320dc38a1d3 | mysql | | 2d921feb-319b-4dac-aaa3-4e814ef2b9c6 | mariadb | +--------------------------------------+------------+root@dlp ~(keystone)# openstack datastore version list mysql
+--------------------------------------+------+---------+
| ID | Name | Version |
+--------------------------------------+------+---------+
| d3ba7a2b-851e-4f58-8a80-4e830ce5b635 | 8.0 | 8.0 |
+--------------------------------------+------+---------+
root@dlp ~(keystone)# openstack database instance create MySQL-8 \
--flavor 0 \
--size 10 \
--nic net-id=7336a271-bec9-4d33-8dc5-e9f3a9892ed7 \
--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 +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- | 41590807-86f5-4d8e-99f6-3a8904fca8c4 | MySQL-8 | mysql | 8.0 | ACTIVE | HEALTHY | True +--------------------------------------+---------+-----------+-------------------+--------+------------------+-------- +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | Addresses | Flavor ID | Size | Role | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+ | [{'address': '192.168.100.216', 'type': 'private', 'network': '7336a271-bec9-4d33-8dc5-e9f3a9892ed7'}, {'address': '10.0.0.215', 'type': 'public'}] | 0 | 10 | | +-----------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+------+root@dlp ~(keystone)# mysql -h 10.0.0.215 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | 8d51d5837578 | +---------------+--------------+ +--------------------+ | Database | +--------------------+ | MyDB | | information_schema | | performance_schema | +--------------------+ |
Sponsored Link |
|