mysqlfabric group add実行時の新規追加サーバーのデータ同期について。

1)マスターDBに必要なバイナリーログがある場合は、新規Slaveがログを読み込んでデータ同期。
2) マスターDBに必要なバイナリーログが無い場合は、新規Slaveにデータをリストアしてからmysqlfabric group addコマンドを実行。

■ mysqlfabric group addコマンドについての前回のブログ
mysqlfabricにてSlaveを追加

【通常時Fabric管理ノードが受け取っている処理】

+---------------------+----------------------------------------+-----------+-----------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 2015-02-26 10:35:43 | fabric[fabric] @ localhost [127.0.0.1] |        16 |         1 | Query        | SELECT group_id, description, master_uuid, master_defined, status FROM groups WHERE group_id = 'global'                                                                                                                                                                                                                                                                                   |
| 2015-02-26 10:35:43 | fabric[fabric] @ localhost [127.0.0.1] |        16 |         1 | Query        | SELECT server_uuid, server_address, mode, status, weight, group_id FROM servers WHERE group_id = 'global'                                                                                                                                                                                                                                                                                 |
| 2015-02-26 10:35:45 | fabric[fabric] @ localhost [127.0.0.1] |        16 |         1 | Query        | SELECT group_id, description, master_uuid, master_defined, status FROM groups WHERE group_id = 'global'                                                                                                                                                                                                                                                                                   |
| 2015-02-26 10:35:45 | fabric[fabric] @ localhost [127.0.0.1] |        16 |         1 | Query        | SELECT server_uuid, server_address, mode, status, weight, group_id FROM servers WHERE group_id = 'global'                                                                                                                                                                                                                                                                                 |
| 2015-02-26 10:35:47 | fabric[fabric] @ localhost [127.0.0.1] |        16 |         1 | Query        | SELECT group_id, description, master_uuid, master_defined, status FROM groups WHERE group_id = 'global'                                                                                                                                                                                                                                                                                   |
| 2015-02-26 10:35:47 | fabric[fabric] @ localhost [127.0.0.1] |        16 |         1 | Query        | SELECT server_uuid, server_address, mode, status, weight, group_id FROM servers WHERE group_id = 'global'                                                                                                                                                                                                                                                                                 |
| 2015-02-26 10:35:49 | fabric[fabric] @ localhost [127.0.0.1] |        16 |         1 | Query        | SELECT group_id, description, master_uuid, master_defined, status FROM groups WHERE group_id = 'global'                                                                                                                                                                                                                                                                                   |
| 2015-02-26 10:35:49 | fabric[fabric] @ localhost [127.0.0.1] |        16 |         1 | Query        | SELECT server_uuid, server_address, mode, status, weight, group_id FROM servers WHERE group_id = 'global'                                                                                                                                                                                                                                                                                 |
+---------------------+----------------------------------------+-----------+-----------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

グループにサーバーを追加した時のバックグラウンド処理の確認。

-bash-4.2$ mysqlfabric group add global 127.0.0.1:63307
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                                uuid finished success result
------------------------------------ -------- ------- ------
b63f21d7-4b17-4602-a110-a6ad394c6438        1       1      1

state success          when                                                   description
----- ------- ------------- -------------------------------------------------------------
    3       2 1424914567.27 Triggered by <mysql.fabric.events.Event object at 0x27465d0>.
    4       2 1424914567.33                               Executing action (_add_server).
    5       2 1424914567.46                                Executed action (_add_server).


-bash-4.2$

-bash-4.2$ mysqlfabric group lookup_servers global
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                         server_uuid         address    status       mode weight
------------------------------------ --------------- --------- ---------- ------
4790c170-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63301   PRIMARY READ_WRITE    1.0
483d8d5a-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63302 SECONDARY  READ_ONLY    1.0
48d8c44f-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63303 SECONDARY  READ_ONLY    1.0
4958fc6d-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63304 SECONDARY  READ_ONLY    1.0
49f47cf1-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63305 SECONDARY  READ_ONLY    1.0
4a900296-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63306 SECONDARY  READ_ONLY    1.0
4b2ed657-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63307 SECONDARY  READ_ONLY    1.0


-bash-4.2$ 

【Slaveを追加した時に流れるQuery】 Fabric管理ノード(データストアDB)

