MySQL5.6以降で標準準拠のGET DIAGNOSTICSが実装され、その中でMySQLのエラーコードを取得することが可能になります。
MySQL5.7(5.7.2)以降でSTACKEDが追加されています。エラーの詳細を記録するのに使えるかと思います。詳細については次のマニュアルをご参照ください。

GET DIAGNOSTICS Syntax
http://dev.mysql.com/doc/refman/5.6/en/get-diagnostics.html
http://dev.mysql.com/doc/refman/5.7/en/get-diagnostics.html
Worklog: http://dev.mysql.com/worklog/task/?id=2111

MySQL5.6
GET [CURRENT] DIAGNOSTICS

MySQL5.7
GET [CURRENT | STACKED] DIAGNOSTICS

SQL statements produce diagnostic information that populates the diagnostics area. Standard SQL has a diagnostics area stack, containing a diagnostics area for each nested execution context. Standard SQL also supports GET STACKED DIAGNOSTICS syntax for referring to the second diagnostics area during condition handler execution. MySQL supports the STACKED keyword as of MySQL 5.7. Before that, MySQL does not support STACKED; there is a single diagnostics area containing information from the most recent statement that wrote to it.
標準SQLは条件ハンドラの実行中に、第2の診断領域を参照するためのSTACKED診断構文をGETサポートしています。

■ GET CURRENTの挙動
The GET DIAGNOSTICS statement is typically used in a handler within a stored program.
It is a MySQL extension that GET [CURRENT] DIAGNOSTICS is permitted outside handler context to check the execution of any SQL statement.


root@localhost [CONFIRM]> DROP TABLE IF EXISTS t334;
Query OK, 0 rows affected, 1 warning (0.00 sec)

root@localhost [CONFIRM]> GET DIAGNOSTICS CONDITION 1 @p1 = RETURNED_SQLSTATE, @p2 = MYSQL_ERRNO, @p3 = MESSAGE_TEXT;
Query OK, 0 rows affected (0.00 sec)

root@localhost [CONFIRM]> SELECT @p1, @p2, @p3;
+-------+------+------------------------------+
| @p1   | @p2  | @p3                          |
+-------+------+------------------------------+
| 42S02 | 1051 | Unknown table 'CONFIRM.t334' |
+-------+------+------------------------------+
1 row in set (0.00 sec)

root@localhost [CONFIRM]> 

■ GET STACKEDの挙動
The GET DIAGNOSTICS statement is typically used in a handler within a stored program.
It is a MySQL extension that GET [CURRENT] DIAGNOSTICS is permitted outside handler context to check the execution of any SQL statement.
プロシジャー外部での利用の為、エラーになっています。

root@localhost [CONFIRM]> DROP TABLE IF EXISTS t334;
Query OK, 0 rows affected, 1 warning (0.01 sec)

root@localhost [CONFIRM]> GET STACKED DIAGNOSTICS CONDITION 1 @p1 = RETURNED_SQLSTATE, @p2 = MYSQL_ERRNO, @p3 = MESSAGE_TEXT;
ERROR 3004 (0Z002): GET STACKED DIAGNOSTICS when handler not active
root@localhost [CONFIRM]> 

■ CURRENTとSTACKEDの挙動

root@localhost [USER01]> delimiter //
root@localhost [USER01]> CREATE PROCEDURE p ()
    -> BEGIN
    ->   DECLARE CONTINUE HANDLER FOR SQLEXCEPTION BEGIN
    ->     SIGNAL SQLSTATE '01000';
    ->     GET CURRENT DIAGNOSTICS CONDITION 1 @current = RETURNED_SQLSTATE;
    ->     GET STACKED DIAGNOSTICS CONDITION 1 @stacked = RETURNED_SQLSTATE;
    ->     END;
    ->   SIGNAL SQLSTATE '03000';
    ->   END//
Query OK, 0 rows affected (0.00 sec)

root@localhost [USER01]> CALL p()//
Query OK, 0 rows affected, 1 warning (0.00 sec)

root@localhost [USER01]> SELECT @current, @stacked//
+----------+----------+
| @current | @stacked |
+----------+----------+
| 01000    | 03000    |
+----------+----------+
1 row in set (0.00 sec)

root@localhost [USER01]> 

■応用:エラーが発生した原因をテーブルに格納して後で確認

root@localhost [CONFIRM]> CREATE TABLE ids(id INT NOT NULL, UNIQUE(id));
Query OK, 0 rows affected (0.03 sec)

root@localhost [CONFIRM]> CREATE TABLE errors(id INT NOT NULL,RS VARCHAR(16),ME varchar(16),MT VARCHAR(1000));
Query OK, 0 rows affected (0.03 sec)

root@localhost [CONFIRM]> delimiter //
root@localhost [CONFIRM]> CREATE PROCEDURE insert_id(id INT)
    -> BEGIN
    -> DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
    -> BEGIN
    -> GET STACKED DIAGNOSTICS CONDITION 1 @p1 = RETURNED_SQLSTATE, @p2 = MYSQL_ERRNO, @p3 = MESSAGE_TEXT;
    -> INSERT INTO errors VALUES(id, @p1,@p2,@p3);
    -> IF @errno = 1213 THEN
    -> RESIGNAL;
    -> END IF;
    -> END;
    -> INSERT INTO ids VALUES(id);
    -> END;
    -> //
Query OK, 0 rows affected (0.01 sec)

root@localhost [CONFIRM]> delimiter ;
root@localhost [CONFIRM]> CALL insert_id(0);CALL insert_id(1);CALL insert_id(2);CALL insert_id(2);
Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.01 sec)

root@localhost [CONFIRM]> select * from ids;
+----+
| id |
+----+
|  0 |
|  1 |
|  2 |
+----+
3 rows in set (0.00 sec)

root@localhost [CONFIRM]> select * from errors;
+----+-------+------+----------------------------------+
| id | RS    | ME   | MT                               |
+----+-------+------+----------------------------------+
|  2 | 23000 | 1062 | Duplicate entry '2' for key 'id' |
+----+-------+------+----------------------------------+
1 row in set (0.00 sec)

root@localhost [CONFIRM]> 

参考)
http://dev.mysql.com/doc/refman/5.6/ja/get-diagnostics.html
http://dev.mysql.com/doc/refman/5.6/ja/diagnostics-area.html
http://dev.mysql.com/doc/refman/5.7/en/get-diagnostics.html
http://dev.mysql.com/doc/refman/5.7/en/diagnostics-area.html


先日、パフォーマンス検証したMySQL Cluster(7.5.3 RC)ですが、MySQL Cluster7.5.4でついにGAになりました。高可用性、インメモリー処理、トランザクション対応したNoSQL/SQL処理、オンライン拡張性が求められるシステムを探されている場合は、是非試してみて下さい。

7.5では、パフォーマンス最適化オプションだけでなく、ndbinfoから様々な構成や稼働情報を簡単に確認する事が出来るようになっています。これまで、クラスターコンフィグファイル等で確認していた内容もクエリーで即座に複数ノードを跨った設定を確認出来るようになってますので、これまで以上に運用がし易くなるかと思います。

Changes in MySQL Cluster NDB 7.5.4 (5.7.16-ndb-7.5.4) (2016-10-18, General Availability)
http://dev.mysql.com/doc/relnotes/mysql-cluster/7.5/en/mysql-cluster-news-7-5-4.html

MySQL Cluster 7.5 パフォーマンス検証

確認:バージョン

mysql> select @@version;
+----------------------------------------------+
| @@version                                    |
+----------------------------------------------+
| 5.7.16-ndb-7.5.4-cluster-commercial-advanced |
+----------------------------------------------+
1 row in set (0.00 sec)

mysql> 

config_paramsとconfig_valuesを利用したMySQL Clusterパラメータの容易な確認

mysql> SELECT  p.param_name AS Name,
    ->         v.node_id AS Node,
    ->         p.param_type AS Type,
    ->         p.param_default AS 'Default',
    ->         p.param_min AS Minimum,
    ->         p.param_max AS Maximum,
    ->         CASE p.param_mandatory WHEN 1 THEN 'Y' ELSE 'N' END AS 'Required',
    ->         v.config_value AS Current
    -> FROM    config_params p
    -> JOIN    config_values v
    -> ON      p.param_number = v.config_param
    -> WHERE   p. param_name IN ('NodeId', 'HostName','DataMemory', 'IndexMemory');
+-------------+------+----------+-----------+---------+---------------+----------+----------------+
| Name        | Node | Type     | Default   | Minimum | Maximum       | Required | Current        |
+-------------+------+----------+-----------+---------+---------------+----------+----------------+
| NodeId      |    1 | unsigned |           | 1       | 48            | Y        | 1              |
| HostName    |    1 | string   | localhost |         |               | N        | 192.168.56.114 |
| DataMemory  |    1 | unsigned | 83886080  | 1048576 | 1099511627776 | N        | 134217728      |
| IndexMemory |    1 | unsigned | 18874368  | 1048576 | 1099511627776 | N        | 68157440       |
| NodeId      |    2 | unsigned |           | 1       | 48            | Y        | 2              |
| HostName    |    2 | string   | localhost |         |               | N        | 192.168.56.115 |
| DataMemory  |    2 | unsigned | 83886080  | 1048576 | 1099511627776 | N        | 134217728      |
| IndexMemory |    2 | unsigned | 18874368  | 1048576 | 1099511627776 | N        | 68157440       |
+-------------+------+----------+-----------+---------+---------------+----------+----------------+
8 rows in set (0.03 sec)

mysql> 

mysql> SELECT  p.param_name AS Name,
    ->         v.node_id AS Node,
    ->         p.param_type AS Type,
    ->         p.param_default AS 'Default',
    ->         p.param_min AS Minimum,
    ->         p.param_max AS Maximum,
    ->         CASE p.param_mandatory WHEN 1 THEN 'Y' ELSE 'N' END AS 'Required',
    ->         v.config_value AS Current
    -> FROM    config_params p
    -> JOIN    config_values v
    -> ON      p.param_number = v.config_param
    -> WHERE   p. param_name like 'max%';
+-----------------------------------+------+----------+------------+----------+---------------+----------+------------+
| Name                              | Node | Type     | Default    | Minimum  | Maximum       | Required | Current    |
+-----------------------------------+------+----------+------------+----------+---------------+----------+------------+
| MaxNoOfSavedMessages              |    1 | unsigned | 25         | 0        | 4294967039    | N        | 25         |
| MaxNoOfTables                     |    1 | unsigned | 128        | 8        | 20320         | N        | 130        |
| MaxNoOfAttributes                 |    1 | unsigned | 1000       | 32       | 4294967039    | N        | 1009       |
| MaxNoOfTriggers                   |    1 | unsigned | 768        | 0        | 4294967039    | N        | 1784       |
| MaxNoOfConcurrentTransactions     |    1 | unsigned | 4096       | 32       | 4294967039    | N        | 4096       |
| MaxNoOfConcurrentOperations       |    1 | unsigned | 32768      | 32       | 4294967039    | N        | 10000      |
| MaxNoOfConcurrentScans            |    1 | unsigned | 256        | 2        | 500           | N        | 256        |
| MaxNoOfFiredTriggers              |    1 | unsigned | 4000       | 0        | 4294967039    | N        | 4000       |
| MaxNoOfConcurrentIndexOperations  |    1 | unsigned | 8192       | 0        | 4294967039    | N        | 8192       |
| MaxNoOfOrderedIndexes             |    1 | unsigned | 128        | 0        | 4294967039    | N        | 512        |
| MaxNoOfUniqueHashIndexes          |    1 | unsigned | 64         | 0        | 4294967039    | N        | 64         |
| MaxAllocate                       |    1 | unsigned | 33554432   | 1048576  | 1073741824    | N        | 33554432   |
| MaxNoOfSubscriptions              |    1 | unsigned | 0          | 0        | 4294967039    | N        | 0          |
| MaxNoOfSubscribers                |    1 | unsigned | 0          | 0        | 4294967039    | N        | 0          |
| MaxNoOfConcurrentSubOperations    |    1 | unsigned | 256        | 0        | 4294967039    | N        | 256        |
| MaxBufferedEpochs                 |    1 | unsigned | 100        | 1        | 100000        | N        | 100        |
| MaxNoOfExecutionThreads           |    1 | unsigned | 0          | 2        | 72            | N        | 2          |
| MaxBufferedEpochBytes             |    1 | unsigned | 26214400   | 26214400 | 4294967039    | N        | 26214400   |
| MaxLCPStartDelay                  |    1 | unsigned | 0          | 0        | 600           | N        | 0          |
| MaxStartFailRetries               |    1 | unsigned | 3          | 0        | 4294967039    | N        | 3          |
| MaxParallelScansPerFragment       |    1 | unsigned | 256        | 1        | 4294967039    | N        | 256        |
| MaxDMLOperationsPerTransaction    |    1 | unsigned | 4294967295 | 32       | 4294967295    | N        | 4294967295 |
| MaxDiskWriteSpeed                 |    1 | unsigned | 20971520   | 1048576  | 1099511627776 | N        | 20971520   |
| MaxDiskWriteSpeedOtherNodeRestart |    1 | unsigned | 52428800   | 1048576  | 1099511627776 | N        | 52428800   |
| MaxDiskWriteSpeedOwnRestart       |    1 | unsigned | 209715200  | 1048576  | 1099511627776 | N        | 209715200  |
| MaxParallelCopyInstances          |    1 | unsigned | 0          | 0        | 64            | N        | 0          |
| MaxSendDelay                      |    1 | unsigned | 0          | 0        | 11000         | N        | 0          |
| MaxNoOfSavedMessages              |    2 | unsigned | 25         | 0        | 4294967039    | N        | 25         |
| MaxNoOfTables                     |    2 | unsigned | 128        | 8        | 20320         | N        | 130        |
| MaxNoOfAttributes                 |    2 | unsigned | 1000       | 32       | 4294967039    | N        | 1009       |
| MaxNoOfTriggers                   |    2 | unsigned | 768        | 0        | 4294967039    | N        | 1784       |
| MaxNoOfConcurrentTransactions     |    2 | unsigned | 4096       | 32       | 4294967039    | N        | 4096       |
| MaxNoOfConcurrentOperations       |    2 | unsigned | 32768      | 32       | 4294967039    | N        | 10000      |
| MaxNoOfConcurrentScans            |    2 | unsigned | 256        | 2        | 500           | N        | 256        |
| MaxNoOfFiredTriggers              |    2 | unsigned | 4000       | 0        | 4294967039    | N        | 4000       |
| MaxNoOfConcurrentIndexOperations  |    2 | unsigned | 8192       | 0        | 4294967039    | N        | 8192       |
| MaxNoOfOrderedIndexes             |    2 | unsigned | 128        | 0        | 4294967039    | N        | 512        |
| MaxNoOfUniqueHashIndexes          |    2 | unsigned | 64         | 0        | 4294967039    | N        | 64         |
| MaxAllocate                       |    2 | unsigned | 33554432   | 1048576  | 1073741824    | N        | 33554432   |
| MaxNoOfSubscriptions              |    2 | unsigned | 0          | 0        | 4294967039    | N        | 0          |
| MaxNoOfSubscribers                |    2 | unsigned | 0          | 0        | 4294967039    | N        | 0          |
| MaxNoOfConcurrentSubOperations    |    2 | unsigned | 256        | 0        | 4294967039    | N        | 256        |
| MaxBufferedEpochs                 |    2 | unsigned | 100        | 1        | 100000        | N        | 100        |
| MaxNoOfExecutionThreads           |    2 | unsigned | 0          | 2        | 72            | N        | 2          |
| MaxBufferedEpochBytes             |    2 | unsigned | 26214400   | 26214400 | 4294967039    | N        | 26214400   |
| MaxLCPStartDelay                  |    2 | unsigned | 0          | 0        | 600           | N        | 0          |
| MaxStartFailRetries               |    2 | unsigned | 3          | 0        | 4294967039    | N        | 3          |
| MaxParallelScansPerFragment       |    2 | unsigned | 256        | 1        | 4294967039    | N        | 256        |
| MaxDMLOperationsPerTransaction    |    2 | unsigned | 4294967295 | 32       | 4294967295    | N        | 4294967295 |
| MaxDiskWriteSpeed                 |    2 | unsigned | 20971520   | 1048576  | 1099511627776 | N        | 20971520   |
| MaxDiskWriteSpeedOtherNodeRestart |    2 | unsigned | 52428800   | 1048576  | 1099511627776 | N        | 52428800   |
| MaxDiskWriteSpeedOwnRestart       |    2 | unsigned | 209715200  | 1048576  | 1099511627776 | N        | 209715200  |
| MaxParallelCopyInstances          |    2 | unsigned | 0          | 0        | 64            | N        | 0          |
| MaxSendDelay                      |    2 | unsigned | 0          | 0        | 11000         | N        | 0          |
+-----------------------------------+------+----------+------------+----------+---------------+----------+------------+
54 rows in set (0.01 sec)

mysql> 

dict_obj_info
The dict_obj_info table provides information about
NDB data dictionary (DICT) objects such as tables and indexes.
こちらのテーブルはNDBデータディクショナリーの情報を確認する事が可能です。


mysql> select * from dict_obj_info limit 5;
+------+------+----------+-------+-----------------+---------------+----------------------------+
| type | id   | version  | state | parent_obj_type | parent_obj_id | fq_name                    |
+------+------+----------+-------+-----------------+---------------+----------------------------+
|    6 |   89 |        1 |     4 |               2 |            88 | sys/def/88/PRIMARY         |
|   18 |   44 |        1 |     4 |               6 |            98 | NDB$INDEX_98_CUSTOM        |
|    2 |   31 | 16777218 |     4 |               0 |             0 | TEST_DB_InnoDB/def/Country |
|    6 |   59 |        1 |     4 |               2 |            33 | sys/def/33/PRIMARY         |
|   18 |    2 |        1 |     4 |               6 |            37 | NDB$INDEX_37_CUSTOM        |
+------+------+----------+-------+-----------------+---------------+----------------------------+
5 rows in set (0.00 sec)

mysql> 

table_distribution_status
The table_distribution_status table provides information about the progress of table distribution for NDB tables.
こちらのテーブルでは、NDBテーブルのディストリビューションステータスを確認する事が可能です。

mysql> select * from table_distribution_status limit 5;
+---------+----------+-----------------+-------------------+----------------+------------+-------------+----------------+---------------+--------------------+-----------------+------------------+
| node_id | table_id | tab_copy_status | tab_update_status | tab_lcp_status | tab_status | tab_storage | tab_partitions | tab_fragments | current_scan_count | scan_count_wait | is_reorg_ongoing |
+---------+----------+-----------------+-------------------+----------------+------------+-------------+----------------+---------------+--------------------+-----------------+------------------+
|       1 |        2 | IDLE            | IDLE              | COMPLETED      | ACTIVE     | NORMAL      |              2 |             2 |                  0 |               0 |                0 |
|       1 |        3 | IDLE            | IDLE              | COMPLETED      | ACTIVE     | NORMAL      |              2 |             2 |                  0 |               0 |                0 |
|       1 |       11 | IDLE            | IDLE              | COMPLETED      | ACTIVE     | NORMAL      |              2 |             2 |                  0 |               0 |                0 |
|       1 |       12 | IDLE            | IDLE              | COMPLETED      | ACTIVE     | NORMAL      |              2 |             2 |                  0 |               0 |                0 |
|       1 |       13 | IDLE            | IDLE              | COMPLETED      | ACTIVE     | NORMAL      |              2 |             2 |                  0 |               0 |                0 |
+---------+----------+-----------------+-------------------+----------------+------------+-------------+----------------+---------------+--------------------+-----------------+------------------+
5 rows in set (0.00 sec)

mysql> 

table_fragments
The table_fragments table provides information about the fragmentation, partitioning, distribution, and (internal) replication of NDB tables.
此方のテーブルでは、NDBテーブルのフラグメンテーション、パーティション、ディストリビューション、レプリケーションを確認する事が可能です。

