設定グループを使用することにより、データベースの設定作業を管理できます。設定グループにより、複数のデータベースを一括で設定オプションを設定できます。
この例は、MySQL データベースが作成済みであると仮定しています。MySQL を設定するために、設定グループを使用する方法について説明します。この例は、1 つのデータベースに 1 つのオプションを設定しますが、これらの手順を同じように使用して、お使いの環境で複数のデータベースに複数のオプションを設定できます。これにより、クラウド管理において大幅な時間節約になります。
利用可能なオプションの一覧表示
まず、どの設定オプションを設定できるのかを確認します。異なるデータストアのバージョンは、異なる設定オプションを持ちます。
mysql
データストアの利用可能な全バージョンの名前と ID を一覧表示します。
$ trove datastore-version-list mysql
+--------------------------------------+-----------+
| id | name |
+--------------------------------------+-----------+
| eeb574ce-f49a-48b6-820d-b2959fcd38bb | mysql-5.5 |
+--------------------------------------+-----------+
trove configuration-parameter-list コマンドにデータストアのバージョン ID を渡して、利用可能なオプションを取得します。
$ trove configuration-parameter-list DATASTORE_VERSION_ID
+--------------------------------+---------+---------+----------------------+------------------+
| name | type | min | max | restart_required |
+--------------------------------+---------+---------+----------------------+------------------+
| auto_increment_increment | integer | 1 | 65535 | False |
| auto_increment_offset | integer | 1 | 65535 | False |
| autocommit | integer | 0 | 1 | False |
| bulk_insert_buffer_size | integer | 0 | 18446744073709547520 | False |
| character_set_client | string | | | False |
| character_set_connection | string | | | False |
| character_set_database | string | | | False |
| character_set_filesystem | string | | | False |
| character_set_results | string | | | False |
| character_set_server | string | | | False |
| collation_connection | string | | | False |
| collation_database | string | | | False |
| collation_server | string | | | False |
| connect_timeout | integer | 1 | 65535 | False |
| expire_logs_days | integer | 1 | 65535 | False |
| innodb_buffer_pool_size | integer | 0 | 68719476736 | True |
| innodb_file_per_table | integer | 0 | 1 | True |
| innodb_flush_log_at_trx_commit | integer | 0 | 2 | False |
| innodb_log_buffer_size | integer | 1048576 | 4294967296 | True |
| innodb_open_files | integer | 10 | 4294967296 | True |
| innodb_thread_concurrency | integer | 0 | 1000 | False |
| interactive_timeout | integer | 1 | 65535 | False |
| join_buffer_size | integer | 0 | 4294967296 | False |
| key_buffer_size | integer | 0 | 4294967296 | False |
| local_infile | integer | 0 | 1 | False |
| max_allowed_packet | integer | 1024 | 1073741824 | False |
| max_connect_errors | integer | 1 | 18446744073709547520 | False |
| max_connections | integer | 1 | 65535 | False |
| max_user_connections | integer | 1 | 100000 | False |
| myisam_sort_buffer_size | integer | 4 | 18446744073709547520 | False |
| server_id | integer | 1 | 100000 | True |
| sort_buffer_size | integer | 32768 | 18446744073709547520 | False |
| sync_binlog | integer | 0 | 18446744073709547520 | False |
| wait_timeout | integer | 1 | 31536000 | False |
+--------------------------------+---------+---------+----------------------+------------------+
この例では、 configuration-parameter-list コマンドが MySQL 5.5 で動作するオプションの一覧を返します。
設定グループの作成
設定グループは、キーと値のペアのカンマ区切り一覧を含みます。各ペアは、設定オプションとその値から構成されます。
trove configuration-create コマンドを使用して、設定グループを作成できます。このコマンドの一般的な構文は、以下のとおりです。
$ trove configuration-create NAME VALUES --datastore DATASTORE_NAME
VALUES を JSON 辞書として設定します。例:
{"myFirstKey" : "someString", "mySecondKey" : 1}
この例は group1
という設定グループを作成します。group1
は 1 つのキーと値のペアを含みます。このペアは sync_binlog
オプションを 1
に設定します。
$ trove configuration-create group1 '{"sync_binlog" : 1}' --datastore mysql
+----------------------+--------------------------------------+
| Property | Value |
+----------------------+--------------------------------------+
| datastore_version_id | eeb574ce-f49a-48b6-820d-b2959fcd38bb |
| description | None |
| id | 9a9ef3bc-079b-476a-9cbf-85aa64f898a5 |
| name | group1 |
| values | {"sync_binlog": 1} |
+----------------------+--------------------------------------+
既存の設定の検査
新しく作成した設定グループを使用する前に、どのように sync_binlog
オプションがデータベースを設定するのかを確認していきます。以下の connection の設定例を、お使いのデータベースに接続できる設定に置き換えます。
$ mysql -u user7 -ppassword -h 172.16.200.2 myDB7
Welcome to the MySQL monitor. Commands end with ; or \g.
...
mysql> show variables like 'sync_binlog';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sync_binlog | 0 |
+---------------+-------+
確認できるように、myDB7
データベースの sync_binlog
オプションが現在 0
に設定されています。
設定グループを用いたデータベース設定の変更
設定グループをデータベースインスタンスに割り当てることにより、データベースの設定を変更できます。このために、 trove configuration-attach コマンドを使用して、データベースインスタンスの ID と設定グループの ID を渡します。
データベースインスタンスの ID を取得します。
$ trove list
+-------------+------------------+-----------+-------------------+--------+-----------+------+
| id | name | datastore | datastore_version | status | flavor_id | size |
+-------------+------------------+-----------+-------------------+--------+-----------+------+
| 26a265dd... | mysql_instance_7 | mysql | mysql-5.5 | ACTIVE | 6 | 5 |
+-------------+------------------+-----------+-------------------+--------+-----------+------+
設定グループの ID を取得します。
$ trove configuration-list
+-------------+--------+-------------+---------------------+
| id | name | description |datastore_version_id |
+-------------+--------+-------------+---------------------+
| 9a9ef3bc... | group1 | None | eeb574ce... |
+-------------+--------+-------------+---------------------+
設定グループをデータベースインスタンスに接続します。
注釈
このコマンド構文は、python-troveclient のバージョン 1.0.6 以降のみ利用できます。これ以前のバージョンは、設定グループ ID を最初の引数として渡す必要があります。
$ trove configuration-attach DB_INSTANCE_ID CONFIG_GROUP_ID
データベース設定の再検査
再び sync_binlog
設定を表示します。
mysql> show variables like 'sync_binlog';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sync_binlog | 1 |
+---------------+-------+
確認できるように、group1
設定グループに指定されているとおり、sync_binlog
オプションが現在 1
に設定されています。
結論。 単一のオプションを単一のデータベースに設定するために、設定グループを使用することは、明らかにささいな例です。しかしながら、設定グループは、以下を検討する際に大きな効果があります。
このように使用すると、設定グループにより、データベースクラウドの設定を、動的かつ大規模に変更できます。
メンテナンス。 設定グループを用いて動作する、有用なメンテナンス機能がいろいろとあります。以下を実行できます。
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.