+---------------------+----------------------------------------+-----------+-----------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        15 |         1 | Query        | SELECT username, protocol, password FROM users WHERE username = 'admin' AND protocol = 'xmlrpc'                                                                                                                                                                                                                                                                                           |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        15 |         1 | Query        | SELECT p.subsystem, p.component, p.function FROM users AS u LEFT JOIN user_roles AS ur USING (user_id) LEFT JOIN role_permissions AS rp USING (role_id) LEFT JOIN permissions AS p USING (permission_id) WHERE u.username = 'admin' AND protocol = 'xmlrpc'                                                                                                                               |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        15 |         1 | Query        | INSERT INTO log (subject, reported, reporter, message, category, type) VALUES('group.add', '2015-02-26 01:36:07', 'mysql.fabric.command', 'Started command (group, add).', 1, 0)                                                                                                                                                                                                          |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        15 |         1 | Query        | BEGIN                                                                                                                                                                                                                                                                                                                                                                                     |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        15 |         1 | Query        | INSERT INTO checkpoints(proc_uuid, lockable_objects, job_uuid, sequence, action_fqn, param_args, param_kwargs) VALUES ('b63f21d7-4b17-4602-a110-a6ad394c6438', 'c__builtin__\nset\np0\n((lp1\nS\'lock\'\np2\natp3\nRp4\n.', '12fe6274-f21b-4706-83c6-9ad2c763cbb9', 0, 'mysql.fabric.services.server._add_server', '(S\'global\'\np0\nS\'127.0.0.1:63307\'\np1\nNI00\ntp2\n.', '(dp0\n.') |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        15 |         1 | Query        | COMMIT                                                                                                                                                                                                                                                                                                                                                                                    |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        10 |         1 | Query        | UPDATE checkpoints set started = 1424914567.333504 WHERE proc_uuid = 'b63f21d7-4b17-4602-a110-a6ad394c6438' and job_uuid = '12fe6274-f21b-4706-83c6-9ad2c763cbb9'                                                                                                                                                                                                                         |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        10 |         1 | Query        | BEGIN                                                                                                                                                                                                                                                                                                                                                                                     |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        10 |         1 | Query        | SELECT group_id, description, master_uuid, master_defined, status FROM groups WHERE group_id = 'global'                                                                                                                                                                                                                                                                                   |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        10 |         1 | Query        | SELECT server_uuid, server_address, mode, status, weight, group_id FROM servers WHERE server_uuid = '4b2ed657-bd51-11e4-9ab3-08002766cefe'                                                                                                                                                                                                                                                |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        10 |         1 | Query        | SELECT @@GLOBAL.SERVER_UUID                                                                                                                                                                                                                                                                                                                                                               |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        10 |         1 | Query        | INSERT INTO servers(server_uuid, server_address, mode, status, weight, group_id) values('4b2ed657-bd51-11e4-9ab3-08002766cefe', '127.0.0.1:63307', 1, 2, 1.0, NULL)                                                                                                                                                                                                                       |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        10 |         1 | Query        | UPDATE servers SET group_id = 'global' WHERE server_uuid = '4b2ed657-bd51-11e4-9ab3-08002766cefe'                                                                                                                                                                                                                                                                                         |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        10 |         1 | Query        | SELECT server_uuid, server_address, mode, status, weight, group_id FROM servers WHERE server_uuid = '4790c170-bd51-11e4-9ab3-08002766cefe'                                                                                                                                                                                                                                                |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        10 |         1 | Query        | UPDATE checkpoints set finished = 1424914567.455931 WHERE proc_uuid = 'b63f21d7-4b17-4602-a110-a6ad394c6438' and job_uuid = '12fe6274-f21b-4706-83c6-9ad2c763cbb9'                                                                                                                                                                                                                        |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        10 |         1 | Query        | COMMIT                                                                                                                                                                                                                                                                                                                                                                                    |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        10 |         1 | Query        | DELETE FROM checkpoints WHERE proc_uuid = 'b63f21d7-4b17-4602-a110-a6ad394c6438'                                                                                                                                                                                                                                                                                                          |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        15 |         1 | Query        | INSERT INTO log (subject, reported, reporter, message, category, type) VALUES('group.add', '2015-02-26 01:36:07', 'mysql.fabric.command', 'Finished command (group, add).', 1, 1)                                                                                                                                                                                                         |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        16 |         1 | Query        | SELECT group_id, description, master_uuid, master_defined, status FROM groups WHERE group_id = 'global'                                                                                                                                                                                                                                                                                   |
| 2015-02-26 10:36:07 | fabric[fabric] @ localhost [127.0.0.1] |        16 |         1 | Query        | SELECT server_uuid, server_address, mode, status, weight, group_id FROM servers WHERE group_id = 'global'                                                                                                                                                                                                                                                                                 |
| 2015-02-26 10:36:08 | root[root] @ localhost [127.0.0.1]     |        17 |         1 | Query        | select * from general_log                                                                                                                                                                                                                                                                                                                                                                 |
+---------------------+----------------------------------------+-----------+-----------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