mysql> select * from table_fragments limit 5;
+---------+----------+--------------+-------------+-----------------+-------------+----------------+-----------------+-------------------+----------------------+-----------------------+----------------------+--------------------+-------------------+------------------+
| node_id | table_id | partition_id | fragment_id | partition_order | log_part_id | no_of_replicas | current_primary | preferred_primary | current_first_backup | current_second_backup | current_third_backup | num_alive_replicas | num_dead_replicas | num_lcp_replicas |
+---------+----------+--------------+-------------+-----------------+-------------+----------------+-----------------+-------------------+----------------------+-----------------------+----------------------+--------------------+-------------------+------------------+
|       1 |        2 |   4294967295 |           0 |               0 |           0 |              2 |               1 |                 1 |                    2 |                     0 |                    0 |                  2 |                 0 |                0 |
|       1 |        2 |   4294967295 |           1 |               0 |           0 |              2 |               2 |                 2 |                    1 |                     0 |                    0 |                  2 |                 0 |                0 |
|       1 |        3 |   4294967295 |           0 |               0 |           1 |              2 |               1 |                 1 |                    2 |                     0 |                    0 |                  2 |                 0 |                0 |
|       1 |        3 |   4294967295 |           1 |               0 |           1 |              2 |               2 |                 2 |                    1 |                     0 |                    0 |                  2 |                 0 |                0 |
|       1 |       11 |   4294967295 |           0 |               0 |           3 |              2 |               1 |                 1 |                    2 |                     0 |                    0 |                  2 |                 0 |                0 |
+---------+----------+--------------+-------------+-----------------+-------------+----------------+-----------------+-------------------+----------------------+-----------------------+----------------------+--------------------+-------------------+------------------+
5 rows in set (0.00 sec)

mysql> 

table_info
The table_info table provides information about logging, checkpointing, distribution, and storage options in effect for individual NDB tables.
こちらのテーブルでは、各NDBテーブルのログ設定、チェックポイント、ディストリビューション、ストレージオプション等を確認する事が可能です。

mysql> select * from  table_info limit 5;
+----------+--------------+------------------+-----------------------+-------------+------------------+--------------+------------+-------------------+------------+
| table_id | logged_table | row_contains_gci | row_contains_checksum | read_backup | fully_replicated | storage_type | hashmap_id | partition_balance | create_gci |
+----------+--------------+------------------+-----------------------+-------------+------------------+--------------+------------+-------------------+------------+
|       31 |            1 |                1 |                     1 |           0 |                0 | MEMORY       |          1 | FOR_RP_BY_LDM     |          0 |
|       12 |            1 |                1 |                     1 |           0 |                0 | DISK         |          1 | FOR_RP_BY_LDM     |          0 |
|       82 |            1 |                1 |                     1 |           0 |                0 | MEMORY       |          1 | FOR_RP_BY_LDM     |          0 |
|       13 |            1 |                1 |                     1 |           0 |                0 | MEMORY       |          1 | FOR_RP_BY_LDM     |          0 |
|        3 |            1 |                1 |                     1 |           0 |                0 | MEMORY       |          1 | FOR_RP_BY_LDM     |          0 |
+----------+--------------+------------------+-----------------------+-------------+------------------+--------------+------------+-------------------+------------+
5 rows in set (0.01 sec)

mysql> 

table_replicas
The table_replicas table provides information about the copying, distribution, and checkpointing of NDB table fragments and fragment replicas.
こちらのテーブルでは、NDBテーブルフラグメントとレプリカのコピー、ディストリビューション、チェックポイントの情報を確認する事が可能です。

mysql> select * from table_replicas limit 5;
+---------+----------+-------------+-------------+-----------------+----------------+----------------------+----------------------+------------------------+-------------+-------------+----------------------+------------------------+-----------------+------------------+------------------+
| node_id | table_id | fragment_id | initial_gci | replica_node_id | is_lcp_ongoing | num_crashed_replicas | last_max_gci_started | last_max_gci_completed | last_lcp_id | prev_lcp_id | prev_max_gci_started | prev_max_gci_completed | last_create_gci | last_replica_gci | is_replica_alive |
+---------+----------+-------------+-------------+-----------------+----------------+----------------------+----------------------+------------------------+-------------+-------------+----------------------+------------------------+-----------------+------------------+------------------+
|       1 |        2 |           0 |           2 |               1 |              0 |                    0 |                60743 |                  60743 |          35 |       57834 |                57834 |                     34 |           57834 |       4294967295 |                1 |
|       1 |        2 |           0 |           2 |               2 |              0 |                    0 |                60743 |                  60743 |          35 |       57834 |                57834 |                     34 |           57834 |       4294967295 |                1 |
|       1 |        2 |           1 |           2 |               1 |              0 |                    0 |                60743 |                  60743 |          35 |       57834 |                57834 |                     34 |           57834 |       4294967295 |                1 |
|       1 |        2 |           1 |           2 |               2 |              0 |                    0 |                60743 |                  60743 |          35 |       57834 |                57834 |                     34 |           57834 |       4294967295 |                1 |
|       1 |        3 |           0 |           2 |               1 |              0 |                    0 |                60743 |                  60743 |          35 |       57834 |                57834 |                     34 |           57834 |       4294967295 |                1 |
+---------+----------+-------------+-------------+-----------------+----------------+----------------------+----------------------+------------------------+-------------+-------------+----------------------+------------------------+-----------------+------------------+------------------+
5 rows in set (0.00 sec)

mysql> 

これらの追加機能やテーブルを活用して、更にMSQL Clusterを活用するケースが増えればと思います。

参考: https://dev.mysql.com/doc/refman/5.7/en/mysql-cluster-what-is-new.html

補足:アップグレードに再度パフォーマンス検証(MySQL Cluster 7.5.4 + Sysbench 0.5)
READ_BACKUP=0
185.78 per sec

ALTER TABLE sbtest1 COMMENT="NDB_TABLE=READ_BACKUP=0 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
ALTER TABLE sbtest2 COMMENT="NDB_TABLE=READ_BACKUP=0 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
ALTER TABLE sbtest3 COMMENT="NDB_TABLE=READ_BACKUP=0 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
ALTER TABLE sbtest4 COMMENT="NDB_TABLE=READ_BACKUP=0 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
[root@CL-SLAVE01 sys03]# ../oltp_test_read_only 
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 32
Initializing random number generator from timer.

Random number generator seed is 0 and will be ignored


Threads started!

