OpenStack Zed : Trove 利用方法2023/06/30 |
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 | | Neutron L2/L3 Agent | | Libvirt | | Memcached Nginx | | Neutron Metadata | | Nova Compute | | Keystone httpd | | Open vSwitch | | Neutron L2 Agent | | Glance Nova API | | iSCSI Target | | Open vSwitch | | Neutron Server | | Cinder Volume | | | | Neutron Metadata | | Trove Services | | | | Cinder API | | Nginx | | | +-----------------------+ +-----------------------+ +-----------------------+ |
[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 | +--------------------------------------+--------------+--------+ | 3a660af6-3f41-4c0f-b2a8-55127dfc3c60 | Debian12 | active | | f3ba224f-e810-4756-b503-aea21336bfed | Trove-Ubuntu | active | +--------------------------------------+--------------+--------+root@dlp ~(keystone)# openstack volume type create lvm-trove --private +-------------+--------------------------------------+ | Field | Value | +-------------+--------------------------------------+ | description | None | | id | fb299d0c-20e3-4a5a-b36a-950f7954b73c | | 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. # 各データストアのバージョンを登録 # [f3ba224f-***] の部分は [2] で作成した Trove 用のイメージ ID root@network:~# su -s /bin/sh -c "trove-manage datastore_version_update mariadb 10.3 mariadb f3ba224f-e810-4756-b503-aea21336bfed 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 f3ba224f-e810-4756-b503-aea21336bfed 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 f3ba224f-e810-4756-b503-aea21336bfed 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 コンテナーとして起動します。 |
debian@dlp ~(keystone)$ openstack datastore list +--------------------------------------+---------+ | ID | Name | +--------------------------------------+---------+ | 3eecb0b7-9017-46d7-b0ae-064e560e218e | mariadb | | 36ba758c-78d7-49fd-995a-333d684bd36c | mysql | +--------------------------------------+---------+debian@dlp ~(keystone)$ openstack datastore version list mariadb +--------------------------------------+------+---------+ | ID | Name | Version | +--------------------------------------+------+---------+ | 9e3b0894-c443-4763-98a7-f7ae59776fa2 | 10.3 | 10.3 | | 368e2fcd-a03a-4351-9f12-1c25acfe6868 | 10.5 | 10.5 | +--------------------------------------+------+---------+debian@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 | 10 | 0 | 4 | True | | 4 | m2.large | 8192 | 10 | 10 | 4 | True | | 5 | m3.large | 8192 | 20 | 0 | 4 | True | +----+-----------+------+------+-----------+-------+-----------+debian@dlp ~(keystone)$ openstack network list +--------------------------------------+---------+--------------------------------------+ | ID | Name | Subnets | +--------------------------------------+---------+--------------------------------------+ | ae5fdb1f-efb9-412b-9053-b81106c90336 | private | b3234f3f-b3e3-41d2-b3a4-ca3d4ec55d24 | | b9b8536b-0696-4a5b-af05-602587435c0a | public | 0129c597-e411-450e-a4f9-b387c68eddb3 | +--------------------------------------+---------+--------------------------------------+ # データベースインスタンス作成 debian@dlp ~(keystone)$ openstack database instance create MariaDB-105 \ --flavor 2 \ --size 10 \ --nic net-id=ae5fdb1f-efb9-412b-9053-b81106c90336 \ --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-06-30T06:16:25 | | datastore | mariadb | | datastore_version | 10.5 | | datastore_version_number | 10.5 | | flavor | 2 | | id | 3ac15cb5-a808-4a10-808e-181fe38ac0a3 | | name | MariaDB-105 | | operating_status | | | public | True | | region | RegionOne | | service_status_updated | 2023-06-30T06:16:25 | | status | BUILD | | updated | 2023-06-30T06:16:25 | | volume | 10 | +--------------------------+--------------------------------------+ # 作成中は [BUILD] ステータス debian@dlp ~(keystone)$ openstack database instance list +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ | ID | Name | Datastore | Datastore Version | Status | Operating Status | Public | Addresses | Flavor ID | Size | Role | +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ | 3ac15cb5-a808-4a10-808e-181fe38ac0a3 | MariaDB-105 | mariadb | 10.5 | BUILD | | True | | 2 | 10 | | +--------------------------------------+-------------+-----------+-------------------+--------+------------------+--------+-----------+-----------+------+------+ # 作成が正常に完了すると [HEALTHY] ステータス debian@dlp ~(keystone)$ openstack database instance list +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- | ID | Name | Datastore | Datastore Version | Status | Operating Status | Public +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- | 3ac15cb5-a808-4a10-808e-181fe38ac0a3 | MariaDB-105 | mariadb | 10.5 | ACTIVE | HEALTHY | True +--------------------------------------+-------------+-----------+-------------------+--------+------------------+-------- +----------------------------------------------------------------------------------------------------------------------------------------------------- | Addresses +----------------------------------------------------------------------------------------------------------------------------------------------------- | [{'address': '192.168.100.181', 'type': 'private', 'network': 'ae5fdb1f-efb9-412b-9053-b81106c90336'}, {'address': '10.0.0.236', 'type': 'public'}] +----------------------------------------------------------------------------------------------------------------------------------------------------- +-----------+------+------+ | Flavor ID | Size | Role | +-----------+------+------+ | 2 | 10 | | +-----------+------+------+ # アクセスして動作確認 debian@dlp ~(keystone)$ mysql -h 10.0.0.236 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | f481de6c6eda | +---------------+--------------+ +--------------------+ | Database | +--------------------+ | MyDB | | information_schema | +--------------------+ # データベースインスタンスを削除する場合は以下 debian@dlp ~(keystone)$ openstack database instance delete MariaDB-105 Request to delete database instance 3ac15cb5-a808-4a10-808e-181fe38ac0a3 has been accepted. |
[4] | MySQL を起動する場合の設定です。 |
debian@dlp ~(keystone)$ openstack datastore list +--------------------------------------+---------+ | ID | Name | +--------------------------------------+---------+ | 3eecb0b7-9017-46d7-b0ae-064e560e218e | mariadb | | 36ba758c-78d7-49fd-995a-333d684bd36c | mysql | +--------------------------------------+---------+debian@dlp ~(keystone)$ openstack datastore version list mysql
+--------------------------------------+------+---------+
| ID | Name | Version |
+--------------------------------------+------+---------+
| 48fc551a-cd52-4bab-be5a-69476d1559e1 | 8.0 | 8.0 |
+--------------------------------------+------+---------+
debian@dlp ~(keystone)$ openstack database instance create MySQL-8 \
--flavor 2 \
--size 10 \
--nic net-id=ae5fdb1f-efb9-412b-9053-b81106c90336 \
--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
debian@dlp ~(keystone)$ openstack database instance list +--------------------------------------+---------+-----------+-------------------+--------+------------------ | ID | Name | Datastore | Datastore Version | Status | Operating Status +--------------------------------------+---------+-----------+-------------------+--------+------------------ | f105b6d5-277b-48ad-8c54-b7fbc311a556 | MySQL-8 | mysql | 8.0 | ACTIVE | HEALTHY +--------------------------------------+---------+-----------+-------------------+--------+------------------ +--------+----------------------------------------------------------------------------------------------------------------------------------------------------- | Public | Addresses +--------+----------------------------------------------------------------------------------------------------------------------------------------------------- | True | [{'address': '192.168.100.122', 'type': 'private', 'network': 'ae5fdb1f-efb9-412b-9053-b81106c90336'}, {'address': '10.0.0.246', 'type': 'public'}] +--------+----------------------------------------------------------------------------------------------------------------------------------------------------- +-----------+------+------+ | Flavor ID | Size | Role | +-----------+------+------+ | 2 | 10 | | +-----------+------+------+debian@dlp ~(keystone)$ mysql -h 10.0.0.246 -u serverworld -p -e "show variables like 'hostname'; show databases;" Enter password: +---------------+--------------+ | Variable_name | Value | +---------------+--------------+ | hostname | ea1e5711e7cf | +---------------+--------------+ +--------------------+ | Database | +--------------------+ | MyDB | | information_schema | | performance_schema | +--------------------+ |
Sponsored Link |