【追加したSlave側のログ】

 
-----------------------------------------------------------------------------------------------------------------
-bash-4.2$ cat fabric_add_slave.sql | more
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Query   SELECT DATABASE()
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Init DB mysql
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Query   show databases
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Query   show tables
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      columns_priv 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      db 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      event 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      func 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      general_log 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      help_category 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      help_keyword 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      help_relation 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      help_topic 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      innodb_index_stats 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      innodb_table_stats 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      ndb_binlog_index 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      plugin 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      proc 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      procs_priv 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      proxies_priv 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      servers 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      slave_master_info 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      slave_relay_log_info 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      slave_worker_info 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      slow_log 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      tables_priv 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      time_zone 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      time_zone_leap_second 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      time_zone_name 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      time_zone_transition 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      time_zone_transition_type 
2015-02-26 10:48:54     root[root] @ localhost [127.0.0.1]      3       8       Field List      user 
2015-02-26 10:48:58     root[root] @ localhost [127.0.0.1]      3       8       Query   show databases
2015-02-26 10:49:21     root[root] @ localhost [127.0.0.1]      3       8       Query   select @@hostname,@@port
2015-02-26 10:49:24     [root] @ localhost [127.0.0.1]  4       8       Connect root@localhost on 
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      4       8       Query   SET NAMES 'utf8' COLLATE 'utf8_general_ci'
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      4       8       Query   SET @@session.autocommit = ON
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      4       8       Query   SELECT @@GLOBAL.SERVER_UUID
2015-02-26 10:49:24     [root] @ localhost [127.0.0.1]  5       8       Connect root@localhost on 
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SET NAMES 'utf8' COLLATE 'utf8_general_ci'
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SET @@session.autocommit = ON
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SELECT @@GLOBAL.SERVER_UUID as SERVER_UUID
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SELECT @@GLOBAL.SERVER_ID as SERVER_ID
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SELECT @@GLOBAL.VERSION as VERSION
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SELECT @@GLOBAL.GTID_MODE as GTID_MODE
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SELECT @@GLOBAL.LOG_BIN as LOG_BIN
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      4       8       Quit
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SELECT @@GLOBAL.READ_ONLY as READ_ONLY
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SHOW GRANTS
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   STOP SLAVE
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SHOW SLAVE STATUS
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SHOW SLAVE STATUS
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   CHANGE MASTER TO MASTER_HOST = '127.0.0.1' MASTER_USER = 'root' MASTER_PASSWORD = <secret> MASTER_PORT = 63301
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SET @@GLOBAL.READ_ONLY = ON
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SELECT @@GLOBAL.READ_ONLY as READ_ONLY
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   START SLAVE
2015-02-26 10:49:24     [] @  []        6       8       Connect Out     root@127.0.0.1:63301
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SHOW SLAVE STATUS
2015-02-26 10:49:24     root[root] @ localhost [127.0.0.1]      5       8       Query   SHOW SLAVE STATUS
2015-02-26 10:49:24     [] @  []        7       8       Query   SET PASSWORD FOR 'root'@'localhost'='*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B'
2015-02-26 10:49:24     [] @  []        7       8       Query   GRANT SELECT, INSERT, DELETE, CREATE, DROP ON `test`.* TO 'app'@'localhost' IDENTIFIED BY PASSWORD '*5BCB3E6AC345B435C7C2E6B7949A04CE6F6563D3'
2015-02-26 10:49:24     [] @  []        7       8       Query   DROP TABLE IF EXISTS `employees` /* generated by server */
2015-02-26 10:49:24     [] @  []        7       8       Query   CREATE TABLE employees (   emp_no INT,    first_name CHAR(40),    last_name CHAR(40))
2015-02-26 10:49:24     [] @  []        7       8       Query   BEGIN
2015-02-26 10:49:24     [] @  []        7       8       Query   INSERT INTO employees VALUES (0, 'MySQL Fabric:0', 'Scale Out and HA Demo')
2015-02-26 10:49:24     [] @  []        7       8       Query   COMMIT /* implicit, from Xid_log_event */
2015-02-26 10:49:24     [] @  []        7       8       Query   BEGIN
2015-02-26 10:49:24     [] @  []        7       8       Query   INSERT INTO employees VALUES (1, 'MySQL Fabric:1', 'Scale Out and HA Demo')
2015-02-26 10:49:24     [] @  []        7       8       Query   COMMIT /* implicit, from Xid_log_event */
2015-02-26 10:49:24     [] @  []        7       8       Query   BEGIN
2015-02-26 10:49:24     [] @  []        7       8       Query   INSERT INTO employees VALUES (2, 'MySQL Fabric:2', 'Scale Out and HA Demo')
2015-02-26 10:49:24     [] @  []        7       8       Query   COMMIT /* implicit, from Xid_log_event */