OLTP test statistics:
    queries performed:
        read:                            156310
        write:                           0
        other:                           22330
        total:                           178640
    transactions:                        11165  (185.78 per sec.)
    read/write requests:                 156310 (2600.95 per sec.)
    other operations:                    22330  (371.56 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          60.0973s
    total number of events:              11165
    total time taken by event execution: 1921.4885s
    response time:
         min:                                 38.13ms
         avg:                                172.10ms
         max:                                390.91ms
         approx.  95 percentile:             243.58ms

Threads fairness:
    events (avg/stddev):           348.9062/3.30
    execution time (avg/stddev):   60.0465/0.02

READ_BACKUP=1
240.78 per sec.

ALTER TABLE sbtest1 COMMENT="NDB_TABLE=READ_BACKUP=1 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
ALTER TABLE sbtest2 COMMENT="NDB_TABLE=READ_BACKUP=1 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
ALTER TABLE sbtest3 COMMENT="NDB_TABLE=READ_BACKUP=1 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
ALTER TABLE sbtest4 COMMENT="NDB_TABLE=READ_BACKUP=1 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
[root@CL-SLAVE01 sys03]# ../oltp_test_read_only 
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 32
Initializing random number generator from timer.

Random number generator seed is 0 and will be ignored


Threads started!

OLTP test statistics:
    queries performed:
        read:                            202482
        write:                           0
        other:                           28926
        total:                           231408
    transactions:                        14463  (240.78 per sec.)
    read/write requests:                 202482 (3370.96 per sec.)
    other operations:                    28926  (481.57 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          60.0666s
    total number of events:              14463
    total time taken by event execution: 1919.6420s
    response time:
         min:                                 66.34ms
         avg:                                132.73ms
         max:                                500.21ms
         approx.  95 percentile:             183.90ms

Threads fairness:
    events (avg/stddev):           451.9688/3.86
    execution time (avg/stddev):   59.9888/0.04

[root@CL-SLAVE01 sys03]# 

MySQL Cluster7.5からPK参照以外の参照性能が向上している。
テーブル作成時にREAD_BACKUPオプションを利用するか、ndb_read_backupオプションを設定しておくとPRIMARYレプリカだけでなく、SECONDARYレプリカからもデータが参照する事が出来るようになる。
MySQL7.4までは常に、PRIMARYレプリカからデータを参照していたので、ローカルにPRIMARYデータが無い場合は、PRIMARYデータを持っているノードまで取得しにいく必要があった。

イメージ

cluster

参照:
14.1.18.7 Setting NDB_TABLE options in table comments

抜粋: 
READ_BACKUP: Setting this option to 1 has the same effect as though ndb_read_backup were enabled; enables reading from any replica.
Setting this option to 1 automatically sets FRAGMENT_COUNT_TYPE to ONE_PER_LDM_PER_NODE_GROUP (see next item).
Starting with MySQL Cluster NDB 7.5.3, you can set READ_BACKUP for an existing table online,
using an ALTER TABLE statement similar to one of those shown here:


ALTER TABLE ... ALGORITHM=INPLACE, COMMENT="NDB_TABLE=READ_BACKUP=1";
ALTER TABLE ... ALGORITHM=INPLACE, COMMENT="NDB_TABLE=READ_BACKUP=0";

【結論】
結果としては、READ_BACKUPをONにした方が、3割程パフォーマンスが向上していました。
非常に非力な、仮想環境での検証なので皆さんの環境でも是非検証してみて下さい。
大幅にパフォーマンスが改善する可能性があります。

READ_BACKUP=0 (OFF)
transactions: 5650 (93.91 per sec.)
transactions: 5718 (94.91 per sec.)
transactions: 5698 (94.71 per sec.)
transactions: 5490 (91.24 per sec.)

READ_BACKUP=1 (ON)
transactions: 7234 (120.17 per sec.)
transactions: 7403 (123.00 per sec.)
transactions: 7419 (123.32 per sec.)
transactions: 7264 (120.77 per sec.)

※ マシーン自体は非力なのでTPSは少ないですが、どちらも全く同じ状況で検証しています。

■ 簡単にSYSBENCH0.5のOLTP READで、参照パフォーマンスの確認を行ってみました。
メモリーが無いので、データは1万件しかいれてません。(1万 X 4テーブル)


mysql> select @@version;
+----------------------------------+
| @@version                        |
+----------------------------------+
| 5.7.13-ndb-7.5.3-cluster-gpl-log |
+----------------------------------+
1 row in set (0.00 sec)

mysql> show tables;
+--------------------+
| Tables_in_sysbench |
+--------------------+
| sbtest1            |
| sbtest2            |
| sbtest3            |
| sbtest4            |
+--------------------+
4 rows in set (0.00 sec)

mysql> select count(*) from sbtest1;
+----------+
| count(*) |
+----------+
|    10000 |
+----------+
1 row in set (0.00 sec)

mysql> 

SYSBENCHのスレッド数と実行しているQUERY
‐ 32スレッドで60秒程実行しています。 
‐ Queryの殆どは、BETWEEN等を利用しているのでPKで特定のデータをピンポイントで持ってくる処理ではありません。


/bin/sysbench \
  --test=../lua/db/oltp.lua \
  --rand-init=on \
  --db-driver=mysql \
  --oltp-table-size=${TSIZE} \
  --rand-type=uniform \
  --oltp-read-only=on \
  --oltp-tables-count=${NTBLE}\
  --mysql-db=sysbench \
  --mysql-host=${ENDPOINT} \
  --mysql-user=bench_user \
  --mysql-password=password \
  --max-time=60 \
  --max-requests=0 \
  --num-threads=32 \




[root@CL-SLAVE01 sys03]# cat ../lua/db/oltp.lua | egrep -i select 
   for i=1, oltp_point_selects do
      rs = db_query("SELECT c FROM ".. table_name .." WHERE id=" .. sb_rand(1, oltp_table_size))
      rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1)
      rs = db_query("SELECT SUM(K) FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1)
      rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1 .. " ORDER BY c")
      rs = db_query("SELECT DISTINCT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1 .. " ORDER BY c")
[root@CL-SLAVE01 sys03]# 

上記のテーブルとデータでDEFAULTの状態(READ_BACKUPをOFF)で検証してみます。

[root@CL-SLAVE01 sys03]# ../oltp_test_read_only 
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 32
Initializing random number generator from timer.

Random number generator seed is 0 and will be ignored


Threads started!

OLTP test statistics:
    queries performed:
        read:                            79100
        write:                           0
        other:                           11300
        total:                           90400
    transactions:                        5650   (93.91 per sec.)
    read/write requests:                 79100  (1314.76 per sec.)
    other operations:                    11300  (187.82 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          60.1630s
    total number of events:              5650
    total time taken by event execution: 1919.4297s
    response time:
         min:                                 89.72ms
         avg:                                339.72ms
         max:                                617.21ms
         approx.  95 percentile:             442.32ms

Threads fairness:
    events (avg/stddev):           176.5625/2.45
    execution time (avg/stddev):   59.9822/0.11

[root@CL-SLAVE01 sys03]# 




[root@CL-SLAVE01 sys03]# ../oltp_test_read_only 
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 32
Initializing random number generator from timer.

Random number generator seed is 0 and will be ignored


Threads started!

OLTP test statistics:
    queries performed:
        read:                            80052
        write:                           0
        other:                           11436
        total:                           91488
    transactions:                        5718   (94.91 per sec.)
    read/write requests:                 80052  (1328.77 per sec.)
    other operations:                    11436  (189.82 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          60.2452s
    total number of events:              5718
    total time taken by event execution: 1924.6034s
    response time:
         min:                                161.28ms
         avg:                                336.59ms
         max:                                646.96ms
         approx.  95 percentile:             441.26ms

Threads fairness:
    events (avg/stddev):           178.6875/2.28
    execution time (avg/stddev):   60.1439/0.07

[root@CL-SLAVE01 sys03]# 

READ_BACKUPをONにしています。ALTERテーブルでテーブル毎に設定変更可能です。


mysql> ALTER TABLE sbtest1 COMMENT="NDB_TABLE=READ_BACKUP=1 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
Query OK, 0 rows affected (0.11 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE sbtest2 COMMENT="NDB_TABLE=READ_BACKUP=1 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
Query OK, 0 rows affected (0.12 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE sbtest3 COMMENT="NDB_TABLE=READ_BACKUP=1 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
Query OK, 0 rows affected (0.10 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE sbtest4 COMMENT="NDB_TABLE=READ_BACKUP=1 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
Query OK, 0 rows affected (0.20 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> 

READ_BACKUPオプションをONにしたので、同じテストを実行してみます。


[root@CL-SLAVE01 sys03]# ../oltp_test_read_only 
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 32
Initializing random number generator from timer.

Random number generator seed is 0 and will be ignored


Threads started!

OLTP test statistics:
    queries performed:
        read:                            101276
        write:                           0
        other:                           14468
        total:                           115744
    transactions:                        7234   (120.17 per sec.)
    read/write requests:                 101276 (1682.33 per sec.)
    other operations:                    14468  (240.33 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          60.1997s
    total number of events:              7234
    total time taken by event execution: 1919.6510s
    response time:
         min:                                 61.99ms
         avg:                                265.37ms
         max:                                515.43ms
         approx.  95 percentile:             350.01ms

Threads fairness:
    events (avg/stddev):           226.0625/0.97
    execution time (avg/stddev):   59.9891/0.10

[root@CL-SLAVE01 sys03]# 



[root@CL-SLAVE01 sys03]# ../oltp_test_read_only 
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 32
Initializing random number generator from timer.

Random number generator seed is 0 and will be ignored


Threads started!

OLTP test statistics:
    queries performed:
        read:                            103642
        write:                           0
        other:                           14806
        total:                           118448
    transactions:                        7403   (123.00 per sec.)
    read/write requests:                 103642 (1722.05 per sec.)
    other operations:                    14806  (246.01 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          60.1852s
    total number of events:              7403
    total time taken by event execution: 1923.2176s
    response time:
         min:                                143.96ms
         avg:                                259.79ms
         max:                                421.40ms
         approx.  95 percentile:             328.68ms

Threads fairness:
    events (avg/stddev):           231.3438/0.59
    execution time (avg/stddev):   60.1006/0.05

[root@CL-SLAVE01 sys03]# 

■ 再テストでREAD_BACKUPをOFFにしてみます。


mysql> ALTER TABLE sbtest1 COMMENT="NDB_TABLE=READ_BACKUP=0 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
Query OK, 0 rows affected (0.09 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE sbtest2 COMMENT="NDB_TABLE=READ_BACKUP=0 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
Query OK, 0 rows affected (0.10 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE sbtest3 COMMENT="NDB_TABLE=READ_BACKUP=0 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
Query OK, 0 rows affected (0.11 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE sbtest4 COMMENT="NDB_TABLE=READ_BACKUP=0 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
Query OK, 0 rows affected (0.21 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> 

READ_BACKUPをOFFにした状態で再度検証してみると、TPSは落ちています。

[root@CL-SLAVE01 sys03]# ../oltp_test_read_only 
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 32
Initializing random number generator from timer.

Random number generator seed is 0 and will be ignored


Threads started!

OLTP test statistics:
    queries performed:
        read:                            79772
        write:                           0
        other:                           11396
        total:                           91168
    transactions:                        5698   (94.71 per sec.)
    read/write requests:                 79772  (1325.97 per sec.)
    other operations:                    11396  (189.42 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          60.1611s
    total number of events:              5698
    total time taken by event execution: 1920.7135s
    response time:
         min:                                118.55ms
         avg:                                337.09ms
         max:                                600.45ms
         approx.  95 percentile:             440.47ms

Threads fairness:
    events (avg/stddev):           178.0625/1.71
    execution time (avg/stddev):   60.0223/0.09

[root@CL-SLAVE01 sys03]# 


[root@CL-SLAVE01 sys03]# ../oltp_test_read_only 
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 32
Initializing random number generator from timer.

Random number generator seed is 0 and will be ignored


Threads started!

OLTP test statistics:
    queries performed:
        read:                            76860
        write:                           0
        other:                           10980
        total:                           87840
    transactions:                        5490   (91.24 per sec.)
    read/write requests:                 76860  (1277.31 per sec.)
    other operations:                    10980  (182.47 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          60.1734s
    total number of events:              5490
    total time taken by event execution: 1922.5091s
    response time:
         min:                                171.24ms
         avg:                                350.18ms
         max:                                801.92ms
         approx.  95 percentile:             478.98ms

Threads fairness:
    events (avg/stddev):           171.5625/1.32
    execution time (avg/stddev):   60.0784/0.06

[root@CL-SLAVE01 sys03]# 

READ_BACKUP設定を再度ONにしています。


mysql> ALTER TABLE sbtest1 COMMENT="NDB_TABLE=READ_BACKUP=1 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
Query OK, 0 rows affected (0.20 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE sbtest2 COMMENT="NDB_TABLE=READ_BACKUP=1 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
Query OK, 0 rows affected (0.20 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE sbtest3 COMMENT="NDB_TABLE=READ_BACKUP=1 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
Query OK, 0 rows affected (0.10 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> ALTER TABLE sbtest4 COMMENT="NDB_TABLE=READ_BACKUP=1 NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM";
Query OK, 0 rows affected (0.16 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> 

もう一度、READ_BACKUPをONにしてパフォーマンスを確認してみました。
やはり、ONにした方が今回の環境ではパフォーマンスが良いようです。

[root@CL-SLAVE01 sys03]# ../oltp_test_read_only 
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 32
Initializing random number generator from timer.

Random number generator seed is 0 and will be ignored


Threads started!

OLTP test statistics:
    queries performed:
        read:                            103866
        write:                           0
        other:                           14838
        total:                           118704
    transactions:                        7419   (123.32 per sec.)
    read/write requests:                 103866 (1726.47 per sec.)
    other operations:                    14838  (246.64 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          60.1609s
    total number of events:              7419
    total time taken by event execution: 1920.0195s
    response time:
         min:                                 91.51ms
         avg:                                258.80ms
         max:                                463.14ms
         approx.  95 percentile:             351.79ms

Threads fairness:
    events (avg/stddev):           231.8438/0.83
    execution time (avg/stddev):   60.0006/0.13

[root@CL-SLAVE01 sys03]#


[root@CL-SLAVE01 sys03]# ../oltp_test_read_only 
sysbench 0.5:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 32
Initializing random number generator from timer.

Random number generator seed is 0 and will be ignored


Threads started!

OLTP test statistics:
    queries performed:
        read:                            101696
        write:                           0
        other:                           14528
        total:                           116224
    transactions:                        7264   (120.77 per sec.)
    read/write requests:                 101696 (1690.77 per sec.)
    other operations:                    14528  (241.54 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          60.1476s
    total number of events:              7264
    total time taken by event execution: 1921.1800s
    response time:
         min:                                 77.60ms
         avg:                                264.48ms
         max:                                454.03ms
         approx.  95 percentile:             343.88ms

Threads fairness:
    events (avg/stddev):           227.0000/0.79
    execution time (avg/stddev):   60.0369/0.06

[root@CL-SLAVE01 sys03]# 

MySQL Cluster 7.5はMySQL5.7ベースのMySQLが利用可能なので、JSONが利用出来たり色々な改善が加わっています。
これまでより、多くのケースで活用出来る場面が増えてくるかと思います。詳細は以下のURLを参照下さい。
19.1.4 What is New in MySQL Cluster NDB 7.5

例) MySQL Cluster7.5のndbinfoから,こちらのようにテーブルの情報も確認出来るようになってます。


mysql> SELECT  p.param_name AS Name,
    ->         v.node_id AS Node,
    ->         p.param_type AS Type,
    ->         p.param_default AS 'Default',
    ->         p.param_min AS Minimum,
    ->         p.param_max AS Maximum,
    ->         CASE p.param_mandatory WHEN 1 THEN 'Y' ELSE 'N' END AS 'Required',
    ->         v.config_value AS Current
    -> FROM    config_params p
    -> JOIN    config_values v
    -> ON      p.param_number = v.config_param
    -> WHERE   p. param_name IN ('NodeId', 'HostName','DataMemory', 'IndexMemory');
+-------------+------+----------+-----------+---------+---------------+----------+----------------+
| Name        | Node | Type     | Default   | Minimum | Maximum       | Required | Current        |
+-------------+------+----------+-----------+---------+---------------+----------+----------------+
| NodeId      |    1 | unsigned |           | 1       | 48            | Y        | 1              |
| HostName    |    1 | string   | localhost |         |               | N        | 192.168.56.114 |
| DataMemory  |    1 | unsigned | 83886080  | 1048576 | 1099511627776 | N        | 134217728      |
| IndexMemory |    1 | unsigned | 18874368  | 1048576 | 1099511627776 | N        | 68157440       |
| NodeId      |    2 | unsigned |           | 1       | 48            | Y        | 2              |
| HostName    |    2 | string   | localhost |         |               | N        | 192.168.56.115 |
| DataMemory  |    2 | unsigned | 83886080  | 1048576 | 1099511627776 | N        | 134217728      |
| IndexMemory |    2 | unsigned | 18874368  | 1048576 | 1099511627776 | N        | 68157440       |
+-------------+------+----------+-----------+---------+---------------+----------+----------------+
8 rows in set (0.09 sec)

mysql> 

MySQL Clusterに関しても、セミナーで紹介していたりするので都合が付けば是非参加下さい。
https://www-jp.mysql.com/news-and-events/events/


InnoDB Clusterは、MySQLの高可用性構成をサポートするMySQLの可用性フレームワークです。
まだLab版ですが、既にRCになっているMySQL Group Replication、GAになっているMySQL Router (GAはバージョンは1.x),MySQL Shell (DMR)を組み合わせて高可用性を実現しています。
基本的な動作は、MySQL Fabricに似ていますが、管理リポジトリー自体がGroup Replication内にあるので、デフォルトで冗長化されています。また、MySQL Router,MySQL Shell,MySQL Group Replicationが蜜に連携していて1つのHAパッケージのようになっています。まだ、十分に検証出来ていませんが、基本的な動作を確認したので、此方にメモしておきます。
※まだLab版なので、仕様は変わると思います。

innodb_cluster

ダウンロード
MySQL Labs :: MySQL InnoDB Cluster 5.7.15 Preview
※ インストール方法は、RPMが提供されているので割愛しています。

■ Sandboxインスタンスのデプロイ
※ Do not run MySQL Shell as root.
以下のdeployLocalInstanceコマンドで新規インスタンスが構築されます。


[root@replications admin]# su - mysql
最終ログイン: 2016/09/27 (火) 22:32:27 JST日時 pts/2
-bash-4.2$ mysqlsh
Welcome to MySQL Shell 1.0.5-labs Development Preview

Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type '\help', '\h' or '\?' for help, type '\quit' or '\q' to exit.

Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.
mysql-js> dba.deployLocalInstance(3310)
A new MySQL sandbox instance will be created on this host in 
/home/mysql/mysql-sandboxes/3310

Please enter a MySQL root password for the new instance: 
Deploying new MySQL instance...

Instance localhost:3310 successfully deployed and started.
Use '\connect root@localhost:3310' to connect to the instance.

mysql-js> dba.deployLocalInstance(3320) 
A new MySQL sandbox instance will be created on this host in 
/home/mysql/mysql-sandboxes/3320

Please enter a MySQL root password for the new instance: 
Deploying new MySQL instance...

Instance localhost:3320 successfully deployed and started.
Use '\connect root@localhost:3320' to connect to the instance.

mysql-js> dba.deployLocalInstance(3330)
A new MySQL sandbox instance will be created on this host in 
/home/mysql/mysql-sandboxes/3330

Please enter a MySQL root password for the new instance: 
Deploying new MySQL instance...

Instance localhost:3330 successfully deployed and started.
Use '\connect root@localhost:3330' to connect to the instance.

mysql-js> 


[root@replications mysql-sandboxes]# pwd
/home/mysql/mysql-sandboxes
[root@replications mysql-sandboxes]# ls -l
合計 12
drwxrwxr-x. 4 mysql mysql 4096  9月 27 17:25 3310
drwxrwxr-x. 4 mysql mysql 4096  9月 27 17:26 3320
drwxrwxr-x. 4 mysql mysql 4096  9月 27 17:27 3330
[root@replications mysql-sandboxes]# ls -l 3310/
合計 28
-rw-r-----. 1 mysql mysql    5  9月 27 17:25 3310.pid
drwxr-x---. 5 mysql mysql 4096  9月 27 17:25 data
-rw-------. 1 mysql mysql  806  9月 27 17:25 my.cnf
drwxrwxr-x. 2 mysql mysql    6  9月 27 17:25 mysql-files
srwxrwxrwx. 1 mysql mysql    0  9月 27 17:25 mysqld.sock
-rw-------. 1 mysql mysql    5  9月 27 17:25 mysqld.sock.lock
srwxrwxrwx. 1 mysql mysql    0  9月 27 17:25 mysqlx.sock
-rw-------. 1 mysql mysql    6  9月 27 17:25 mysqlx.sock.lock
-rwx------. 1 mysql mysql  121  9月 27 17:25 start.sh
-rwx------. 1 mysql mysql  186  9月 27 17:25 stop.sh
[root@replications mysql-sandboxes]# ls -l 3310/data/
合計 122948
-rw-r-----. 1 mysql mysql      169  9月 27 17:25 ON.000001
-rw-r-----. 1 mysql mysql      169  9月 27 17:25 ON.000002
-rw-r-----. 1 mysql mysql      150  9月 27 17:25 ON.000003
-rw-r-----. 1 mysql mysql       36  9月 27 17:25 ON.index
-rw-r-----. 1 mysql mysql       56  9月 27 17:25 auto.cnf
-rw-r-----. 1 mysql mysql    14266  9月 27 17:25 error.log
-rw-r-----. 1 mysql mysql      362  9月 27 17:25 ib_buffer_pool
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:25 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:25 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:25 ibdata1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:25 ibtmp1
drwxr-x---. 2 mysql mysql     4096  9月 27 17:25 mysql
drwxr-x---. 2 mysql mysql     8192  9月 27 17:25 performance_schema
drwxr-x---. 2 mysql mysql     8192  9月 27 17:25 sys
[root@replications mysql-sandboxes]# ls -l 3320/data/
合計 122948
-rw-r-----. 1 mysql mysql      169  9月 27 17:26 ON.000001
-rw-r-----. 1 mysql mysql      169  9月 27 17:26 ON.000002
-rw-r-----. 1 mysql mysql      150  9月 27 17:26 ON.000003
-rw-r-----. 1 mysql mysql       36  9月 27 17:26 ON.index
-rw-r-----. 1 mysql mysql       56  9月 27 17:26 auto.cnf
-rw-r-----. 1 mysql mysql    14369  9月 27 17:26 error.log
-rw-r-----. 1 mysql mysql      362  9月 27 17:26 ib_buffer_pool
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:26 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:26 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:26 ibdata1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:26 ibtmp1
drwxr-x---. 2 mysql mysql     4096  9月 27 17:26 mysql
drwxr-x---. 2 mysql mysql     8192  9月 27 17:26 performance_schema
drwxr-x---. 2 mysql mysql     8192  9月 27 17:26 sys
[root@replications mysql-sandboxes]# ls -l 3330/data/
合計 122948
-rw-r-----. 1 mysql mysql      169  9月 27 17:27 ON.000001
-rw-r-----. 1 mysql mysql      169  9月 27 17:27 ON.000002
-rw-r-----. 1 mysql mysql      150  9月 27 17:27 ON.000003
-rw-r-----. 1 mysql mysql       36  9月 27 17:27 ON.index
-rw-r-----. 1 mysql mysql       56  9月 27 17:27 auto.cnf
-rw-r-----. 1 mysql mysql    13201  9月 27 17:27 error.log
-rw-r-----. 1 mysql mysql      359  9月 27 17:27 ib_buffer_pool
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:27 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:27 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:27 ibdata1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:27 ibtmp1
drwxr-x---. 2 mysql mysql     4096  9月 27 17:27 mysql
drwxr-x---. 2 mysql mysql     8192  9月 27 17:27 performance_schema
drwxr-x---. 2 mysql mysql     8192  9月 27 17:27 sys
[root@replications mysql-sandboxes]# ls -l 3330/data/
合計 122948
-rw-r-----. 1 mysql mysql      169  9月 27 17:27 ON.000001
-rw-r-----. 1 mysql mysql      169  9月 27 17:27 ON.000002
-rw-r-----. 1 mysql mysql      150  9月 27 17:27 ON.000003
-rw-r-----. 1 mysql mysql       36  9月 27 17:27 ON.index
-rw-r-----. 1 mysql mysql       56  9月 27 17:27 auto.cnf
-rw-r-----. 1 mysql mysql    13201  9月 27 17:27 error.log
-rw-r-----. 1 mysql mysql      359  9月 27 17:27 ib_buffer_pool
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:27 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:27 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:27 ibdata1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:27 ibtmp1
drwxr-x---. 2 mysql mysql     4096  9月 27 17:27 mysql
drwxr-x---. 2 mysql mysql     8192  9月 27 17:27 performance_schema
drwxr-x---. 2 mysql mysql     8192  9月 27 17:27 sys
[root@replications mysql-sandboxes]# 

■ InnoDB Clusterの初期化
※Do not lose the MASTER key because it is required for managing the InnoDB cluster.
構築したインスタンスでグループレプリケーションを構築します。


mysql-js> \connect root@localhost:3310
Creating a Session to 'root@localhost:3310'
Enter password: 
Classic Session successfully established. No default schema selected.
mysql-js> cluster = dba.createCluster('test')
A new InnoDB cluster will be created on instance 'root@localhost:3310'.

When setting up a new InnoDB cluster it is required to define an administrative
MASTER key for the cluster. This MASTER key needs to be re-entered when making
changes to the cluster later on, e.g.adding new MySQL instances or configuring
MySQL Routers. Losing this MASTER key will require the configuration of all
InnoDB cluster entities to be changed.

Please specify an administrative MASTER key for the cluster 'test': 
Creating InnoDB cluster 'test' on 'root@localhost:3310'...
Adding Seed Instance...

Cluster successfully created. Use Cluster.addInstance() to add MySQL instances.
At least 3 instances are needed for the cluster to be able to withstand up to
one server failure.

<Cluster:test>
mysql-js> 



[root@replications mysql-sandboxes]# ls -l 3310/data/
合計 122988
-rw-r-----. 1 mysql mysql      169  9月 27 17:25 ON.000001
-rw-r-----. 1 mysql mysql      169  9月 27 17:25 ON.000002
-rw-r-----. 1 mysql mysql    10397  9月 27 17:31 ON.000003
-rw-r-----. 1 mysql mysql       36  9月 27 17:25 ON.index
-rw-r-----. 1 mysql mysql       56  9月 27 17:25 auto.cnf
-rw-r-----. 1 mysql mysql    21676  9月 27 17:31 error.log
-rw-r-----. 1 mysql mysql      362  9月 27 17:25 ib_buffer_pool
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:31 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:25 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:31 ibdata1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:31 ibtmp1
drwxr-x---. 2 mysql mysql     4096  9月 27 17:25 mysql
drwxr-x---. 2 mysql mysql     4096  9月 27 17:31 mysql_innodb_cluster_metadata
drwxr-x---. 2 mysql mysql     8192  9月 27 17:25 performance_schema
-rw-r-----. 1 mysql mysql      232  9月 27 17:31 replications-relay-bin-group_replication_applier.000001
-rw-r-----. 1 mysql mysql      598  9月 27 17:31 replications-relay-bin-group_replication_applier.000002
-rw-r-----. 1 mysql mysql      116  9月 27 17:31 replications-relay-bin-group_replication_applier.index
-rw-r-----. 1 mysql mysql      150  9月 27 17:31 replications-relay-bin-group_replication_recovery.000001
-rw-r-----. 1 mysql mysql       59  9月 27 17:31 replications-relay-bin-group_replication_recovery.index
drwxr-x---. 2 mysql mysql     8192  9月 27 17:25 sys
[root@replications mysql-sandboxes]# ls -l 3320/data/
合計 122948
-rw-r-----. 1 mysql mysql      169  9月 27 17:26 ON.000001
-rw-r-----. 1 mysql mysql      169  9月 27 17:26 ON.000002
-rw-r-----. 1 mysql mysql      150  9月 27 17:26 ON.000003
-rw-r-----. 1 mysql mysql       36  9月 27 17:26 ON.index
-rw-r-----. 1 mysql mysql       56  9月 27 17:26 auto.cnf
-rw-r-----. 1 mysql mysql    14369  9月 27 17:26 error.log
-rw-r-----. 1 mysql mysql      362  9月 27 17:26 ib_buffer_pool
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:26 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:26 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:26 ibdata1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:26 ibtmp1
drwxr-x---. 2 mysql mysql     4096  9月 27 17:26 mysql
drwxr-x---. 2 mysql mysql     8192  9月 27 17:26 performance_schema
drwxr-x---. 2 mysql mysql     8192  9月 27 17:26 sys
[root@replications mysql-sandboxes]# ls -l 3330/data/
合計 122948
-rw-r-----. 1 mysql mysql      169  9月 27 17:27 ON.000001
-rw-r-----. 1 mysql mysql      169  9月 27 17:27 ON.000002
-rw-r-----. 1 mysql mysql      150  9月 27 17:27 ON.000003
-rw-r-----. 1 mysql mysql       36  9月 27 17:27 ON.index
-rw-r-----. 1 mysql mysql       56  9月 27 17:27 auto.cnf
-rw-r-----. 1 mysql mysql    13201  9月 27 17:27 error.log
-rw-r-----. 1 mysql mysql      359  9月 27 17:27 ib_buffer_pool
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:27 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:27 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:27 ibdata1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:27 ibtmp1
drwxr-x---. 2 mysql mysql     4096  9月 27 17:27 mysql
drwxr-x---. 2 mysql mysql     8192  9月 27 17:27 performance_schema
drwxr-x---. 2 mysql mysql     8192  9月 27 17:27 sys
[root@replications mysql-sandboxes]# 

■ InnoDB Clusterへのインスタンスの追加
グループレプリケーションへインスタンスを追加します。


mysql-js> cluster.addInstance('root@localhost:3320')
A new instance will be added to the InnoDB cluster. Depending on the amount of
data on the cluster this might take from a few seconds to several hours.

Please provide the password for 'root@localhost:3320': 
Adding instance to the cluster ...

The instance 'root@localhost:3320' was successfully added to the cluster.

mysql-js> cluster.addInstance('root@localhost:3330')
A new instance will be added to the InnoDB cluster. Depending on the amount of
data on the cluster this might take from a few seconds to several hours.

Please provide the password for 'root@localhost:3330': 
Adding instance to the cluster ...

The instance 'root@localhost:3330' was successfully added to the cluster.

mysql-js> 


[root@replications mysql-sandboxes]# ls -l 3310/data/
合計 122988
-rw-r-----. 1 mysql mysql      169  9月 27 17:25 ON.000001
-rw-r-----. 1 mysql mysql      169  9月 27 17:25 ON.000002
-rw-r-----. 1 mysql mysql    12253  9月 27 17:36 ON.000003
-rw-r-----. 1 mysql mysql       36  9月 27 17:25 ON.index
-rw-r-----. 1 mysql mysql       56  9月 27 17:25 auto.cnf
-rw-r-----. 1 mysql mysql    23760  9月 27 17:36 error.log
-rw-r-----. 1 mysql mysql      362  9月 27 17:25 ib_buffer_pool
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:36 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:25 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:36 ibdata1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:36 ibtmp1
drwxr-x---. 2 mysql mysql     4096  9月 27 17:25 mysql
drwxr-x---. 2 mysql mysql     4096  9月 27 17:31 mysql_innodb_cluster_metadata
drwxr-x---. 2 mysql mysql     8192  9月 27 17:25 performance_schema
-rw-r-----. 1 mysql mysql      232  9月 27 17:31 replications-relay-bin-group_replication_applier.000001
-rw-r-----. 1 mysql mysql     1336  9月 27 17:36 replications-relay-bin-group_replication_applier.000002
-rw-r-----. 1 mysql mysql      116  9月 27 17:31 replications-relay-bin-group_replication_applier.index
-rw-r-----. 1 mysql mysql      150  9月 27 17:31 replications-relay-bin-group_replication_recovery.000001
-rw-r-----. 1 mysql mysql       59  9月 27 17:31 replications-relay-bin-group_replication_recovery.index
drwxr-x---. 2 mysql mysql     8192  9月 27 17:25 sys
[root@replications mysql-sandboxes]# ls -l 3320/data/
合計 122996
-rw-r-----. 1 mysql mysql      169  9月 27 17:26 ON.000001
-rw-r-----. 1 mysql mysql      169  9月 27 17:26 ON.000002
-rw-r-----. 1 mysql mysql    12129  9月 27 17:36 ON.000003
-rw-r-----. 1 mysql mysql       36  9月 27 17:26 ON.index
-rw-r-----. 1 mysql mysql       56  9月 27 17:26 auto.cnf
-rw-r-----. 1 mysql mysql    24847  9月 27 17:37 error.log
-rw-r-----. 1 mysql mysql      362  9月 27 17:26 ib_buffer_pool
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:36 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:26 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:36 ibdata1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:35 ibtmp1
drwxr-x---. 2 mysql mysql     4096  9月 27 17:26 mysql
drwxr-x---. 2 mysql mysql     4096  9月 27 17:35 mysql_innodb_cluster_metadata
drwxr-x---. 2 mysql mysql     8192  9月 27 17:26 performance_schema
-rw-r-----. 1 mysql mysql      232  9月 27 17:35 replications-relay-bin-group_replication_applier.000001
-rw-r-----. 1 mysql mysql     2135  9月 27 17:36 replications-relay-bin-group_replication_applier.000002
-rw-r-----. 1 mysql mysql      116  9月 27 17:35 replications-relay-bin-group_replication_applier.index
-rw-r-----. 1 mysql mysql      233  9月 27 17:35 replications-relay-bin-group_replication_recovery.000001
-rw-r-----. 1 mysql mysql      269  9月 27 17:35 replications-relay-bin-group_replication_recovery.000002
-rw-r-----. 1 mysql mysql      118  9月 27 17:35 replications-relay-bin-group_replication_recovery.index
drwxr-x---. 2 mysql mysql     8192  9月 27 17:26 sys
[root@replications mysql-sandboxes]# ls -l 3330/data/
合計 122992
-rw-r-----. 1 mysql mysql      169  9月 27 17:27 ON.000001
-rw-r-----. 1 mysql mysql      169  9月 27 17:27 ON.000002
-rw-r-----. 1 mysql mysql    12129  9月 27 17:36 ON.000003
-rw-r-----. 1 mysql mysql       36  9月 27 17:27 ON.index
-rw-r-----. 1 mysql mysql       56  9月 27 17:27 auto.cnf
-rw-r-----. 1 mysql mysql    22841  9月 27 17:36 error.log
-rw-r-----. 1 mysql mysql      359  9月 27 17:27 ib_buffer_pool
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:36 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648  9月 27 17:27 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:36 ibdata1
-rw-r-----. 1 mysql mysql 12582912  9月 27 17:36 ibtmp1
drwxr-x---. 2 mysql mysql     4096  9月 27 17:27 mysql
drwxr-x---. 2 mysql mysql     4096  9月 27 17:36 mysql_innodb_cluster_metadata
drwxr-x---. 2 mysql mysql     8192  9月 27 17:27 performance_schema
-rw-r-----. 1 mysql mysql      232  9月 27 17:36 replications-relay-bin-group_replication_applier.000001
-rw-r-----. 1 mysql mysql     1202  9月 27 17:36 replications-relay-bin-group_replication_applier.000002
-rw-r-----. 1 mysql mysql      116  9月 27 17:36 replications-relay-bin-group_replication_applier.index
-rw-r-----. 1 mysql mysql      233  9月 27 17:36 replications-relay-bin-group_replication_recovery.000001
-rw-r-----. 1 mysql mysql      269  9月 27 17:36 replications-relay-bin-group_replication_recovery.000002
-rw-r-----. 1 mysql mysql      118  9月 27 17:36 replications-relay-bin-group_replication_recovery.index
drwxr-x---. 2 mysql mysql     8192  9月 27 17:27 sys
[root@replications mysql-sandboxes]# 


[root@replications mysql-sandboxes]# netstat -na | grep sandboxes
unix  2      [ ACC ]     STREAM     LISTENING     26245    /home/mysql/mysql-sandboxes/3310/mysqlx.sock
unix  2      [ ACC ]     STREAM     LISTENING     26250    /home/mysql/mysql-sandboxes/3310/mysqld.sock
unix  2      [ ACC ]     STREAM     LISTENING     22039    /home/mysql/mysql-sandboxes/3330/mysqlx.sock
unix  2      [ ACC ]     STREAM     LISTENING     22044    /home/mysql/mysql-sandboxes/3330/mysqld.sock
unix  2      [ ACC ]     STREAM     LISTENING     21930    /home/mysql/mysql-sandboxes/3320/mysqlx.sock
unix  2      [ ACC ]     STREAM     LISTENING     21935    /home/mysql/mysql-sandboxes/3320/mysqld.sock
[root@replications mysql-sandboxes]# 

■ InnoDB Clusterのステータス確認
全てのホストがONLINEでHAが構成されている事が確認出来る。


mysql-js> cluster.status()
{
    "clusterName": "test",
    "defaultReplicaSet": {
        "status": "Cluster tolerant to up to ONE failure.",
        "topology": {
            "localhost:3310": {
                "address": "localhost:3310",
                "status": "ONLINE",
                "role": "HA",
                "mode": "R/W",
                "leaves": {
                    "localhost:3320": {
                        "address": "localhost:3320",
                        "status": "ONLINE",
                        "role": "HA",
                        "mode": "R/O",
                        "leaves": {}
                    },
                    "localhost:3330": {
                        "address": "localhost:3330",
                        "status": "ONLINE",
                        "role": "HA",
                        "mode": "R/O",
                        "leaves": {}
                    }
                }
            }
        }
    }
}
mysql-js> 

Sandbox環境のGroup ReplicationはSingle Primary Modeで動いています。
It is a configuration mode for Group Replication that makes a single member act as a writeable master (PRIMARY) and the rest of the members act as hot-standbys (SECONDARY).
The group itself coordinates and configures itself automatically to determine which member will act as the PRIMARY, through a leader election mechanism.


-bash-4.2$ mysql -u root -pP@33word -h 127.0.0.1 -P 6446 -e "show variables like 'group_replication_single_primary_mode'"
mysql: [Warning] Using a password on the command line interface can be insecure.
+---------------------------------------+-------+
| Variable_name                         | Value |
+---------------------------------------+-------+
| group_replication_single_primary_mode | ON    |
+---------------------------------------+-------+
-bash-4.2$ 

-bash-4.2$ mysql -u root -pP@33word -h 127.0.0.1 -P 6446 -e "show variables like 'group_replication_enforce_update_everywhere_checks'"
mysql: [Warning] Using a password on the command line interface can be insecure.
+----------------------------------------------------+-------+
| Variable_name                                      | Value |
+----------------------------------------------------+-------+
| group_replication_enforce_update_everywhere_checks | OFF   |
+----------------------------------------------------+-------+
-bash-4.2$ 

-bash-4.2$ mysql -u root -pP@33word -h 127.0.0.1 -P 6447 -e "SELECT * FROM performance_schema.global_status WHERE VARIABLE_NAME='group_replication_primary_member'"
mysql: [Warning] Using a password on the command line interface can be insecure.
+----------------------------------+--------------------------------------+
| VARIABLE_NAME                    | VARIABLE_VALUE                       |
+----------------------------------+--------------------------------------+
| group_replication_primary_member | 944915c6-853a-11e6-8e3d-080027d65c57 |
+----------------------------------+--------------------------------------+
-bash-4.2$ 

■ MySQL Routerのデプロイ
MySQL Routerを起動させて、グループレプリケーションへの接続をコントロールします。


-bash-4.2$ sudo mysqlrouter --bootstrap localhost:3310
[sudo] password for mysql: 
Please enter the administrative MASTER key for the MySQL InnoDB cluster: 
MySQL Router has now been configured for the InnoDB cluster 'test'.

The following connection information can be used to connect to the cluster.

Classic MySQL protocol connections to cluster 'test':
- Read/Write Connections: localhost:6446
- Read/Only Connections: localhost:6447
-bash-4.2$ 


-bash-4.2$ mysqlrouter &
[1] 3615
-bash-4.2$ Logging to /var/log/mysqlrouter/mysqlrouter.log

-bash-4.2$ ps -ef | grep mysqlrouter
mysql     3615  3589  0 14:32 pts/1    00:00:00 mysqlrouter
mysql     3625  3589  0 14:32 pts/1    00:00:00 grep --color=auto mysqlrouter
-bash-4.2$ 

■ MySQLRouter経由でmysqlに接続し動作確認
mysqlshell経由


1) MySQL Shell経由

-bash-4.2$ mysqlsh --uri root@localhost:6446
Creating a Session to 'root@localhost:6446'
Enter password: 
Classic Session successfully established. No default schema selected.
Welcome to MySQL Shell 1.0.5-labs Development Preview

Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type '\help', '\h' or '\?' for help, type '\quit' or '\q' to exit.

Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.
mysql-js> \sql
Switching to SQL mode... Commands end with ;
mysql-sql> select @@hostname,@@port;
+--------------+--------+
| @@hostname   | @@port |
+--------------+--------+
| replications |   3310 |
+--------------+--------+
1 row in set (0.00 sec)
mysql-sql> 


-bash-4.2$ mysqlsh --uri root@localhost:6447
Creating a Session to 'root@localhost:6447'
Enter password: 
Classic Session successfully established. No default schema selected.
Welcome to MySQL Shell 1.0.5-labs Development Preview

Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type '\help', '\h' or '\?' for help, type '\quit' or '\q' to exit.

Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.
mysql-js> \sql
Switching to SQL mode... Commands end with ;
mysql-sql> select @@hostname,@@port;
+--------------+--------+
| @@hostname   | @@port |
+--------------+--------+
| replications |   3330 |
+--------------+--------+
1 row in set (0.00 sec)
mysql-sql>

2) MySQLコマンド経由での確認とステータスの確認


-bash-4.2$ mysql -u root -p -h 127.0.0.1 -P 6446
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.7.15-labs-gr090-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select @@hostname,@@port;
+--------------+--------+
| @@hostname   | @@port |
+--------------+--------+
| replications |   3310 |
+--------------+--------+
1 row in set (0.00 sec)

mysql> 


-bash-4.2$ mysql -u root -p -h 127.0.0.1 -P 6447
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 26
Server version: 5.7.15-labs-gr090-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select @@hostname,@@port;
+--------------+--------+
| @@hostname   | @@port |
+--------------+--------+
| replications |   3320 |
+--------------+--------+
1 row in set (0.00 sec)

mysql> 



mysql-js> cluster.status()
{
    "clusterName": "test",
    "defaultReplicaSet": {
        "status": "Cluster tolerant to up to ONE failure.",
        "topology": {
            "localhost:3310": {
                "address": "localhost:3310",
                "status": "ONLINE",
                "role": "HA",
                "mode": "R/W",
                "leaves": {
                    "localhost:3320": {
                        "address": "localhost:3320",
                        "status": "ONLINE",
                        "role": "HA",
                        "mode": "R/O",
                        "leaves": {}
                    },
                    "localhost:3330": {
                        "address": "localhost:3330",
                        "status": "ONLINE",
                        "role": "HA",
                        "mode": "R/O",
                        "leaves": {}
                    }
                }
            }
        }
    }
}
mysql-js> 

mysql-js> cluster.describe();
{
    "clusterName": "test",
    "adminType": "local",
    "defaultReplicaSet": {
        "name": "default",
        "instances": [
            {
                "name": "localhost:3310",
                "host": "localhost:3310",
                "role": "HA"
            },
            {
                "name": "localhost:3320",
                "host": "localhost:3320",
                "role": "HA"
            },
            {
                "name": "localhost:3330",
                "host": "localhost:3330",
                "role": "HA"
            }
        ]
    }
}
mysql-js> 

■ フェイルオーバーの確認 (HA)
既存のマスターインスタンスをdba.killLocalInstanceでダウンさせてみる。


mysql-js> dba.killLocalInstance(3310)
The MySQL sandbox instance on this host in 
/home/mysql/mysql-sandboxes/3310 will be killed

Killing MySQL instance...

Instance localhost:3310 successfully killed.

mysql-js> 

– 書き込みの接続が3310から3320に代わっている事が確認出来ます。


-bash-4.2$ mysqlsh --uri root@localhost:6446
Creating a Session to 'root@localhost:6446'
Enter password: 
ERROR: 2003 (HY000): Can't connect to remote MySQL server on '127.0.0.1:6446'
-bash-4.2$ mysqlsh --uri root@localhost:6446
Creating a Session to 'root@localhost:6446'
Enter password: 
Classic Session successfully established. No default schema selected.
Welcome to MySQL Shell 1.0.5-labs Development Preview

Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type '\help', '\h' or '\?' for help, type '\quit' or '\q' to exit.

Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.
mysql-js> \sql
Switching to SQL mode... Commands end with ;
mysql-sql> select @@hostname,@@port;
+--------------+--------+
| @@hostname   | @@port |
+--------------+--------+
| replications |   3320 |
+--------------+--------+
1 row in set (0.00 sec)
mysql-sql> 



-bash-4.2$ mysql -u root -p -h 127.0.0.1 -P 6446
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 5.7.15-labs-gr090-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select @@hostname,@@port;
+--------------+--------+
| @@hostname   | @@port |
+--------------+--------+
| replications |   3320 |
+--------------+--------+
1 row in set (0.00 sec)

mysql> 


-bash-4.2$ mysql -u root -p -h 127.0.0.1 -P 6447
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.7.15-labs-gr090-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select @@hostname,@@port;
+--------------+--------+
| @@hostname   | @@port |
+--------------+--------+
| replications |   3330 |
+--------------+--------+
1 row in set (0.00 sec)

mysql> 


-bash-4.2$ mysqlsh
Welcome to MySQL Shell 1.0.5-labs Development Preview

Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type '\help', '\h' or '\?' for help, type '\quit' or '\q' to exit.

Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.
mysql-js> \connect root@localhost:6446
Creating a Session to 'root@localhost:6446'
Enter password: 
Classic Session successfully established. No default schema selected.
mysql-js> cluster = dba.getCluster()
When the InnoDB cluster was setup, a MASTER key was defined in order to enable
performing administrative tasks on the cluster.

Please specify the administrative MASTER key for the default cluster: 
<Cluster:test>
mysql-js> cluster.status()
{
    "clusterName": "test",
    "defaultReplicaSet": {
        "status": "Cluster is NOT tolerant to any failures.",
        "topology": {
            "localhost:3320": {
                "address": "localhost:3320",
                "status": "ONLINE",
                "role": "HA",
                "mode": "R/W",
                "leaves": {
                    "localhost:3330": {
                        "address": "localhost:3330",
                        "status": "ONLINE",
                        "role": "HA",
                        "mode": "R/O",
                        "leaves": {}
                    },
                    "localhost:3310": {
                        "address": "localhost:3310",
                        "status": "OFFLINE",
                        "role": "HA",
                        "mode": "R/O",
                        "leaves": {}
                    }
                }
            }
        }
    }
}
mysql-js> cluster.describe();
{
    "clusterName": "test",
    "adminType": "local",
    "defaultReplicaSet": {
        "name": "default",
        "instances": [
            {
                "name": "localhost:3310",
                "host": "localhost:3310",
                "role": "HA"
            },
            {
                "name": "localhost:3320",
                "host": "localhost:3320",
                "role": "HA"
            },
            {
                "name": "localhost:3330",
                "host": "localhost:3330",
                "role": "HA"
            }
        ]
    }
}
mysql-js> 

■ 停止したインスタンスの再開


mysql-js> dba.startLocalInstance(3310)
The MySQL sandbox instance on this host in 
/home/mysql/mysql-sandboxes/3310 will be started

Starting MySQL instance...

Instance localhost:3310 successfully started.

mysql-js> cluster.status()
{
    "clusterName": "test",
    "defaultReplicaSet": {
        "status": "Cluster is NOT tolerant to any failures.",
        "topology": {
            "localhost:3320": {
                "address": "localhost:3320",
                "status": "ONLINE",
                "role": "HA",
                "mode": "R/W",
                "leaves": {
                    "localhost:3330": {
                        "address": "localhost:3330",
                        "status": "ONLINE",
                        "role": "HA",
                        "mode": "R/O",
                        "leaves": {}
                    },
                    "localhost:3310": {
                        "address": "localhost:3310",
                        "status": "OFFLINE",
                        "role": "HA",
                        "mode": "R/O",
                        "leaves": {}
                    }
                }
            }
        }
    }
}
mysql-js> 

■ インスタンスをInnoDB Clusterグループへ再参加


mysql-js> dba.validateInstance('root@localhost:3310')
Please provide a password for 'root@localhost:3310': 
Validating instance...


Running check command.
Checking Group Replication prerequisites.
* Comparing options compatibility with Group Replication... PASS
Server configuration is compliant with the requirements.
* Checking server version... PASS
Server is 5.7.15

* Checking that server_id is unique... PASS
The server_id is valid.


* Checking compliance of existing tables... PASS

The instance: localhost:3310 is valid for Cluster usage

mysql-js> cluster.rejoinInstance('root@localhost:3310')
Please provide the password for 'root@localhost:3310': 
The instance will try rejoining the InnoDB cluster. Depending on the original
problem that made the instance unavailable the rejoin, operation might not be
successful and further manual steps will be needed to fix the underlying
problem.

Please monitor the output of the rejoin operation and take necessary action if
the instance cannot rejoin.
mysql-js> cluster.status()
{
    "clusterName": "test",
    "defaultReplicaSet": {
        "status": "Cluster tolerant to up to ONE failure.",
        "topology": {
            "localhost:3320": {
                "address": "localhost:3320",
                "status": "ONLINE",
                "role": "HA",
                "mode": "R/W",
                "leaves": {
                    "localhost:3310": {
                        "address": "localhost:3310",
                        "status": "ONLINE",
                        "role": "HA",
                        "mode": "R/O",
                        "leaves": {}
                    },
                    "localhost:3330": {
                        "address": "localhost:3330",
                        "status": "ONLINE",
                        "role": "HA",
                        "mode": "R/O",
                        "leaves": {}
                    }
                }
            }
        }
    }
}
mysql-js> 

■ SQLクライアントを利用したデータ同期と参照用インスタンスへのラウンドロビンを確認。

1) データ作成


-bash-4.2$ mysql -u root -p -h 127.0.0.1 -P 6446
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.7.15-labs-gr090-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+-------------------------------+
| Database                      |
+-------------------------------+
| information_schema            |
| mysql                         |
| mysql_innodb_cluster_metadata |
| performance_schema            |
| sys                           |
+-------------------------------+
5 rows in set (0.00 sec)

mysql> create database test;
Query OK, 1 row affected (0.05 sec)

mysql> use test
Database changed
mysql> CREATE TABLE `InnoDB_Cluster` (
    -> `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    -> `comment` varchar(100) NOT NULL,
    -> `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    -> PRIMARY KEY (`id`)
    -> ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
Query OK, 0 rows affected (0.05 sec)

mysql> show databases;
+-------------------------------+
| Database                      |
+-------------------------------+
| information_schema            |
| mysql                         |
| mysql_innodb_cluster_metadata |
| performance_schema            |
| sys                           |
| test                          |
+-------------------------------+
6 rows in set (0.00 sec)

mysql> exit
Bye
-bash-4.2$ mysql -u root -p -h 127.0.0.1 -P 6447
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 5.7.15-labs-gr090-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+-------------------------------+
| Database                      |
+-------------------------------+
| information_schema            |
| mysql                         |
| mysql_innodb_cluster_metadata |
| performance_schema            |
| sys                           |
| test                          |
+-------------------------------+
6 rows in set (0.00 sec)

mysql> 

■ データを1万件入れてます。

※ もし、参照側データベースにデータをINSERTしようとすると以下のようにエラーになる。
1290 (HY000): The MySQL server is running with the –super-read-only option so it cannot execute this statement
MySQL5.7からのsuper-read-onlyオプションが設定されている。

-bash-4.2$ python innodb_cluster.py 
Finish Creating Data
-bash-4.2$ 

■ 書き込み接続の確認(MySQL Routerの設定により、特定のマスターへ接続)

-bash-4.2$ mysql -u root -pP@33word -h 127.0.0.1 -P 6446 -e 'select @@port,count(*) from test.InnoDB_Cluster'
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------+----------+
| @@port | count(*) |
+--------+----------+
|   3320 |    10000 |
+--------+----------+
-bash-4.2$ mysql -u root -pP@33word -h 127.0.0.1 -P 6446 -e 'select @@port,count(*) from test.InnoDB_Cluster'
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------+----------+
| @@port | count(*) |
+--------+----------+
|   3320 |    10000 |
+--------+----------+
-bash-4.2$ 

■ 読み込み接続の確認(MySQL Routerの設定により、複数スレーブへのラウンドロビン接続)

-bash-4.2$ mysql -u root -pP@33word -h 127.0.0.1 -P 6447 -e 'select @@port,count(*) from test.InnoDB_Cluster'
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------+----------+
| @@port | count(*) |
+--------+----------+
|   3330 |    10000 |
+--------+----------+
-bash-4.2$ mysql -u root -pP@33word -h 127.0.0.1 -P 6447 -e 'select @@port,count(*) from test.InnoDB_Cluster'
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------+----------+
| @@port | count(*) |
+--------+----------+
|   3310 |    10000 |
+--------+----------+
-bash-4.2$ mysql -u root -pP@33word -h 127.0.0.1 -P 6447 -e 'select @@port,count(*) from test.InnoDB_Cluster'
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------+----------+
| @@port | count(*) |
+--------+----------+
|   3330 |    10000 |
+--------+----------+
-bash-4.2$ 

■ その他参考:リポジトリー(各ノードで持っているので冗長化が取れている)

-bash-4.2$ mysql -u root -pP@33word -h 127.0.0.1 -P 6446
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 50
Server version: 5.7.15-labs-gr090-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+-------------------------------+
| Database                      |
+-------------------------------+
| information_schema            |
| mysql                         |
| mysql_innodb_cluster_metadata |
| performance_schema            |
| sys                           |
| test                          |
+-------------------------------+
6 rows in set (0.01 sec)

mysql> use mysql_innodb_cluster_metadata
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-----------------------------------------+
| Tables_in_mysql_innodb_cluster_metadata |
+-----------------------------------------+
| clusters                                |
| hosts                                   |
| instances                               |
| replicasets                             |
| schema_version                          |
+-----------------------------------------+
5 rows in set (0.00 sec)

mysql> desc clusters;
+---------------------+------------------+------+-----+---------+----------------+
| Field               | Type             | Null | Key | Default | Extra          |
+---------------------+------------------+------+-----+---------+----------------+
| cluster_id          | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| cluster_name        | varchar(40)      | NO   | UNI | NULL    |                |
| default_replicaset  | int(10) unsigned | YES  | MUL | NULL    |                |
| description         | text             | YES  |     | NULL    |                |
| mysql_user_accounts | blob             | YES  |     | NULL    |                |
| options             | json             | YES  |     | NULL    |                |
| attributes          | json             | YES  |     | NULL    |                |
+---------------------+------------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)

mysql> desc hosts;
+--------------------+------------------+------+-----+---------+----------------+
| Field              | Type             | Null | Key | Default | Extra          |
+--------------------+------------------+------+-----+---------+----------------+
| host_id            | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| host_name          | varchar(128)     | YES  |     | NULL    |                |
| ip_address         | varchar(45)      | YES  |     | NULL    |                |
| location           | varchar(256)     | NO   |     | NULL    |                |
| attributes         | json             | YES  |     | NULL    |                |
| admin_user_account | json             | YES  |     | NULL    |                |
+--------------------+------------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)

mysql> desc instances;
+-------------------+---------------------------+------+-----+---------+----------------+
| Field             | Type                      | Null | Key | Default | Extra          |
+-------------------+---------------------------+------+-----+---------+----------------+
| instance_id       | int(10) unsigned          | NO   | PRI | NULL    | auto_increment |
| host_id           | int(10) unsigned          | NO   | MUL | NULL    |                |
| replicaset_id     | int(10) unsigned          | YES  | MUL | NULL    |                |
| mysql_server_uuid | varchar(40)               | NO   | UNI | NULL    |                |
| instance_name     | varchar(40)               | NO   | UNI | NULL    |                |
| role              | enum('HA','readScaleOut') | NO   |     | NULL    |                |
| weight            | float                     | YES  |     | NULL    |                |
| addresses         | json                      | NO   |     | NULL    |                |
| attributes        | json                      | YES  |     | NULL    |                |
| version_token     | int(10) unsigned          | YES  |     | NULL    |                |
| description       | text                      | YES  |     | NULL    |                |
+-------------------+---------------------------+------+-----+---------+----------------+
11 rows in set (0.00 sec)

mysql> desc replicasets;
+-----------------+------------------+------+-----+---------+----------------+
| Field           | Type             | Null | Key | Default | Extra          |
+-----------------+------------------+------+-----+---------+----------------+
| replicaset_id   | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| cluster_id      | int(10) unsigned | NO   | MUL | NULL    |                |
| replicaset_type | enum('gr')       | NO   |     | NULL    |                |
| topology_type   | enum('pm','mm')  | NO   |     | pm      |                |
| replicaset_name | varchar(40)      | NO   |     | NULL    |                |
| active          | tinyint(1)       | NO   |     | NULL    |                |
| attributes      | json             | YES  |     | NULL    |                |
| description     | text             | YES  |     | NULL    |                |
+-----------------+------------------+------+-----+---------+----------------+
8 rows in set (0.00 sec)

mysql> desc schema_version;
+-------+--------+------+-----+---------+-------+
| Field | Type   | Null | Key | Default | Extra |
+-------+--------+------+-----+---------+-------+
| major | int(1) | NO   |     | 0       |       |
| minor | int(1) | NO   |     | 0       |       |
+-------+--------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql> 

■ その他参考:MySQL Router設定

[root@replications mysql-sandboxes]# cat /etc/mysqlrouter/mysqlrouter.conf 
[DEFAULT]
plugin_folder=/lib64/mysqlrouter
# logging_folder=/var/log/mysqlrouter

[logger]
level = INFO

[metadata_cache]
bootstrap_server_addresses=mysql://localhost:3310,mysql://localhost:3320,mysql://localhost:3330
user=mysql_innodb_cluster_reader
password=]yZQL(C7H7AU.x(2
metadata_cluster=test
ttl=300
metadata_replicaset=default

[routing:default_rw]
bind_port=6446
destinations=metadata-cache:///default?role=PRIMARY
mode=read-write

[routing:default_ro]
bind_port=6447
destinations=metadata-cache:///default?role=SECONDARY
mode=read-only
[root@replications mysql-sandboxes]# 


[root@replications mysql-sandboxes]# cat /etc/mysqlrouter/mysqlrouter.ini 
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

#
# MySQL Router configuration file
#
# Documentation is available at
#    http://dev.mysql.com/doc/mysql-router/en/

[DEFAULT]
logging_folder = /var/log/mysqlrouter/
plugin_folder = /usr/lib64/mysqlrouter
runtime_folder = /var/run/mysqlrouter
config_folder = /etc/mysqlrouter

[logger]
level = info

# If no plugin is configured which starts a service, keepalive
# will make sure MySQL Router will not immediately exit. It is
# safe to remove once Router is configured.
[keepalive]
interval = 60
[root@replications mysql-sandboxes]# 

参考)
https://dev.mysql.com/doc/mysql-innodb-cluster/en/mysql-innodb-cluster-getting-started.html
http://wagnerbianchi.com/blog/?p=1229
http://wagnerbianchi.com/blog/?p=1259
https://www.pythian.com/blog/rejoining-node-mysqls-innodb-cluster/


MySQL5.7から実装された、マルチソースレプリケーションに関しての質問も少しずつ増えてきたので、改めて基本的な挙動をこちらに纏めました。
基本的には、通常のレプリケーションの挙動と変わりませんが、CHANNELに分けて1台のスレーブが複数マスターからのログを受け取るので、運用上、気を付けないといけない部分が増えてくるので、リカバリー含むPOCはしておいた方が安心です。

■ マスター側の設定(複数マスターサーバー全体でサーバーID以外は同じ)
※ マスター側は通常のレプリケーションの設定をしています。(サーバーID, バイナリーログ等)
※ ログポジションベース、GTIDモードどちらも可能ですが、今回はGTIDで設定しています。
※ Masterに予めスレーブ用のアカウントを作成済み。

Optionファイルに設定した方が良いですが検証なので、動的に設定しています。
MySQL8.0ではここら辺の動的設定も永続化するオプションが追加されています。

以下の構成での説明になります

Master1(Port:63301) --------------------->
                                            SLAVE(Port:63303)
Master2(Port:63302) --------------------->

■ Slaveにて、各マスターへの接続設定を行います。


mysql> STOP SLAVE;SET GLOBAL master_info_repository = 'TABLE';SET GLOBAL relay_log_info_repository = 'TABLE';
Query OK, 0 rows affected, 1 warning (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> CHANGE MASTER TO MASTER_HOST='localhost', MASTER_USER='multi_source', MASTER_PORT=63301, MASTER_PASSWORD='password', \
    -> MASTER_AUTO_POSITION = 1 FOR CHANNEL 'master-1';
Query OK, 0 rows affected, 1 warning (0.06 sec)

mysql> CHANGE MASTER TO MASTER_HOST='localhost', MASTER_USER='multi_source', MASTER_PORT=63302, MASTER_PASSWORD='password', \
    -> MASTER_AUTO_POSITION = 1 FOR CHANNEL 'master-2';
Query OK, 0 rows affected, 1 warning (0.04 sec)

mysql>

mysql> START SLAVE FOR CHANNEL 'master-1';START SLAVE FOR CHANNEL 'master-2';
Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> 

■ レプリケーションステータスの確認
(CHANNELを指定しなければ、全てのCHANNELの接続情報が表示されます)


mysql> SHOW SLAVE STATUS FOR CHANNEL 'master-1' \G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: localhost
                  Master_User: multi_source
                  Master_Port: 63301
                Connect_Retry: 60
              Master_Log_File: Fabric02-bin.000001
          Read_Master_Log_Pos: 885
               Relay_Log_File: Fabric02-relay-bin-master@002d1.000002
                Relay_Log_Pos: 423
        Relay_Master_Log_File: Fabric02-bin.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 885
              Relay_Log_Space: 686
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1
                  Master_UUID: a0c35acf-839f-11e6-89f4-080027d65c57
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: a0c35acf-839f-11e6-89f4-080027d65c57:1-3,
a65948cd-839f-11e6-8cb5-080027d65c57:1-3,
abf190f1-839f-11e6-8dbb-080027d65c57:1-2
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: master-1
           Master_TLS_Version: 
1 row in set (0.00 sec)

mysql> SHOW SLAVE STATUS FOR CHANNEL 'master-2' \G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: localhost
                  Master_User: multi_source
                  Master_Port: 63302
                Connect_Retry: 60
              Master_Log_File: Fabric02-bin.000001
          Read_Master_Log_Pos: 885
               Relay_Log_File: Fabric02-relay-bin-master@002d2.000002
                Relay_Log_Pos: 1104
        Relay_Master_Log_File: Fabric02-bin.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 885
              Relay_Log_Space: 1327
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 2
                  Master_UUID: a65948cd-839f-11e6-8cb5-080027d65c57
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: a65948cd-839f-11e6-8cb5-080027d65c57:1-3
            Executed_Gtid_Set: a0c35acf-839f-11e6-89f4-080027d65c57:1-3,
a65948cd-839f-11e6-8cb5-080027d65c57:1-3,
abf190f1-839f-11e6-8dbb-080027d65c57:1-2
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: master-2
           Master_TLS_Version: 
1 row in set (0.00 sec)

mysql> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: localhost
                  Master_User: multi_source
                  Master_Port: 63301
                Connect_Retry: 60
              Master_Log_File: Fabric02-bin.000001
          Read_Master_Log_Pos: 2102
               Relay_Log_File: Fabric02-relay-bin-master@002d1.000002
                Relay_Log_Pos: 1640
        Relay_Master_Log_File: Fabric02-bin.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 2102
              Relay_Log_Space: 1903
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1
                  Master_UUID: a0c35acf-839f-11e6-89f4-080027d65c57
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: a0c35acf-839f-11e6-89f4-080027d65c57:4-8
            Executed_Gtid_Set: a0c35acf-839f-11e6-89f4-080027d65c57:1-8,
a65948cd-839f-11e6-8cb5-080027d65c57:1-6,
abf190f1-839f-11e6-8dbb-080027d65c57:1-2
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: master-1
           Master_TLS_Version: 
*************************** 2. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: localhost
                  Master_User: multi_source
                  Master_Port: 63302
                Connect_Retry: 60
              Master_Log_File: Fabric02-bin.000001
          Read_Master_Log_Pos: 1623
               Relay_Log_File: Fabric02-relay-bin-master@002d2.000002
                Relay_Log_Pos: 1842
        Relay_Master_Log_File: Fabric02-bin.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 1623
              Relay_Log_Space: 2065
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 2
                  Master_UUID: a65948cd-839f-11e6-8cb5-080027d65c57
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: a65948cd-839f-11e6-8cb5-080027d65c57:1-6
            Executed_Gtid_Set: a0c35acf-839f-11e6-89f4-080027d65c57:1-8,
a65948cd-839f-11e6-8cb5-080027d65c57:1-6,
abf190f1-839f-11e6-8dbb-080027d65c57:1-2
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: master-2
           Master_TLS_Version: 
2 rows in set (0.00 sec)

mysql> 

■ Performance_Schemaのコネクションテーブルからも接続を確認可能です。


mysql> SELECT * FROM performance_schema.replication_connection_status WHERE channel_name='master-1'\G
*************************** 1. row ***************************
             CHANNEL_NAME: master-1
               GROUP_NAME: 
              SOURCE_UUID: a0c35acf-839f-11e6-89f4-080027d65c57
                THREAD_ID: 36
            SERVICE_STATE: ON
COUNT_RECEIVED_HEARTBEATS: 38
 LAST_HEARTBEAT_TIMESTAMP: 2016-09-26 13:43:04
 RECEIVED_TRANSACTION_SET: a0c35acf-839f-11e6-89f4-080027d65c57:4-8
        LAST_ERROR_NUMBER: 0
       LAST_ERROR_MESSAGE: 
     LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00
1 row in set (0.00 sec)

mysql> SELECT * FROM performance_schema.replication_connection_status WHERE channel_name='master-2'\G
*************************** 1. row ***************************
             CHANNEL_NAME: master-2
               GROUP_NAME: 
              SOURCE_UUID: a65948cd-839f-11e6-8cb5-080027d65c57
                THREAD_ID: 38
            SERVICE_STATE: ON
COUNT_RECEIVED_HEARTBEATS: 39
 LAST_HEARTBEAT_TIMESTAMP: 2016-09-26 13:43:01
 RECEIVED_TRANSACTION_SET: a65948cd-839f-11e6-8cb5-080027d65c57:1-6
        LAST_ERROR_NUMBER: 0
       LAST_ERROR_MESSAGE: 
     LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00
1 row in set (0.00 sec)

mysql> 

全てのマスターからスレーブに配布するスキーマが異なっていれば、運用的な敷居は低いかと思います。
こちらの例では、マスター毎にスキーマ(データベース)が別です。

multi-master

マスターとスレーブで同じスキーマ、同じテーブルを利用する場合は、データに矛盾が発生しないようにしないといけません。
予めIDが被らないようにするなどの設計と実装が必要です。
同じスキーマを対象にしている場合のオブジェクト変更は、特定のマスターのみで変更して他のマスターではBINLOGをOFFにして変更する等の運用が必要です。

(以下の例では同じオブジェクトに別々のIDでデータをINSERTしています)
multi-source_same_schema_table

こちらは、サーバーPORTにプラスで付けてます。何でも被らなければOKです。
multi-source_same_schema_table_appli

リレーログは、各マスターサーバー毎に作成されます。
こちらの例では、relay-bin-master@002d1とrelay-bin-master@002d2でログがサーバー毎に分かれています。

-bash-4.2$ ls -l /home/mysql/fabric/mysql3/*relay*
-rw-r-----. 1 mysql mysql  223  9月 27 11:02 /home/mysql/fabric/mysql3/Fabric02-relay-bin-master@002d1.000001
-rw-r-----. 1 mysql mysql 1411  9月 27 11:16 /home/mysql/fabric/mysql3/Fabric02-relay-bin-master@002d1.000002
-rw-r-----. 1 mysql mysql   82  9月 27 11:02 /home/mysql/fabric/mysql3/Fabric02-relay-bin-master@002d1.index
-rw-r-----. 1 mysql mysql  223  9月 27 11:02 /home/mysql/fabric/mysql3/Fabric02-relay-bin-master@002d2.000001
-rw-r-----. 1 mysql mysql 1411  9月 27 11:17 /home/mysql/fabric/mysql3/Fabric02-relay-bin-master@002d2.000002
-rw-r-----. 1 mysql mysql   82  9月 27 11:02 /home/mysql/fabric/mysql3/Fabric02-relay-bin-master@002d2.index
-bash-4.2$ /usr/local/mysql57/bin/mysqlbinlog -v Fabric02-relay-bin-master@002d1.000002 | grep CREATE
GRANT SELECT, INSERT, DELETE, CREATE, DROP ON `test`.* TO 'app'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*5BCB3E6AC345B435C7C2E6B7949A04CE6F6563D3'
CREATE TABLE MASTER01 (
-bash-4.2$ /usr/local/mysql57/bin/mysqlbinlog -v Fabric02-relay-bin-master@002d2.000002 | grep CREATE
GRANT SELECT, INSERT, DELETE, CREATE, DROP ON `test`.* TO 'app'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*5BCB3E6AC345B435C7C2E6B7949A04CE6F6563D3'
CREATE TABLE MASTER02 (
-bash-4.2$ 

■ RESET (特定CHANNELのみRESETしてますが、CHANNELオプション無しで全てRESETも可能です。)


mysql> STOP SLAVE FOR CHANNEL 'master-1';
Query OK, 0 rows affected (0.00 sec)

mysql> RESET SLAVE FOR CHANNEL 'master-1';
Query OK, 0 rows affected (0.07 sec)

mysql> SELECT * FROM performance_schema.replication_connection_status WHERE channel_name='master-1'\G
*************************** 1. row ***************************
             CHANNEL_NAME: master-1
               GROUP_NAME: 
              SOURCE_UUID: a0c35acf-839f-11e6-89f4-080027d65c57
                THREAD_ID: NULL
            SERVICE_STATE: OFF
COUNT_RECEIVED_HEARTBEATS: 49
 LAST_HEARTBEAT_TIMESTAMP: 2016-09-26 13:48:34
 RECEIVED_TRANSACTION_SET: 
        LAST_ERROR_NUMBER: 0
       LAST_ERROR_MESSAGE: 
     LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00
1 row in set (0.00 sec)

mysql> SELECT * FROM performance_schema.replication_connection_status WHERE channel_name='master-2'\G
*************************** 1. row ***************************
             CHANNEL_NAME: master-2
               GROUP_NAME: 
              SOURCE_UUID: a65948cd-839f-11e6-8cb5-080027d65c57
                THREAD_ID: 38
            SERVICE_STATE: ON
COUNT_RECEIVED_HEARTBEATS: 53
 LAST_HEARTBEAT_TIMESTAMP: 2016-09-26 13:50:01
 RECEIVED_TRANSACTION_SET: a65948cd-839f-11e6-8cb5-080027d65c57:1-6
        LAST_ERROR_NUMBER: 0
       LAST_ERROR_MESSAGE: 
     LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00
1 row in set (0.00 sec)

mysql>

mysql> STOP SLAVE FOR CHANNEL 'master-2';
Query OK, 0 rows affected (0.00 sec)

mysql> RESET SLAVE FOR CHANNEL 'master-2';
Query OK, 0 rows affected (0.01 sec)

mysql> SELECT * FROM performance_schema.replication_connection_status WHERE channel_name='master-2'\G
*************************** 1. row ***************************
             CHANNEL_NAME: master-2
               GROUP_NAME: 
              SOURCE_UUID: a65948cd-839f-11e6-8cb5-080027d65c57
                THREAD_ID: NULL
            SERVICE_STATE: OFF
COUNT_RECEIVED_HEARTBEATS: 55
 LAST_HEARTBEAT_TIMESTAMP: 2016-09-26 13:51:01
 RECEIVED_TRANSACTION_SET: 
        LAST_ERROR_NUMBER: 0
       LAST_ERROR_MESSAGE: 
     LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00
1 row in set (0.01 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: 
                  Master_Host: localhost
                  Master_User: multi_source
                  Master_Port: 63301
                Connect_Retry: 60
              Master_Log_File: 
          Read_Master_Log_Pos: 4
               Relay_Log_File: Fabric02-relay-bin-master@002d1.000002
                Relay_Log_Pos: 4
        Relay_Master_Log_File: 
             Slave_IO_Running: No
            Slave_SQL_Running: No
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 0
              Relay_Log_Space: 1903
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1
                  Master_UUID: a0c35acf-839f-11e6-89f4-080027d65c57
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: 
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: a0c35acf-839f-11e6-89f4-080027d65c57:1-8,
a65948cd-839f-11e6-8cb5-080027d65c57:1-6,
abf190f1-839f-11e6-8dbb-080027d65c57:1-2
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: master-1
           Master_TLS_Version: 
*************************** 2. row ***************************
               Slave_IO_State: 
                  Master_Host: localhost
                  Master_User: multi_source
                  Master_Port: 63302
                Connect_Retry: 60
              Master_Log_File: 
          Read_Master_Log_Pos: 4
               Relay_Log_File: Fabric02-relay-bin-master@002d2.000002
                Relay_Log_Pos: 4
        Relay_Master_Log_File: 
             Slave_IO_Running: No
            Slave_SQL_Running: No
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 0
              Relay_Log_Space: 2065
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 2
                  Master_UUID: a65948cd-839f-11e6-8cb5-080027d65c57
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: 
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: a0c35acf-839f-11e6-89f4-080027d65c57:1-8,
a65948cd-839f-11e6-8cb5-080027d65c57:1-6,
abf190f1-839f-11e6-8dbb-080027d65c57:1-2
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: master-2
           Master_TLS_Version: 
2 rows in set (0.00 sec)

mysql> 
 

参考: 
https://dev.mysql.com/doc/refman/5.7/en/replication-multi-source-overview.html
http://dev.mysql.com/doc/refman/5.7/en/replication-multi-source-tutorials.html


Oracle Public CloudにてMySQLサービスが提供開始されました。
MySQLは様々なPublic Cloudにて、既にサービスとして提供されていますが、
MySQL Enterprise版の機能を全て実装した, MySQLはこちらのサービスのみになります。

まだまだこれからの部分もありますが、今後どんどんと進化していくのでTCO削減やセキュリティ対策等で
使えそうでしたら是非活用してみて下さい。

トライアル
OPC MySQL Service詳細とトライアル
https://cloud.oracle.com/mysql
trial

プロビジョニングは非常にシンプルで、インストール時にMySQL Enterprise Monitorも同時インストール可能
provisioning

MySQL Enterprise Monitorを利用すると、MySQLの管理コスト削減をサポートしてくれます。
※Access Listで接続元を絞った運用をお勧めします。
※Access Listで他のインスタンスもモニタリング可能です。
mem

MySQL Enterprise Backupも利用可能です。
※データサイズが大きい場合に特に有効。また色々な追加機能もあります。
※データベースのバックアップ、リカバリー、ポイントインタイムリカバリーをダッシュボードから実行可能。
backup_restore

それぞれのPublic Cloudにそれそれの特徴があり、パフォーマンス、セキュリティ、可用性、安定性、管理コスト等、色々な要素を比較・検討して選択されると思います。MySQLを利用する場合は、Oracle Public CloudのMySQL Serviceも検討してみて下さい。

参考)
MySQL Enterprise Edition
https://www-jp.mysql.com/products/enterprise/


MySQL Enterprise Auditのログローテーションについての追加の手法。
合わせて、NFS上に監査ログを設定していて、万が一NFSが一時的に切れてしまった場合の挙動の確認。

1) ログサイズによる自動ローテーション
audit_log_rotate_on_size

2) mysqlutilitiesを利用したローテーション
mysqlauditadmin.exe

上記は、前回のブログ記事で紹介。
MySQL Audit Logのローテーション

今回は、CRON等で定期的に実行して、自分のカスタマイズしたいようにログをシェルでローテーションする方法です。

3) 自分でSHELLを用意して運用する方法

概要はこちらのマニュアルページで紹介しています。
https://dev.mysql.com/doc/refman/5.7/en/audit-log-logging-control.html

By default, audit_log_rotate_on_size=0 and there is no log rotation. In this case, the audit log plugin closes and reopens the log file when the audit_log_flush value changes from disabled to enabled.
If audit_log_rotate_on_size is greater than 0, setting audit_log_flush has no effect. In this case, the audit log plugin closes and reopens its log file whenever a write to the file causes its size to exceed the audit_log_rotate_on_size value.

MySQLのaudit関連設定

parameter

実際に、以下の様にSHELLを作成してログのローテーション確認してみました。
audit.logがリネームされて、新しいaudit.logファイルが再作成されています。


[root@misc01 mysql]# ls -l
合計 396
-rw-r-----. 1 mysql mysql   2813  9月 21 23:19 audit.log
-rwxr-xr-x. 1 root  root     391  9月 21 23:19 audit_log_rotate.sh
-rw-r-----. 1 mysql mysql  98304 11月 18  2015 osc_tablespace01.ibd
drwxrwxr-x. 2 mysql mysql      6  4月 29  2015 perl5
drwxrwxr-x. 2 mysql mysql   4096  4月 29  2015 ssl
-rw-r-----. 1 mysql mysql 163840  9月 19 21:43 user_tablespace01.ibd
-rw-r-----. 1 mysql mysql  65536  4月 22  2015 user_tablespace02.ibd
-rw-r-----. 1 mysql mysql  65536  4月 20  2015 user_tablespace02_8k.ibd
[root@misc01 mysql]# ./audit_log_rotate.sh 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@misc01 mysql]# ls -l
合計 400
-rw-r-----. 1 mysql mysql     47  9月 21 23:19 audit.log
-rw-r-----. 1 mysql mysql   2822  9月 21 23:19 audit_log_2016-09-21.log
-rwxr-xr-x. 1 root  root     391  9月 21 23:19 audit_log_rotate.sh
-rw-r-----. 1 mysql mysql  98304 11月 18  2015 osc_tablespace01.ibd
drwxrwxr-x. 2 mysql mysql      6  4月 29  2015 perl5
drwxrwxr-x. 2 mysql mysql   4096  4月 29  2015 ssl
-rw-r-----. 1 mysql mysql 163840  9月 19 21:43 user_tablespace01.ibd
-rw-r-----. 1 mysql mysql  65536  4月 22  2015 user_tablespace02.ibd
-rw-r-----. 1 mysql mysql  65536  4月 20  2015 user_tablespace02_8k.ibd

簡易版なので、適宜用途によって加工して利用して下さい。


[root@misc01 mysql]# cat audit_log_rotate.sh 
#!/bin/sh

#######################################
#
#    MySQL Aduit Log Rotate Shell
#
#######################################

TODAY=`date -d 'today' '+%Y-%m-%d'`
AUDIT_LOG=/home/mysql/audit_log_${TODAY}.log

# Archive and rotate audit.log
mv /home/mysql/audit.log ${AUDIT_LOG}

# Flush Audit Log for creating new log file.
mysql -u root -ppassword -e "SET GLOBAL audit_log_flush = ON;"

[root@misc01 mysql]# 


【その他、確認事項】
■ NFS上にaudit.logを配置して、運用中にNFSが切れてしまった場合の挙動の確認。

ログのローテションを確認する為に、一時的にaudit_log_rotate_on_sizeに最小限のサイズを設定しています。


root@localhost [(none)]> show variables like 'audit%';
+-----------------------------+-----------------------+
| Variable_name               | Value                 |
+-----------------------------+-----------------------+
| audit_log_buffer_size       | 1048576               |
| audit_log_connection_policy | ALL                   |
| audit_log_current_session   | OFF                   |
| audit_log_exclude_accounts  |                       |
| audit_log_file              | /home/mysql/audit.log |
| audit_log_filter_id         | 0                     |
| audit_log_flush             | OFF                   |
| audit_log_format            | NEW                   |
| audit_log_include_accounts  |                       |
| audit_log_policy            | ALL                   |
| audit_log_rotate_on_size    | 0                     |
| audit_log_statement_policy  | ALL                   |
| audit_log_strategy          | ASYNCHRONOUS          |
+-----------------------------+-----------------------+
13 rows in set (0.00 sec)

root@localhost [(none)]> set global audit_log_rotate_on_size=4096;
Query OK, 0 rows affected (0.00 sec)

root@localhost [(none)]> show variables like 'audit%';
+-----------------------------+-----------------------+
| Variable_name               | Value                 |
+-----------------------------+-----------------------+
| audit_log_buffer_size       | 1048576               |
| audit_log_connection_policy | ALL                   |
| audit_log_current_session   | OFF                   |
| audit_log_exclude_accounts  |                       |
| audit_log_file              | /home/mysql/audit.log |
| audit_log_filter_id         | 0                     |
| audit_log_flush             | OFF                   |
| audit_log_format            | NEW                   |
| audit_log_include_accounts  |                       |
| audit_log_policy            | ALL                   |
| audit_log_rotate_on_size    | 4096                  |
| audit_log_statement_policy  | ALL                   |
| audit_log_strategy          | ASYNCHRONOUS          |
+-----------------------------+-----------------------+
13 rows in set (0.01 sec)

root@localhost [(none)]> 


ログをリネームして一時的にMySQLからファイルを見えなくしています。この間にAudit対象のQueryを実行して、ローテーションサイズを超えてもadit.logが無いので監査ログは書き込まれません。


[root@misc01 mysql]# ls -l
合計 424
-rw-r-----. 1 mysql mysql    504  9月 22 21:52 audit.log
-rw-r-----. 1 mysql mysql   4466  9月 22 21:52 audit.log.14745487509667319.xml
-rw-r-----. 1 mysql mysql   4169  9月 22 21:52 audit.log.14745487651271064.xml
-rw-r-----. 1 mysql mysql   4169  9月 22 21:52 audit.log.14745487704909257.xml
-rw-r-----. 1 mysql mysql   2822  9月 21 23:19 audit_log_2016-09-21.log
-rwxr-xr-x. 1 root  root     391  9月 21 23:19 audit_log_rotate.sh
-rw-r-----. 1 mysql mysql  98304 11月 18  2015 osc_tablespace01.ibd
drwxrwxr-x. 2 mysql mysql      6  4月 29  2015 perl5
drwxrwxr-x. 2 mysql mysql   4096  4月 29  2015 ssl
-rw-r-----. 1 mysql mysql 163840  9月 19 21:43 user_tablespace01.ibd
-rw-r-----. 1 mysql mysql  65536  4月 22  2015 user_tablespace02.ibd
-rw-r-----. 1 mysql mysql  65536  4月 20  2015 user_tablespace02_8k.ibd

[root@misc01 mysql]# mv audit.log on_purpose_rename_audit.log
[root@misc01 mysql]# ls -l
合計 424
-rw-r-----. 1 mysql mysql   4466  9月 22 21:52 audit.log.14745487509667319.xml
-rw-r-----. 1 mysql mysql   4169  9月 22 21:52 audit.log.14745487651271064.xml
-rw-r-----. 1 mysql mysql   4169  9月 22 21:52 audit.log.14745487704909257.xml
-rw-r-----. 1 mysql mysql   2822  9月 21 23:19 audit_log_2016-09-21.log
-rwxr-xr-x. 1 root  root     391  9月 21 23:19 audit_log_rotate.sh
-rw-r-----. 1 mysql mysql    504  9月 22 21:52 on_purpose_rename_audit.log
-rw-r-----. 1 mysql mysql  98304 11月 18  2015 osc_tablespace01.ibd
drwxrwxr-x. 2 mysql mysql      6  4月 29  2015 perl5
drwxrwxr-x. 2 mysql mysql   4096  4月 29  2015 ssl
-rw-r-----. 1 mysql mysql 163840  9月 19 21:43 user_tablespace01.ibd
-rw-r-----. 1 mysql mysql  65536  4月 22  2015 user_tablespace02.ibd
-rw-r-----. 1 mysql mysql  65536  4月 20  2015 user_tablespace02_8k.ibd
[root@misc01 mysql]# ls -l
合計 424
-rw-r-----. 1 mysql mysql   4466  9月 22 21:52 audit.log.14745487509667319.xml
-rw-r-----. 1 mysql mysql   4169  9月 22 21:52 audit.log.14745487651271064.xml
-rw-r-----. 1 mysql mysql   4169  9月 22 21:52 audit.log.14745487704909257.xml
-rw-r-----. 1 mysql mysql   2822  9月 21 23:19 audit_log_2016-09-21.log
-rwxr-xr-x. 1 root  root     391  9月 21 23:19 audit_log_rotate.sh
-rw-r-----. 1 mysql mysql    961  9月 22 21:53 on_purpose_rename_audit.log
-rw-r-----. 1 mysql mysql  98304 11月 18  2015 osc_tablespace01.ibd
drwxrwxr-x. 2 mysql mysql      6  4月 29  2015 perl5
drwxrwxr-x. 2 mysql mysql   4096  4月 29  2015 ssl
-rw-r-----. 1 mysql mysql 163840  9月 19 21:43 user_tablespace01.ibd
-rw-r-----. 1 mysql mysql  65536  4月 22  2015 user_tablespace02.ibd
-rw-r-----. 1 mysql mysql  65536  4月 20  2015 user_tablespace02_8k.ibd
[root@misc01 mysql]# ls -l
合計 428
-rw-r-----. 1 mysql mysql   4466  9月 22 21:52 audit.log.14745487509667319.xml
-rw-r-----. 1 mysql mysql   4169  9月 22 21:52 audit.log.14745487651271064.xml
-rw-r-----. 1 mysql mysql   4169  9月 22 21:52 audit.log.14745487704909257.xml
-rw-r-----. 1 mysql mysql   2822  9月 21 23:19 audit_log_2016-09-21.log
-rwxr-xr-x. 1 root  root     391  9月 21 23:19 audit_log_rotate.sh
-rw-r-----. 1 mysql mysql   6902  9月 22 21:53 on_purpose_rename_audit.log
-rw-r-----. 1 mysql mysql  98304 11月 18  2015 osc_tablespace01.ibd
drwxrwxr-x. 2 mysql mysql      6  4月 29  2015 perl5
drwxrwxr-x. 2 mysql mysql   4096  4月 29  2015 ssl
-rw-r-----. 1 mysql mysql 163840  9月 19 21:43 user_tablespace01.ibd
-rw-r-----. 1 mysql mysql  65536  4月 22  2015 user_tablespace02.ibd
-rw-r-----. 1 mysql mysql  65536  4月 20  2015 user_tablespace02_8k.ibd

NFSの接続が戻ったと仮定して、ログを元の名前に戻す。
21:56の段階でaudit.logが無かった時のデータがaudit.log.14745489750144595.xmlに書き込まれている。
ログローテーションのサイズ(4096)をオーバーしているがデータがロストしていない事が確認出来る。
また、新規でaudit.logが作成されている。ローテーションも設定サイズできちんと行われている。
audit.logに書き込めない間は、audit_log_bufferに蓄積されているようです。


[root@misc01 mysql]# mv on_purpose_rename_audit.log audit.log
[root@misc01 mysql]# ls -l
合計 440
-rw-r-----. 1 mysql mysql   1418  9月 22 21:56 audit.log
-rw-r-----. 1 mysql mysql   4466  9月 22 21:52 audit.log.14745487509667319.xml
-rw-r-----. 1 mysql mysql   4169  9月 22 21:52 audit.log.14745487651271064.xml
-rw-r-----. 1 mysql mysql   4169  9月 22 21:52 audit.log.14745487704909257.xml
-rw-r-----. 1 mysql mysql  15594  9月 22 21:56 audit.log.14745489750144595.xml
-rw-r-----. 1 mysql mysql   2822  9月 21 23:19 audit_log_2016-09-21.log
-rwxr-xr-x. 1 root  root     391  9月 21 23:19 audit_log_rotate.sh
-rw-r-----. 1 mysql mysql  98304 11月 18  2015 osc_tablespace01.ibd
drwxrwxr-x. 2 mysql mysql      6  4月 29  2015 perl5
drwxrwxr-x. 2 mysql mysql   4096  4月 29  2015 ssl
-rw-r-----. 1 mysql mysql 163840  9月 19 21:43 user_tablespace01.ibd
-rw-r-----. 1 mysql mysql  65536  4月 22  2015 user_tablespace02.ibd
-rw-r-----. 1 mysql mysql  65536  4月 20  2015 user_tablespace02_8k.ibd
[root@misc01 mysql]# 

nfs


補足:ログに書けない間も、MySQLのステータス変数はカウントアップされている事がaudit_log_current_sizeから確認する事が出来ます。
ファイルを戻したタイミングで、ログがファイルに書き込まれ、audit_log_current_sizeは値が小さくなっている事が確認出来ます。

root@localhost [(none)]> show status like 'audit%';
+-------------------------------+-------+
| Variable_name                 | Value |
+-------------------------------+-------+
| audit_log_current_size        | 15585 |
| audit_log_event_max_drop_size | 0     |
| audit_log_events              | 1     |
| audit_log_events_buffered     | 0     |
| audit_log_events_filtered     | 0     |
| audit_log_events_lost         | 0     |
| audit_log_events_written      | 59    |
| audit_log_total_size          | 28389 |
| audit_log_write_waits         | 0     |
+-------------------------------+-------+
9 rows in set (0.00 sec)

root@localhost [(none)]> show status like 'audit%';
+-------------------------------+-------+
| Variable_name                 | Value |
+-------------------------------+-------+
| audit_log_current_size        | 1418  |
| audit_log_event_max_drop_size | 0     |
| audit_log_events              | 1     |
| audit_log_events_buffered     | 0     |
| audit_log_events_filtered     | 0     |
| audit_log_events_lost         | 0     |
| audit_log_events_written      | 62    |
| audit_log_total_size          | 29816 |
| audit_log_write_waits         | 0     |
+-------------------------------+-------+
9 rows in set (0.00 sec)

root@localhost [(none)]> 


MySQL8.0がDockerリポジトリーで提供されているので、Dockerに8.0のイメージをダウンロードしてインストールしてみました。
同時にMySQL8.0の新機能確認として、動的にGlobal Variablesを変更して永続化出来るか?また、データディクショナリの状況も確認してみました。

■ DockerレポジトリーとイメージTag
https://hub.docker.com/r/mysql/mysql-server/
https://hub.docker.com/r/mysql/mysql-server/tags/

MySQL8.0 Dockerイメージダウンロード~起動まで


[root@DockerHost oracle]# docker pull mysql/mysql-server:8.0
8.0: Pulling from mysql/mysql-server
7f369f1cac0b: Pull complete 
897fddccf3d8: Pull complete 
865c22dab1e4: Pull complete 
3e61c960af44: Pull complete 
fcd95ea99f45: Pull complete 
e9cae96efb21: Pull complete 
671450fab9a5: Pull complete 
1b8291aef5a7: Pull complete 
99ef814fb233: Pull complete 
c1add8e582f0: Pull complete 
Digest: sha256:c65b1da17c01749a28fc0b0865f94bf02053f290f23a28bf4fe9d8447dccadd6
Status: Downloaded newer image for mysql/mysql-server:8.0
[root@DockerHost oracle]# docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
mysql/mysql-server   8.0                 c1add8e582f0        5 days ago          393.4 MB
mysql/mysql-server   5.7.12              4e1d42e32c43        5 months ago        296.7 MB
mysql                5.7.10              ea0aca21950d        9 months ago        360.3 MB
mysql/mysql-server   5.7.10              e472f1765697        9 months ago        294.6 MB
[root@DockerHost oracle]# 

[root@DockerHost oracle]# docker run --name mysql8 -v /docker/docker8:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=mysql -d mysql/mysql-server:8.0
f0d7a1a715633b76aaadbba8b8fa6a63b293a9a88d193d28cd44cebd33d08955
[root@DockerHost oracle]# 

[root@DockerHost oracle]# docker ps -a
CONTAINER ID        IMAGE                       COMMAND                  CREATED              STATUS                    PORTS                 NAMES
f0d7a1a71563        mysql/mysql-server:8.0      "/entrypoint.sh mysql"   About a minute ago   Up About a minute         3306/tcp, 33060/tcp   mysql8
88da7fe02e00        mysql:5.7.10                "/entrypoint.sh mysql"   3 months ago         Exited (0) 3 months ago                         my_docker03
4fde03dc4cb5        mysql/mysql-server:5.7.10   "/entrypoint.sh mysql"   8 months ago         Exited (0) 3 months ago                         my_docker02
5152a22b2aa0        mysql:5.7.10                "/entrypoint.sh mysql"   8 months ago         Exited (0) 8 months ago                         my_docker01
[root@DockerHost oracle]# 

[root@DockerHost oracle]# docker inspect -f "{{.Config.Hostname}}, {{.NetworkSettings.IPAddress}}" $(docker ps | grep -v "^CONTAINER" | awk '{print $1}')
f0d7a1a71563, 172.17.0.2
[root@DockerHost oracle]# 

ログインしてバージョン確認

[root@DockerHost oracle]# docker exec -it mysql8 mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 8.0.0-dmr MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 8.0.0-dmr |
+-----------+
1 row in set (0.00 sec)

mysql> 

■ SET PERSIST Statementの確認
http://mysqlserverteam.com/mysql-8-0-persisting-configuration-variables/


mysql> SELECT * FROM performance_schema.variables_info WHERE variable_source != 'COMPILED';
+--------------------+-----------------+---------------+-----------+-----------+
| VARIABLE_NAME      | VARIABLE_SOURCE | VARIABLE_PATH | MIN_VALUE | MAX_VALUE |
+--------------------+-----------------+---------------+-----------+-----------+
| datadir            | GLOBAL          | /etc/my.cnf   | 0         | 0         |
| foreign_key_checks | DYNAMIC         |               | 0         | 0         |
| log_error          | GLOBAL          | /etc/my.cnf   | 0         | 0         |
| pid_file           | GLOBAL          | /etc/my.cnf   | 0         | 0         |
| secure_file_priv   | GLOBAL          | /etc/my.cnf   | 0         | 0         |
| skip_name_resolve  | GLOBAL          | /etc/my.cnf   | 0         | 0         |
| socket             | GLOBAL          | /etc/my.cnf   | 0         | 0         |
+--------------------+-----------------+---------------+-----------+-----------+
7 rows in set (0.00 sec)

mysql> show variables like 'log_timestamps';                                               
+----------------+-------+
| Variable_name  | Value |
+----------------+-------+
| log_timestamps | UTC   |
+----------------+-------+
1 row in set (0.01 sec)

mysql> SET PERSIST log_timestamps='SYSTEM';
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like 'log_timestamps';                                               
+----------------+--------+
| Variable_name  | Value  |
+----------------+--------+
| log_timestamps | SYSTEM |
+----------------+--------+
1 row in set (0.00 sec)

mysql> SELECT * FROM performance_schema.variables_info WHERE variable_source != 'COMPILED';
+--------------------+-----------------+---------------+-----------+-----------+
| VARIABLE_NAME      | VARIABLE_SOURCE | VARIABLE_PATH | MIN_VALUE | MAX_VALUE |
+--------------------+-----------------+---------------+-----------+-----------+
| datadir            | GLOBAL          | /etc/my.cnf   | 0         | 0         |
| foreign_key_checks | DYNAMIC         |               | 0         | 0         |
| log_error          | GLOBAL          | /etc/my.cnf   | 0         | 0         |
| log_timestamps     | DYNAMIC         |               | 0         | 0         |
| pid_file           | GLOBAL          | /etc/my.cnf   | 0         | 0         |
| secure_file_priv   | GLOBAL          | /etc/my.cnf   | 0         | 0         |
| skip_name_resolve  | GLOBAL          | /etc/my.cnf   | 0         | 0         |
| socket             | GLOBAL          | /etc/my.cnf   | 0         | 0         |
+--------------------+-----------------+---------------+-----------+-----------+
8 rows in set (0.00 sec)

mysql> 

再起動後も値が反映されている事を確認


[root@DockerHost oracle]# docker stop f0d7a1a71563
f0d7a1a71563
[root@DockerHost oracle]# docker ps -a
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                     PORTS               NAMES
f0d7a1a71563        mysql/mysql-server:8.0      "/entrypoint.sh mysql"   11 minutes ago      Exited (0) 2 seconds ago                       mysql8
88da7fe02e00        mysql:5.7.10                "/entrypoint.sh mysql"   3 months ago        Exited (0) 3 months ago                        my_docker03
4fde03dc4cb5        mysql/mysql-server:5.7.10   "/entrypoint.sh mysql"   8 months ago        Exited (0) 3 months ago                        my_docker02
5152a22b2aa0        mysql:5.7.10                "/entrypoint.sh mysql"   8 months ago        Exited (0) 8 months ago                        my_docker01
[root@DockerHost oracle]# docker start f0d7a1a71563
f0d7a1a71563
[root@DockerHost oracle]# docker ps -a
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                    PORTS                 NAMES
f0d7a1a71563        mysql/mysql-server:8.0      "/entrypoint.sh mysql"   11 minutes ago      Up 2 seconds              3306/tcp, 33060/tcp   mysql8
88da7fe02e00        mysql:5.7.10                "/entrypoint.sh mysql"   3 months ago        Exited (0) 3 months ago                         my_docker03
4fde03dc4cb5        mysql/mysql-server:5.7.10   "/entrypoint.sh mysql"   8 months ago        Exited (0) 3 months ago                         my_docker02
5152a22b2aa0        mysql:5.7.10                "/entrypoint.sh mysql"   8 months ago        Exited (0) 8 months ago                         my_docker01
[root@DockerHost oracle]# 

[root@DockerHost oracle]# docker exec -it mysql8 mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 8.0.0-dmr MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'log_timestamps';
+----------------+--------+
| Variable_name  | Value  |
+----------------+--------+
| log_timestamps | SYSTEM |
+----------------+--------+
1 row in set (0.02 sec)

mysql> 

(補足) SET PERSISTで設定変更した、GLOBAL変数は以下のようにmysqld-auto.cnfから読み込まれています。

Under the hood the settings will be persisted to a file named mysqld-auto.cnf which will be created in the data directory.
This file will be read during server startup just like any other configuration file, and all variables present in this file will be applied as the highest priority.
That means the file mysqld-auto.cnf will be the last file to be applied on server startup (even after command-line options) and takes precedence if a specific setting has been specified in more than one location.


mysql>  select VARIABLE_NAME,VARIABLE_SOURCE,VARIABLE_PATH from performance_schema.variables_info where VARIABLE_PATH <> '';
+-------------------+-----------------+--------------------------------+
| VARIABLE_NAME     | VARIABLE_SOURCE | VARIABLE_PATH                  |
+-------------------+-----------------+--------------------------------+
| datadir           | GLOBAL          | /etc/my.cnf                    |
| log_error         | GLOBAL          | /etc/my.cnf                    |
| log_timestamps    | PERSISTED       | /var/lib/mysql/mysqld-auto.cnf |
| pid_file          | GLOBAL          | /etc/my.cnf                    |
| secure_file_priv  | GLOBAL          | /etc/my.cnf                    |
| skip_name_resolve | GLOBAL          | /etc/my.cnf                    |
| socket            | GLOBAL          | /etc/my.cnf                    |
+-------------------+-----------------+--------------------------------+
7 rows in set (0.00 sec)

mysql> 

■MySQL8.0データディクショナリの確認


[root@DockerHost var]# docker exec -it mysql8 mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.0-dmr MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> source /var/lib/mysql/init-docker-sakila.sql

Query OK, 200 rows affected (0.01 sec)
Records: 200  Duplicates: 0  Warnings: 0

Query OK, 603 rows affected (0.04 sec)
Records: 603  Duplicates: 0  Warnings: 0

Query OK, 600 rows affected (0.01 sec)
Records: 600  Duplicates: 0  Warnings: 0

<SNIP>

Query OK, 109 rows affected (0.01 sec)
Records: 109  Duplicates: 0  Warnings: 0

Query OK, 599 rows affected (0.04 sec)
Records: 599  Duplicates: 0  Warnings: 0

Query OK, 1000 rows affected (0.17 sec)
Records: 1000  Duplicates: 0  Warnings: 0

Query OK, 5462 rows affected (0.18 sec)
Records: 5462  Duplicates: 0  Warnings: 0

Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sakila             |
| sys                |
+--------------------+
5 rows in set (0.01 sec)

mysql> 

■ MySQL8.0で作成したSakilaサンプルデータベースのデータディクショナリー確認

[root@DockerHost sakila]# ls -l /docker/docker8/sakila
total 25104
-rw-r----- 1 27 27   147456 Sep 20 13:55 actor.ibd
-rw-r----- 1 27 27   278528 Sep 20 13:55 address.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 category.ibd
-rw-r----- 1 27 27   147456 Sep 20 13:55 city.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 country.ibd
-rw-r----- 1 27 27   229376 Sep 20 13:55 customer.ibd
-rw-r----- 1 27 27   376832 Sep 20 13:55 film_actor.ibd
-rw-r----- 1 27 27   180224 Sep 20 13:55 film_category.ibd
-rw-r----- 1 27 27   376832 Sep 20 13:55 film.ibd
-rw-r----- 1 27 27   294912 Sep 20 13:55 film_text.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 FTS_000000000000005b_00000000000000ae_INDEX_1.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 FTS_000000000000005b_00000000000000ae_INDEX_2.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 FTS_000000000000005b_00000000000000ae_INDEX_3.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 FTS_000000000000005b_00000000000000ae_INDEX_4.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 FTS_000000000000005b_00000000000000ae_INDEX_5.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 FTS_000000000000005b_00000000000000ae_INDEX_6.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 FTS_000000000000005b_BEING_DELETED_CACHE.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 FTS_000000000000005b_BEING_DELETED.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 FTS_000000000000005b_CONFIG.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 FTS_000000000000005b_DELETED_CACHE.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 FTS_000000000000005b_DELETED.ibd
-rw-r----- 1 27 27   475136 Sep 20 13:56 inventory.ibd
-rw-r----- 1 27 27   131072 Sep 20 13:55 language.ibd
-rw-r----- 1 27 27 10485760 Sep 20 13:56 payment.ibd
-rw-r----- 1 27 27 10485760 Sep 20 13:56 rental.ibd
-rw-r----- 1 27 27   180224 Sep 20 13:55 staff.ibd
-rw-r----- 1 27 27   163840 Sep 20 13:55 store.ibd
[root@DockerHost sakila]# 

■ MySQL5.7で作成したSakilaサンプルデータベースのデータディクショナリー確認
frmやTRGファイルが存在しています。


[root@DockerHost sakila]# ls -l /docker/docker03/sakila/
total 24620
-rw-r----- 1 999 999     8694 Jun  7 07:17 actor.frm
-rw-r----- 1 999 999   114688 Jun  7 07:17 actor.ibd
-rw-r----- 1 999 999     2863 Jun  7 07:17 actor_info.frm
-rw-r----- 1 999 999     8878 Jun  7 07:17 address.frm
-rw-r----- 1 999 999   245760 Jun  7 07:17 address.ibd
-rw-r----- 1 999 999     8648 Jun  7 07:17 category.frm
-rw-r----- 1 999 999    98304 Jun  7 07:17 category.ibd
-rw-r----- 1 999 999     8682 Jun  7 07:17 city.frm
-rw-r----- 1 999 999   114688 Jun  7 07:17 city.ibd
-rw-r----- 1 999 999     8652 Jun  7 07:17 country.frm
-rw-r----- 1 999 999    98304 Jun  7 07:17 country.ibd
-rw-r----- 1 999 999       40 Jun  7 07:17 customer_create_date.TRN
-rw-r----- 1 999 999     8890 Jun  7 07:17 customer.frm
-rw-r----- 1 999 999   196608 Jun  7 07:17 customer.ibd
-rw-r----- 1 999 999     1892 Jun  7 07:17 customer_list.frm
-rw-r----- 1 999 999      300 Jun  7 07:17 customer.TRG
-rw-r----- 1 999 999       61 Jun  7 07:17 db.opt
-rw-r----- 1 999 999       36 Jun  7 07:17 del_film.TRN
-rw-r----- 1 999 999     8648 Jun  7 07:17 film_actor.frm
-rw-r----- 1 999 999   344064 Jun  7 07:17 film_actor.ibd
-rw-r----- 1 999 999     8654 Jun  7 07:17 film_category.frm
-rw-r----- 1 999 999   147456 Jun  7 07:17 film_category.ibd
-rw-r----- 1 999 999     9188 Jun  7 07:17 film.frm
-rw-r----- 1 999 999   344064 Jun  7 07:17 film.ibd
-rw-r----- 1 999 999     2616 Jun  7 07:17 film_list.frm
-rw-r----- 1 999 999     8642 Jun  7 07:17 film_text.frm
-rw-r----- 1 999 999   262144 Jun  7 07:17 film_text.ibd
-rw-r----- 1 999 999     1093 Jun  7 07:17 film.TRG
-rw-r----- 1 999 999    98304 Jun  7 07:17 FTS_0000000000000035_0000000000000045_INDEX_1.ibd
-rw-r----- 1 999 999   131072 Jun  7 07:17 FTS_0000000000000035_0000000000000045_INDEX_2.ibd
-rw-r----- 1 999 999    98304 Jun  7 07:17 FTS_0000000000000035_0000000000000045_INDEX_3.ibd
-rw-r----- 1 999 999    98304 Jun  7 07:17 FTS_0000000000000035_0000000000000045_INDEX_4.ibd
-rw-r----- 1 999 999   131072 Jun  7 07:17 FTS_0000000000000035_0000000000000045_INDEX_5.ibd
-rw-r----- 1 999 999    98304 Jun  7 07:17 FTS_0000000000000035_0000000000000045_INDEX_6.ibd
-rw-r----- 1 999 999    98304 Jun  7 07:17 FTS_0000000000000035_BEING_DELETED_CACHE.ibd
-rw-r----- 1 999 999    98304 Jun  7 07:17 FTS_0000000000000035_BEING_DELETED.ibd
-rw-r----- 1 999 999    98304 Jun  7 07:17 FTS_0000000000000035_CONFIG.ibd
-rw-r----- 1 999 999    98304 Jun  7 07:17 FTS_0000000000000035_DELETED_CACHE.ibd
-rw-r----- 1 999 999    98304 Jun  7 07:17 FTS_0000000000000035_DELETED.ibd
-rw-r----- 1 999 999       36 Jun  7 07:17 ins_film.TRN
-rw-r----- 1 999 999     8694 Jun  7 07:17 inventory.frm
-rw-r----- 1 999 999   442368 Jun  7 07:17 inventory.ibd
-rw-r----- 1 999 999     8648 Jun  7 07:17 language.frm
-rw-r----- 1 999 999    98304 Jun  7 07:17 language.ibd
-rw-r----- 1 999 999     3234 Jun  7 07:17 nicer_but_slower_film_list.frm
-rw-r----- 1 999 999       39 Jun  7 07:17 payment_date.TRN
-rw-r----- 1 999 999     8818 Jun  7 07:17 payment.frm
-rw-r----- 1 999 999 10485760 Jun  7 07:17 payment.ibd
-rw-r----- 1 999 999      292 Jun  7 07:17 payment.TRG
-rw-r----- 1 999 999       38 Jun  7 07:17 rental_date.TRN
-rw-r----- 1 999 999     8830 Jun  7 07:17 rental.frm
-rw-r----- 1 999 999 10485760 Jun  7 07:17 rental.ibd
-rw-r----- 1 999 999      289 Jun  7 07:17 rental.TRG
-rw-r----- 1 999 999     1669 Jun  7 07:17 sales_by_film_category.frm
-rw-r----- 1 999 999     2344 Jun  7 07:17 sales_by_store.frm
-rw-r----- 1 999 999     8952 Jun  7 07:17 staff.frm
-rw-r----- 1 999 999   147456 Jun  7 07:17 staff.ibd
-rw-r----- 1 999 999     1705 Jun  7 07:17 staff_list.frm
-rw-r----- 1 999 999     8708 Jun  7 07:17 store.frm
-rw-r----- 1 999 999   131072 Jun  7 07:17 store.ibd
-rw-r----- 1 999 999       36 Jun  7 07:17 upd_film.TRN

メモ:MySQL8.0 DATA DICTIONARY

Data dictionary tables are invisible. They cannot be read with SELECT, do not appear in the output of SHOW TABLES,
are not listed in the INFORMATION_SCHEMA.TABLES table, and so forth. However, in most cases there are corresponding INFORMATION_SCHEMA tables
that can be queried. Conceptually, the INFORMATION_SCHEMA provides a view through which MySQL exposes data dictionary metadata.
For example, you cannot select from the mysql.schemata table directly:
http://dev.mysql.com/doc/refman/8.0/en/system-database.html#system-database-data-dictionary-tables


mysql> SELECT * FROM mysql.schemata;                                                                         
ERROR 3554 (HY000): Access to system table 'mysql.schemata' is rejected.
mysql> 

mysql> SELECT * FROM INFORMATION_SCHEMA.SCHEMATA limit 10; 
+--------------+--------------------+----------------------------+------------------------+----------+
| CATALOG_NAME | SCHEMA_NAME        | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH |
+--------------+--------------------+----------------------------+------------------------+----------+
| def          | mysql              | latin1                     | latin1_swedish_ci      |     NULL |
| def          | information_schema | utf8                       | utf8_general_ci        |     NULL |
| def          | performance_schema | utf8                       | utf8_general_ci        |     NULL |
| def          | sys                | utf8                       | utf8_general_ci        |     NULL |
| def          | sakila             | latin1                     | latin1_swedish_ci      |     NULL |
+--------------+--------------------+----------------------------+------------------------+----------+
5 rows in set (0.00 sec)

mysql> select * from INNODB_SYS_TABLES where NAME LIKE 'sakila%';
+----------+------------------------------------------------------+------+--------+-------+------------+---------------+------------+
| TABLE_ID | NAME                                                 | FLAG | N_COLS | SPACE | ROW_FORMAT | ZIP_PAGE_SIZE | SPACE_TYPE |
+----------+------------------------------------------------------+------+--------+-------+------------+---------------+------------+
|       97 | sakila/FTS_000000000000005b_00000000000000ae_INDEX_1 |   33 |      8 |    85 | Dynamic    |             0 | Single     |
|       98 | sakila/FTS_000000000000005b_00000000000000ae_INDEX_2 |   33 |      8 |    86 | Dynamic    |             0 | Single     |
|       99 | sakila/FTS_000000000000005b_00000000000000ae_INDEX_3 |   33 |      8 |    87 | Dynamic    |             0 | Single     |
|      100 | sakila/FTS_000000000000005b_00000000000000ae_INDEX_4 |   33 |      8 |    88 | Dynamic    |             0 | Single     |
|      101 | sakila/FTS_000000000000005b_00000000000000ae_INDEX_5 |   33 |      8 |    89 | Dynamic    |             0 | Single     |
|      102 | sakila/FTS_000000000000005b_00000000000000ae_INDEX_6 |   33 |      8 |    90 | Dynamic    |             0 | Single     |
|       92 | sakila/FTS_000000000000005b_BEING_DELETED            |   33 |      4 |    80 | Dynamic    |             0 | Single     |
|       93 | sakila/FTS_000000000000005b_BEING_DELETED_CACHE      |   33 |      4 |    81 | Dynamic    |             0 | Single     |
|       94 | sakila/FTS_000000000000005b_CONFIG                   |   33 |      5 |    82 | Dynamic    |             0 | Single     |
|       95 | sakila/FTS_000000000000005b_DELETED                  |   33 |      4 |    83 | Dynamic    |             0 | Single     |
|       96 | sakila/FTS_000000000000005b_DELETED_CACHE            |   33 |      4 |    84 | Dynamic    |             0 | Single     |
|      109 | sakila/OPC                                           |   33 |      4 |   100 | Dynamic    |             0 | Single     |
|       82 | sakila/actor                                         |   33 |      7 |    70 | Dynamic    |             0 | Single     |
|       83 | sakila/address                                       |   33 |     12 |    71 | Dynamic    |             0 | Single     |
|       84 | sakila/category                                      |   33 |      6 |    72 | Dynamic    |             0 | Single     |
|       85 | sakila/city                                          |   33 |      7 |    73 | Dynamic    |             0 | Single     |
|       86 | sakila/country                                       |   33 |      6 |    74 | Dynamic    |             0 | Single     |
|       87 | sakila/customer                                      |   33 |     12 |    75 | Dynamic    |             0 | Single     |
|       88 | sakila/film                                          |   33 |     16 |    76 | Dynamic    |             0 | Single     |
|       89 | sakila/film_actor                                    |   33 |      6 |    77 | Dynamic    |             0 | Single     |
|       90 | sakila/film_category                                 |   33 |      6 |    78 | Dynamic    |             0 | Single     |
|       91 | sakila/film_text                                     |   33 |      7 |    79 | Dynamic    |             0 | Single     |
|      103 | sakila/inventory                                     |   33 |      7 |    91 | Dynamic    |             0 | Single     |
|      104 | sakila/language                                      |   33 |      6 |    92 | Dynamic    |             0 | Single     |
|      105 | sakila/payment                                       |   33 |     10 |    93 | Dynamic    |             0 | Single     |
|      106 | sakila/rental                                        |   33 |     10 |    94 | Dynamic    |             0 | Single     |
|      107 | sakila/staff                                         |   33 |     14 |    95 | Dynamic    |             0 | Single     |
|      108 | sakila/store                                         |   33 |      7 |    96 | Dynamic    |             0 | Single     |
+----------+------------------------------------------------------+------+--------+-------+------------+---------------+------------+
28 rows in set (0.00 sec)

mysql> select * from INNODB_SYS_DATAFILES limit 5;
+-------+------------------------------+
| SPACE | PATH                         |
+-------+------------------------------+
|     2 | ./mysql/version.ibd          |
|     3 | ./mysql/character_sets.ibd   |
|     4 | ./mysql/collations.ibd       |
|     5 | ./mysql/tablespaces.ibd      |
|     6 | ./mysql/tablespace_files.ibd |
+-------+------------------------------+
5 rows in set (0.01 sec)

mysql> 

■ 参照
15.6 Data Dictionary Usage Differences
The MySQL 8.0.0 Milestone Release is available


MySQL Clusterの検証をIBM(Softlayer)さん、株式会社インフィニットループさんと共同で行って、
結果を先日のCEDECで発表した時の資料です。インフィニットループさんがOpenSourceのゲームで検証してくれているので、内容的には参考になるかと思います。

1. MySQL Clusterを稼働させるにはネットワークが非常に重要
2. MySQL Clusterを稼働させる場合、仮想環境のCommit Ratioがコントロール出来ない場合はベアメタルが良い。
3. 仮想、ベアメタル共にSSDを利用していてもISCSIよりもやはりローカルの方が断然良い。
4. MaxNoOfExecutionThreadsより、ThreadConfigで丁寧に調整した方がパフォーマンス良い(この検証では1.2倍)
5. 今回のSYSBENCH0.5での検証では、データの偏りがあったので思うようにパフォーマンスが出なかった。(パーティションで対応可能)
6・ Sysbench0.5のOLTP R/Wの処理は、5割程がMySQL Cluster向きで残りの5割はInnDB向きの処理。(データノードを跨る処理が多かった)

今回は2週間でしたが、もう少し時間があればより最適なパラメータ構成を設定出来たかと思います。
皆さんも利用する場合は、事前に最適なパラメータ確認を実施して下さい。

MySQL Cluster Community Edition Download
http://dev.mysql.com/downloads/cluster/

Commercial Edition追加ツールとサポート
https://www-jp.mysql.com/products/cluster/


MySQL5.7.14のGroup Replication DMR版が先月リリースされていたので、基本的な動作確認をしました。
まだ、DMR版なので前回の5.7.10とまた微妙に異なっていて、
group_replication_peer_addressesがgroup_replication_group_seedsに代わっていたり、
group_replication_recovery_userやgroup_replication_recovery_passwordが無くなっていたりします。

MySQL Group Replication: A Quick Start Guide
http://mysqlhighavailability.com/mysql-group-replication-a-quick-start-guide/

MySQL5.7.10版での検証: MYSQL GROUP REPLICATION
http://variable.jp/2016/07/18/mysql-group-replication/

検証環境のオプションファイル設定
基本的にはserver_idをノード間で変更しているのみ。

# Binary logging and Replication
server_id                      = 1
log_bin                        = mysql-bin
binlog_cache_size              = 1M
binlog_stmt_cache_size         = 1M                                  # Since 5.5
max_binlog_size                = 64M                                 # Make bigger for high traffic to reduce number of files
sync_binlog                    = 0                                   # Set to 1 or higher to reduce potential loss of binary-log data
expire_logs_days               = 30                                  # We will survive easter holidays
#binlog_format                 = MIXED                               # Use MIXED if you experience some troubles
binlog_format                  = ROW
binlog_row_image               = MINIMAL                             # Since 5.6
binlog_rows_query_log_events   = 1                                   # Log Statement in ROW Base Binlog
# auto_increment_increment       = 1                                 # For Master/Master set-ups use 1 and 2
# auto_increment_offset          = 2                                 # For Master/Master set-ups use 2 for both nodes
log_timestamps = SYSTEM


# Add for GTID Mode
gtid-mode                      = on
enforce-gtid-consistency       = on
log-slave-updates

master_info_repository        = TABLE
relay_log_info_repository     = TABLE

# Group replication
# plugin-load = group_replication.so
group_replication_start_on_boot = ON
group_replication_bootstrap_group = OFF
# transaction-write-set-extraction=MURMUR32
transaction-write-set-extraction=XXHASH64
binlog-checksum=NONE
group_replication = FORCE_PLUS_PERMANENT
transaction-write-set-extraction = XXHASH64
group_replication_group_name= "00000000-1111-2222-3333-123456789ABC"
#group_replication_recovery_user='rpl_user'                             #commented out at upgrading to 5.7.14
#group_replication_recovery_password='rpl_pass'                         #commented out at upgrading to 5.7.14
group_replication_recovery_retry_count= 2
group_replication_recovery_reconnect_interval= 120
group_replication_local_address="192.168.56.101:6606"
#group_replication_peer_addresses= "192.168.56.101:18620,192.168.56.102:18620" #commented out at upgrading to 5.7.14
group_replication_group_seeds =  "192.168.56.101:6606,192.168.56.102:6606"

# 5.7.14
relay-log-recovery = ON
slave-parallel-type = LOGICAL_CLOCK
slave-preserve-commit-order = ON
slave-rows-search-algorithms = 'INDEX_SCAN,HASH_SCAN'
slave-type-conversions = ALL_NON_LOSSY
sync-master-info = 1000
sync-relay-log = 1000
slave-parallel-workers = 0

■Boot Strap Nodeの起動

– It will not try and participate in any group communication when starting but will instead configure the group as consisting only of itself.
– Any subsequent member that attempts to join the group will sync itself up with the state of this instance.

We need to pick one member and declare that it is the bootstrap node by setting group_replication_bootstrap_group=ON
Just remember to turn group_replication_bootstrap_group=OFF again after the first member is up.

root@localhost [GR_TEST]> select @@version,@@hostname;
+-----------------------+------------+
| @@version             | @@hostname |
+-----------------------+------------+
| 5.7.14-labs-gr080-log | misc01     |
+-----------------------+------------+
1 row in set (0.00 sec)

root@localhost [GR_TEST]> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 29ea17bc-3848-11e6-9900-0800279ca844 | misc01      |        3306 | OFFLINE      |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
1 row in set (0.00 sec)

root@localhost [GR_TEST]> show variables like 'group_replication_bootstrap_group';
+-----------------------------------+-------+
| Variable_name                     | Value |
+-----------------------------------+-------+
| group_replication_bootstrap_group | OFF   |
+-----------------------------------+-------+
1 row in set (0.03 sec)

root@localhost [GR_TEST]> SET GLOBAL group_replication_bootstrap_group= 1;
Query OK, 0 rows affected (0.00 sec)

root@localhost [GR_TEST]> show variables like 'group_replication_bootstrap_group';
+-----------------------------------+-------+
| Variable_name                     | Value |
+-----------------------------------+-------+
| group_replication_bootstrap_group | ON    |
+-----------------------------------+-------+
1 row in set (0.00 sec)

root@localhost [GR_TEST]> START GROUP_REPLICATION;
Query OK, 0 rows affected (1.07 sec)

root@localhost [GR_TEST]> SET GLOBAL group_replication_bootstrap_group= 0;
Query OK, 0 rows affected (0.00 sec)

root@localhost [GR_TEST]> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 29ea17bc-3848-11e6-9900-0800279ca844 | misc01      |        3306 | ONLINE       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
1 row in set (0.00 sec)

root@localhost [GR_TEST]> select * from performance_schema.replication_group_member_stats\G
*************************** 1. row ***************************
                      CHANNEL_NAME: group_replication_applier
                           VIEW_ID: 14732520384730018:1
                         MEMBER_ID: 29ea17bc-3848-11e6-9900-0800279ca844
       COUNT_TRANSACTIONS_IN_QUEUE: 0
        COUNT_TRANSACTIONS_CHECKED: 0
          COUNT_CONFLICTS_DETECTED: 0
COUNT_TRANSACTIONS_ROWS_VALIDATING: 0
TRANSACTIONS_COMMITTED_ALL_MEMBERS: 
    LAST_CONFLICT_FREE_TRANSACTION: 
1 row in set (0.00 sec)

root@localhost [GR_TEST]> 

■2番目のノード追加
Specify valid MySQL credentials that this node will use when requesting GTIDs from existing members of the
group (a seed or donor) necessary to perform an automated recovery (such as when joining the group, which we’ll do next):
CHANGE MASTER TO MASTER_USER=’rpl_user’, MASTER_PASSWORD=’rpl_pass’ FOR CHANNEL ‘group_replication_recovery’;
Have the new node join to become a member with: STOP GROUP_REPLICATION; START GROUP_REPLICATION; (STOP is necessary because we have start_on_boot enabled).

root@localhost [GR_TEST]>  select @@version,@@hostname;
+-----------------------+------------+
| @@version             | @@hostname |
+-----------------------+------------+
| 5.7.14-labs-gr080-log | misc02     |
+-----------------------+------------+
1 row in set (0.00 sec)

root@localhost [GR_TEST]> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 5b07d5d8-4057-11e6-a315-0800279cea3c | misc02      |        3306 | OFFLINE      |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
1 row in set (0.00 sec)

root@localhost [GR_TEST]> CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='rpl_pass' FOR CHANNEL 'group_replication_recovery';
Query OK, 0 rows affected, 2 warnings (0.02 sec)

root@localhost [GR_TEST]> STOP GROUP_REPLICATION;START GROUP_REPLICATION;
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (7.04 sec)

root@localhost [GR_TEST]> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 29ea17bc-3848-11e6-9900-0800279ca844 | misc01      |        3306 | ONLINE       |
| group_replication_applier | 5b07d5d8-4057-11e6-a315-0800279cea3c | misc02      |        3306 | ONLINE       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
2 rows in set (0.00 sec)

root@localhost [GR_TEST]> select * from performance_schema.replication_group_member_stats\G
*************************** 1. row ***************************
                      CHANNEL_NAME: group_replication_applier
                           VIEW_ID: 14732520384730018:2
                         MEMBER_ID: 5b07d5d8-4057-11e6-a315-0800279cea3c
       COUNT_TRANSACTIONS_IN_QUEUE: 0
        COUNT_TRANSACTIONS_CHECKED: 0
          COUNT_CONFLICTS_DETECTED: 0
COUNT_TRANSACTIONS_ROWS_VALIDATING: 0
TRANSACTIONS_COMMITTED_ALL_MEMBERS: 
    LAST_CONFLICT_FREE_TRANSACTION: 
1 row in set (0.00 sec)

root@localhost [GR_TEST]> select user_name, user_password from mysql.slave_master_info where channel_name = 'group_replication_recovery';
+-----------+---------------+
| user_name | user_password |
+-----------+---------------+
| rpl_user  | rpl_pass      |
+-----------+---------------+
1 row in set (0.00 sec)

root@localhost [GR_TEST]> 

■ 追加の確認と設定(NODE2を追加後にBootstrapノードで実行)

You should also now execute step 3 (the CHANGE MASTER TO) on the node we used to bootstrap the group, if you haven’t previously done so.

root@localhost [GR_TEST]> SELECT * FROM performance_schema.replication_group_members;
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
| group_replication_applier | 29ea17bc-3848-11e6-9900-0800279ca844 | misc01      |        3306 | ONLINE       |
| group_replication_applier | 5b07d5d8-4057-11e6-a315-0800279cea3c | misc02      |        3306 | ONLINE       |
+---------------------------+--------------------------------------+-------------+-------------+--------------+
2 rows in set (0.00 sec)

root@localhost [GR_TEST]> CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='rpl_pass' FOR CHANNEL 'group_replication_recovery';
Query OK, 0 rows affected, 2 warnings (0.02 sec)

root@localhost [GR_TEST]> select user_name, user_password from mysql.slave_master_info where channel_name = 'group_replication_recovery';
+-----------+---------------+
| user_name | user_password |
+-----------+---------------+
| rpl_user  | rpl_pass      |
+-----------+---------------+
1 row in set (0.00 sec)

root@localhost [GR_TEST]> 

以下、基本動作確認

■マルチマスターの基本動作確認 (NODE1とNODE2からINSERT)

NODE1)

root@localhost [GR_TEST]> desc T01;
+--------------+-------------+------+-----+-------------------+-------+
| Field        | Type        | Null | Key | Default           | Extra |
+--------------+-------------+------+-----+-------------------+-------+
| ID           | int(11)     | NO   | PRI | NULL              |       |
| MEMO         | varchar(30) | NO   |     |                   |       |
| created_time | datetime    | YES  |     | CURRENT_TIMESTAMP |       |
+--------------+-------------+------+-----+-------------------+-------+
3 rows in set (0.01 sec)

root@localhost [GR_TEST]> insert into T01(ID,MEMO) values(1,@@hostname);
Query OK, 1 row affected (0.01 sec)

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
+----+--------+---------------------+
2 rows in set (0.00 sec)

root@localhost [GR_TEST]> 

NODE2)

root@localhost [GR_TEST]> select * from T01;
Empty set (0.00 sec)

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
+----+--------+---------------------+
1 row in set (0.00 sec)

root@localhost [GR_TEST]> insert into T01(ID,MEMO) values(2,@@hostname);
Query OK, 1 row affected (0.01 sec)

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
+----+--------+---------------------+
2 rows in set (0.00 sec)

root@localhost [GR_TEST]>

blog2

■トランザクションの確認
NODE1)

root@localhost [GR_TEST]> start transaction;insert into T01(ID,MEMO) values(3,@@hostname);
Query OK, 0 rows affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

root@localhost [GR_TEST]> commit;
Query OK, 0 rows affected (0.01 sec)

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
|  3 | misc01 | 2016-09-07 22:09:10 |
|  4 | misc02 | 2016-09-07 22:09:13 |
+----+--------+---------------------+
4 rows in set (0.00 sec)

root@localhost [GR_TEST]> 

NODE2) 上記を実行中に同じテーブルに対してINSERTは問題ない。

root@localhost [GR_TEST]> start transaction;insert into T01(ID,MEMO) values(4,@@hostname);
Query OK, 0 rows affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
|  4 | misc02 | 2016-09-07 22:09:13 |
+----+--------+---------------------+
3 rows in set (0.00 sec)

root@localhost [GR_TEST]> commit;
Query OK, 0 rows affected (0.01 sec)

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
|  3 | misc01 | 2016-09-07 22:09:10 |
|  4 | misc02 | 2016-09-07 22:09:13 |
+----+--------+---------------------+
4 rows in set (0.00 sec)

root@localhost [GR_TEST]> 

■ 同じ行を更新してみる(where ID=4)
NODE1)

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
|  3 | misc01 | 2016-09-07 22:09:10 |
|  4 | misc02 | 2016-09-07 22:09:13 |
+----+--------+---------------------+
4 rows in set (0.00 sec)

root@localhost [GR_TEST]> start transaction;update T01 set MEMO = 'MISC02' where ID = 4;
Query OK, 0 rows affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
|  3 | misc01 | 2016-09-07 22:09:10 |
|  4 | MISC02 | 2016-09-07 22:09:13 |
+----+--------+---------------------+
4 rows in set (0.00 sec)

root@localhost [GR_TEST]> commit;
Query OK, 0 rows affected (0.01 sec)

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
|  3 | misc01 | 2016-09-07 22:09:10 |
|  4 | MISC02 | 2016-09-07 22:09:13 |
+----+--------+---------------------+
4 rows in set (0.00 sec)

root@localhost [GR_TEST]> start transaction;update T01 set MEMO = 'misc02' where ID = 4;
Query OK, 0 rows affected (0.00 sec)

Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

root@localhost [GR_TEST]> commit;
Query OK, 0 rows affected (0.01 sec)

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
|  3 | misc01 | 2016-09-07 22:09:10 |
|  4 | misc02 | 2016-09-07 22:09:13 |
+----+--------+---------------------+
4 rows in set (0.00 sec)

root@localhost [GR_TEST]> 

NODE2) NODE1のトランザクション中に実行。
※トランザクション発行の順番では無く、先にcommitした方が優先される。

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
|  3 | misc01 | 2016-09-07 22:09:10 |
|  4 | misc02 | 2016-09-07 22:09:13 |
+----+--------+---------------------+
4 rows in set (0.00 sec)

root@localhost [GR_TEST]> start transaction;update T01 set MEMO = 'MISC01' where ID = 4;
Query OK, 0 rows affected (0.00 sec)

Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
|  3 | misc01 | 2016-09-07 22:09:10 |
|  4 | MISC01 | 2016-09-07 22:09:13 |
+----+--------+---------------------+
4 rows in set (0.00 sec)

root@localhost [GR_TEST]> select * from T01;
ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction
root@localhost [GR_TEST]> commit;
Query OK, 0 rows affected (0.00 sec)

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
|  3 | misc01 | 2016-09-07 22:09:10 |
|  4 | MISC02 | 2016-09-07 22:09:13 |
+----+--------+---------------------+
4 rows in set (0.00 sec)

root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
|  3 | misc01 | 2016-09-07 22:09:10 |
|  4 | MISC02 | 2016-09-07 22:09:13 |
+----+--------+---------------------+
4 rows in set (0.00 sec)

root@localhost [GR_TEST]> start transaction;update T01 set MEMO = 'MISC01' where ID = 4;
Query OK, 0 rows affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

root@localhost [GR_TEST]> commit;
ERROR 1180 (HY000): Got error 149 during COMMIT
root@localhost [GR_TEST]> select * from T01;
+----+--------+---------------------+
| ID | MEMO   | created_time        |
+----+--------+---------------------+
|  1 | misc01 | 2016-09-07 22:05:15 |
|  2 | misc02 | 2016-09-07 22:05:47 |
|  3 | misc01 | 2016-09-07 22:09:10 |
|  4 | misc02 | 2016-09-07 22:09:13 |
+----+--------+---------------------+
4 rows in set (0.00 sec)

root@localhost [GR_TEST]>