省略.....

2015-02-26 10:49:24     [] @  []        7       8       Query   INSERT INTO employees VALUES (298, 'MySQL Fabric:298', 'Scale Out and HA Demo')
2015-02-26 10:49:24     [] @  []        7       8       Query   COMMIT /* implicit, from Xid_log_event */
2015-02-26 10:49:24     [] @  []        7       8       Query   BEGIN
2015-02-26 10:49:24     [] @  []        7       8       Query   INSERT INTO employees VALUES (299, 'MySQL Fabric:299', 'Scale Out and HA Demo')
2015-02-26 10:49:24     [] @  []        7       8       Query   COMMIT /* implicit, from Xid_log_event */
2015-02-26 10:49:26     [root] @ localhost [127.0.0.1]  8       8       Connect root@localhost on 
2015-02-26 10:49:26     root[root] @ localhost [127.0.0.1]      8       8       Query   SET NAMES 'utf8' COLLATE 'utf8_general_ci'
2015-02-26 10:49:26     root[root] @ localhost [127.0.0.1]      8       8       Query   SET @@session.autocommit = ON
2015-02-26 10:49:26     root[root] @ localhost [127.0.0.1]      8       8       Quit
2015-02-26 10:49:28     [root] @ localhost [127.0.0.1]  9       8       Connect root@localhost on 
2015-02-26 10:49:28     root[root] @ localhost [127.0.0.1]      9       8       Query   SET NAMES 'utf8' COLLATE 'utf8_general_ci'
2015-02-26 10:49:28     root[root] @ localhost [127.0.0.1]      9       8       Query   SET @@session.autocommit = ON
2015-02-26 10:49:28     root[root] @ localhost [127.0.0.1]      9       8       Quit
2015-02-26 10:49:30     [root] @ localhost [127.0.0.1]  10      8       Connect root@localhost on 
2015-02-26 10:49:30     root[root] @ localhost [127.0.0.1]      10      8       Query   SET NAMES 'utf8' COLLATE 'utf8_general_ci'
2015-02-26 10:49:30     root[root] @ localhost [127.0.0.1]      10      8       Query   SET @@session.autocommit = ON
2015-02-26 10:49:30     root[root] @ localhost [127.0.0.1]      10      8       Quit
2015-02-26 10:49:32     [root] @ localhost [127.0.0.1]  11      8       Connect root@localhost on 
2015-02-26 10:49:32     root[root] @ localhost [127.0.0.1]      11      8       Query   SET NAMES 'utf8' COLLATE 'utf8_general_ci'
2015-02-26 10:49:32     root[root] @ localhost [127.0.0.1]      11      8       Query   SET @@session.autocommit = ON
2015-02-26 10:49:32     root[root] @ localhost [127.0.0.1]      11      8       Quit
2015-02-262015-02-26 10:54:48     root[root] @ localhost [127.0.0.1]      121     8       Query   select * into outfile 'fabric_add_slave.sql' from mysql.general_log
-bash-4.2$ 
-----------------------------------------------------------------------------------------------------------------

【マスターでバイバリーログを削除した場合に、サーバーを追加した場合の動作確認】

バイナリーログのPURGE


mysql> flush logs;
Query OK, 0 rows affected (0.03 sec)

mysql> SHOW MASTER LOGS;
+---------------------+-----------+
| Log_name            | File_size |
+---------------------+-----------+
| Fabric01-bin.000001 |     93831 |
| Fabric01-bin.000002 |       241 |
| Fabric01-bin.000003 |       191 |
+---------------------+-----------+
3 rows in set (0.00 sec)

mysql> PURGE MASTER LOGS TO 'Fabric01-bin.000002';
Query OK, 0 rows affected (0.05 sec)

mysql> SHOW MASTER LOGS;
+---------------------+-----------+
| Log_name            | File_size |
+---------------------+-----------+
| Fabric01-bin.000002 |       241 |
| Fabric01-bin.000003 |       191 |
+---------------------+-----------+
2 rows in set (0.01 sec)

mysql> 

【マスターでバイバリーログを削除した場合はログが読み取れずスレーブ作成が失敗する】

-bash-4.2$ mysqlfabric group add global 127.0.0.1:63309
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

ServerError: Error trying to configure server (4c6e5d9d-bd51-11e4-9ab3-08002766cefe) as slave: Got fatal error 1236 from master when reading data from binary log: 'The slave is connecting using CHANGE MASTER TO MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.'.

-bash-4.2$ mysqlfabric group lookup_servers global
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                         server_uuid         address    status       mode weight
------------------------------------ --------------- --------- ---------- ------
4790c170-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63301   PRIMARY READ_WRITE    1.0
483d8d5a-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63302 SECONDARY  READ_ONLY    1.0
48d8c44f-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63303 SECONDARY  READ_ONLY    1.0
4958fc6d-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63304 SECONDARY  READ_ONLY    1.0
49f47cf1-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63305 SECONDARY  READ_ONLY    1.0
4a900296-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63306 SECONDARY  READ_ONLY    1.0
4b2ed657-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63307 SECONDARY  READ_ONLY    1.0
4c2e3c4e-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63308 SECONDARY  READ_ONLY    1.0


-bash-4.2$ 

【マスターからダンプして,新規Slaveにリストア後にGROUPにADD】
既に、上記でGROUP ADDが失敗していたので、@@GLOBAL.GTID_EXECUTEDが存在していたので情報をリセットしてからリストア。

-bash-4.2$ /usr/local/mysql/bin/mysqldump -uroot -proot -h127.0.0.1 -P63301 --all-databases --single-transaction --triggers --routines --events > GTID_63301.sql
Warning: Using a password on the command line interface can be insecure.
-bash-4.2$ ls
Fabric01-bin.000002  Fabric01-relay-bin.000001  Fabric01.pid    ib_logfile0  my.sock    mysql.out
Fabric01-bin.000003  Fabric01-relay-bin.index   GTID_63301.sql  ib_logfile1  mysql      performance_schema
Fabric01-bin.index   Fabric01.log               auto.cnf        ibdata1      mysql.err  test
-bash-4.2$ 


-bash-4.2$ /usr/local/mysql/bin/mysql -h127.0.0.1 -P63309 -u root -p < /home/mysql/fabric/mysql1/GTID_63301.sql
Enter password: 
ERROR 1840 (HY000) at line 24: @@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty.
-bash-4.2$ /usr/local/mysql/bin/mysql -h127.0.0.1 -P63309 -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 5.6.22-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2014, 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 GLOBAL VARIABLES LIKE '%GTID%';
+---------------------------------+------------------------------------------+
| Variable_name                   | Value                                    |
+---------------------------------+------------------------------------------+
| enforce_gtid_consistency        | ON                                       |
| gtid_executed                   | 4c6e5d9d-bd51-11e4-9ab3-08002766cefe:1-2 |
| gtid_mode                       | ON                                       |
| gtid_owned                      |                                          |
| gtid_purged                     |                                          |
| simplified_binlog_gtid_recovery | OFF                                      |
+---------------------------------+------------------------------------------+
6 rows in set (0.00 sec)

mysql> RESET MASTER;
Query OK, 0 rows affected (0.03 sec)

mysql> exit
Bye
-bash-4.2$ /usr/local/mysql/bin/mysql -h127.0.0.1 -P63309 -u root -p < /home/mysql/fabric/mysql1/GTID_63301.sql
Enter password: 
-bash-4.2$ 

&#91;/SHELL&#93;
※一度,group addに失敗している為、一度RESET MASTERを実行しています。


<strong>【ダンプからリストア後にSlaveをグループに追加】</strong> 
[SHELL]
-bash-4.2$ mysqlfabric group lookup_servers global
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                         server_uuid         address    status       mode weight
------------------------------------ --------------- --------- ---------- ------
4790c170-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63301   PRIMARY READ_WRITE    1.0
483d8d5a-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63302 SECONDARY  READ_ONLY    1.0
48d8c44f-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63303 SECONDARY  READ_ONLY    1.0
4958fc6d-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63304 SECONDARY  READ_ONLY    1.0
49f47cf1-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63305 SECONDARY  READ_ONLY    1.0
4a900296-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63306 SECONDARY  READ_ONLY    1.0
4b2ed657-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63307 SECONDARY  READ_ONLY    1.0
4c2e3c4e-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63308 SECONDARY  READ_ONLY    1.0


-bash-4.2$ mysqlfabric group add global 127.0.0.1:63309
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                                uuid finished success result
------------------------------------ -------- ------- ------
7e90ab70-f52f-4e18-b7e6-2a009cddd828        1       1      1

state success          when                                                   description
----- ------- ------------- -------------------------------------------------------------
    3       2 1424917991.59 Triggered by <mysql.fabric.events.Event object at 0x27465d0>.
    4       2 1424917991.59                               Executing action (_add_server).
    5       2 1424917991.67                                Executed action (_add_server).


-bash-4.2$ mysqlfabric group lookup_servers global
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1

                         server_uuid         address    status       mode weight
------------------------------------ --------------- --------- ---------- ------
4790c170-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63301   PRIMARY READ_WRITE    1.0
483d8d5a-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63302 SECONDARY  READ_ONLY    1.0
48d8c44f-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63303 SECONDARY  READ_ONLY    1.0
4958fc6d-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63304 SECONDARY  READ_ONLY    1.0
49f47cf1-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63305 SECONDARY  READ_ONLY    1.0
4a900296-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63306 SECONDARY  READ_ONLY    1.0
4b2ed657-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63307 SECONDARY  READ_ONLY    1.0
4c2e3c4e-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63308 SECONDARY  READ_ONLY    1.0
4c6e5d9d-bd51-11e4-9ab3-08002766cefe 127.0.0.1:63309 SECONDARY  READ_ONLY    1.0


-bash-4.2$ 

-bash-4.2$ mysql -uroot -proot -h127.0.0.1 -P63307 -se"select @@port,count(*) from test.employees"
Warning: Using a password on the command line interface can be insecure.
@@port  count(*)
63307   299
-bash-4.2$ mysql -uroot -proot -h127.0.0.1 -P63309 -se"select @@port,count(*) from test.employees"
Warning: Using a password on the command line interface can be insecure.
@@port  count(*)
63309   299
-bash-4.2$ 

【新規、ダンプ&リストアして追加したスレーブのログを確認してみる。】

mysql> select * from mysql.general_log;
+---------------------+------------------------------------+-----------+-----------+--------------+----------------------------------------------------------------------------------------------------------------+
| event_time          | user_host                          | thread_id | server_id | command_type | argument                                                                                                       |
+---------------------+------------------------------------+-----------+-----------+--------------+----------------------------------------------------------------------------------------------------------------+
| 2015-02-26 11:33:11 | [root] @ localhost [127.0.0.1]     |        24 |         9 | Connect      | root@localhost on                                                                                              |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |        24 |         9 | Query        | SET NAMES 'utf8' COLLATE 'utf8_general_ci'                                                                     |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |        24 |         9 | Query        | SET @@session.autocommit = ON                                                                                  |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |        24 |         9 | Query        | SELECT @@GLOBAL.SERVER_UUID                                                                                    |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |        24 |         9 | Quit         |                                                                                                                |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | SELECT @@GLOBAL.SERVER_UUID as SERVER_UUID                                                                     |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | SELECT @@GLOBAL.SERVER_ID as SERVER_ID                                                                         |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | SELECT @@GLOBAL.VERSION as VERSION                                                                             |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | SELECT @@GLOBAL.GTID_MODE as GTID_MODE                                                                         |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | SELECT @@GLOBAL.LOG_BIN as LOG_BIN                                                                             |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | SELECT @@GLOBAL.READ_ONLY as READ_ONLY                                                                         |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | SHOW GRANTS                                                                                                    |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | STOP SLAVE                                                                                                     |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | SHOW SLAVE STATUS                                                                                              |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | SHOW SLAVE STATUS                                                                                              |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | CHANGE MASTER TO MASTER_HOST = '127.0.0.1' MASTER_USER = 'root' MASTER_PASSWORD = <secret> MASTER_PORT = 63301 |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | SET @@GLOBAL.READ_ONLY = ON                                                                                    |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | SELECT @@GLOBAL.READ_ONLY as READ_ONLY                                                                         |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | START SLAVE                                                                                                    |
| 2015-02-26 11:33:11 | [] @  []                           |        25 |         9 | Connect Out  | root@127.0.0.1:63301                                                                                           |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | SHOW SLAVE STATUS                                                                                              |
| 2015-02-26 11:33:11 | root[root] @ localhost [127.0.0.1] |         6 |         9 | Query        | SHOW SLAVE STATUS                                                                                              |
| 2015-02-26 11:33:13 | [root] @ localhost [127.0.0.1]     |        27 |         9 | Connect      | root@localhost on                                                                                              |
| 2015-02-26 11:33:13 | root[root] @ localhost [127.0.0.1] |        27 |         9 | Query        | SET NAMES 'utf8' COLLATE 'utf8_general_ci'                                                                     |
| 2015-02-26 11:33:13 | root[root] @ localhost [127.0.0.1] |        27 |         9 | Query        | SET @@session.autocommit = ON                                                                                  |
| 2015-02-26 11:33:13 | root[root] @ localhost [127.0.0.1] |        27 |         9 | Quit         |                                                                                                                |

省略....
                                                                 |
| 2015-02-26 11:35:22 | [root] @ localhost [127.0.0.1]     |        91 |         9 | Connect      | root@localhost on                                                                                              |
| 2015-02-26 11:35:22 | root[root] @ localhost [127.0.0.1] |        91 |         9 | Query        | SET NAMES 'utf8' COLLATE 'utf8_general_ci'                                                                     |
| 2015-02-26 11:35:22 | root[root] @ localhost [127.0.0.1] |        91 |         9 | Query        | SET @@session.autocommit = ON                                                                                  |
| 2015-02-26 11:35:22 | root[root] @ localhost [127.0.0.1] |        91 |         9 | Quit         |                                                                                                                |
| 2015-02-26 11:35:24 | [root] @ localhost [127.0.0.1]     |        92 |         9 | Connect      | root@localhost on                                                                                              |
| 2015-02-26 11:35:24 | root[root] @ localhost [127.0.0.1] |        92 |         9 | Query        | SET NAMES 'utf8' COLLATE 'utf8_general_ci'                                                                     |
| 2015-02-26 11:35:24 | root[root] @ localhost [127.0.0.1] |        92 |         9 | Query        | SET @@session.autocommit = ON                                                                                  |
| 2015-02-26 11:35:24 | root[root] @ localhost [127.0.0.1] |        92 |         9 | Quit         |                                                                                                                |
| 2015-02-26 11:35:26 | [root] @ localhost [127.0.0.1]     |        93 |         9 | Connect      | root@localhost on                                                                                              |
| 2015-02-26 11:35:26 | root[root] @ localhost [127.0.0.1] |        93 |         9 | Query        | SET NAMES 'utf8' COLLATE 'utf8_general_ci'                                                                     |
| 2015-02-26 11:35:26 | root[root] @ localhost [127.0.0.1] |        93 |         9 | Query        | SET @@session.autocommit = ON                                                                                  |
| 2015-02-26 11:35:26 | root[root] @ localhost [127.0.0.1] |        93 |         9 | Quit         |                                                                                                                |
| 2015-02-26 11:35:27 | root[root] @ localhost [127.0.0.1] |        23 |         9 | Query        | select * from mysql.general_log                                                                                |
+---------------------+------------------------------------+-----------+-----------+--------------+----------------------------------------------------------------------------------------------------------------+
291 rows in set (0.01 sec)

mysql> 

17.1.3.2 Setting Up Replication Using GTIDs
http://dev.mysql.com/doc/refman/5.6/en/replication-gtids-howto.html
MySQL Fabric – Part 1 – Installing
https://blog.marceloaltmann.com/mysql-fabric-installing-instalar/

Comments are closed.

Post Navigation