Whats new                        in MySQL 5.5 and 5.6                                 replication                         ...
AGENDA                        •   5.5                            •   semi-synchronous replication                        •...
DA     AG        EN              semi-synch replicationTuesday, April 17, 12                            3
semi-synchronous                                  replication                        • Available in 5.5 and higher        ...
client                                                           master   transaction                                     ...
client                                     transaction                                                           master   ...
semi-synchronous                              replication in practice                        • installation:              ...
semi-synch replication install  # in the master  plugin-load=rpl_semi_sync_master=semisync_master.so  rpl_semi_sync_master...
semi-synch replication check  # in the master  show variables like rpl_semi%;  +------------------------------------+-----...
semi-synch replication check  show status like "rpl_semi_%tx";  +-----------------------------+-------+  | variable_name  ...
semi-synch replication test  master> create table t1 ( i int);  Query OK, 0 rows affected (0.01 sec)  master> show status ...
disabling semi-synch  # for each slave  set global rpl_semi_sync_slave_enabled=0;  stop slave io_thread;  start slave io_t...
disabled semi-synch replication test  master> insert into t1 values (1);  Query OK, 1 row affected (10.00 sec)  master> sh...
disabled semi-synch replication test  master> insert into t1 values (2);  Query OK, 1 row affected (0.01 sec)  master> sho...
re-enabling semi-synch  # in one slave  set global rpl_semi_sync_slave_enabled=1;  stop slave io_thread;  start slave io_t...
reenabled semi-synch replication test  master> insert into t1 values (3);  Query OK, 1 row affected (0.01 sec)  master> sh...
DA     AG        EN              delayed replicationTuesday, April 17, 12                         17
delayed replication in practice  STOP SLAVE;  change master to master_delay=60;  START SLAVE;  SHOW SLAVE STATUSG  (...)  ...
delayed replication in practice  master >                 use test;  master >                 create table t2 (i int);  SH...
delayed replication in practice  # after 1 minute  SHOW SLAVE STATUSG  (...)                                     SQL_Delay...
DA     AG        EN              Server UUIDTuesday, April 17, 12                 21
testing some replication     make_replication_sandbox mysql-5.6.5-m8-     osx10.7-.tar.gz     ....     ....     replicatio...
testing some replication     ~/sandboxes/rsandbox_mysql-5_6_5/s1     show slave statusG     ******** 1. row **************...
testing some replication     ~/sandboxes/rsandbox_mysql-5_6_5/s1     show slave statusG     ....     Master_Server_Id: 1  ...
DA     AG        EN              crash safe slaveTuesday, April 17, 12                      25
uncovering replication                              features     show variables like %info%;     +------------------------...
uncovering replication                              features     STOP SLAVE;     set global master_info_repository=table; ...
fixing replication tables     use mysql;     slave1 [localhost] {msandbox} (mysql) > alter table     slave_master_info engi...
Look at the new features     show slave statusG     ....     ....     Master_UUID: be3c022a-726f-11e1-a26a-     a64f991393...
Look at the new features     select * from mysql.slave_master_infoG     *************************** 1. row ******         ...
Look at the new features     select * from mysql.slave_relay_log_infoG     *************************** 1. row ************...
Look at the new features     select * from mysql.slave_worker_infoG     ************** 3. row *********************       ...
DA     AG        EN              multi-threaded slaveTuesday, April 17, 12                          33
facts about multiple threaded slave                a.k.a. parallel replication                        • Requires MySQL 5.6...
enabling multi-threaded slave     set global slave_parallel_workers=10;     show variables like %worker%;     +-----------...
DA     AG        EN              global transaction identifierTuesday, April 17, 12                                  36
global transaction identifier    • Requires MySQL 5.6 in both master and slave    • requires all servers in the cluster to ...
global transaction identifier issues          • Cant work with:           • non-transactional updates.           • temporar...
enabling global transaction identifiers     # change my.cnf in ALL nodes     # (master and slaves)     [mysqld]     log-bin...
testing global transaction identifiers     create table t1 (i int not null primary key);     show binlog eventsG     ******...
testing global transaction identifiers     SHOW SLAVE STATUSG     (...)           Retrieved_Gtid_Set: 44556A96-8417-11E1-95...
DEMOTuesday, April 17, 12          42
ADVERTISING   ©Continuent 2012          43Tuesday, April 17, 12                 43
WE ARE HIRING!    • Cluster implementation engineer    • QA engineer    • Documentation writer      http://www.continuent....
Upcoming SlideShare
Loading in …5
×

Mysql 5.5 and 5.6 replication

6,737 views

Published on

What's new in MySQL 5.5

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,737
On SlideShare
0
From Embeds
0
Number of Embeds
295
Actions
Shares
0
Downloads
102
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Mysql 5.5 and 5.6 replication

  1. 1. Whats new in MySQL 5.5 and 5.6 replication Giuseppe Maxia Continuent, Inc ©Continuent 2012.Tuesday, April 17, 12 1
  2. 2. AGENDA • 5.5 • semi-synchronous replication • 5.6 • delayed replication • server UUID • crash-safe slave • multi-thread slave • Global transaction identi!ers ©Continuent 2012 2Tuesday, April 17, 12 2
  3. 3. DA AG EN semi-synch replicationTuesday, April 17, 12 3
  4. 4. semi-synchronous replication • Available in 5.5 and higher • Makes sure that at least one slave has copied the data. • Increases reliabilityTuesday, April 17, 12 4
  5. 5. client master transaction 1 with regular commit replication execute 2 slave returns 4 to client binary log 3 5 replication 5Tuesday, April 17, 12 5
  6. 6. client transaction master 1 with semi- commit synchronous replication execute 2 slave 7 returns to client binary log 3 sends 4 transaction relay log 5 to slave gets 6 acknowledgement 6Tuesday, April 17, 12 6
  7. 7. semi-synchronous replication in practice • installation: • it’s a plugin. • Actually, two pluginsTuesday, April 17, 12 7
  8. 8. semi-synch replication install # in the master plugin-load=rpl_semi_sync_master=semisync_master.so rpl_semi_sync_master_enabled=1 # in each slave plugin-load=rpl_semi_sync_slave=semisync_slave.so rpl_semi_sync_slave_enabled=1 # restar all serversTuesday, April 17, 12 8
  9. 9. semi-synch replication check # in the master show variables like rpl_semi%; +------------------------------------+-------+ | Variable_name | Value | +------------------------------------+-------+ | rpl_semi_sync_master_enabled | ON | | rpl_semi_sync_master_timeout | 10000 | | rpl_semi_sync_master_trace_level | 32 | | rpl_semi_sync_master_wait_no_slave | ON | +------------------------------------+-------+Tuesday, April 17, 12 9
  10. 10. semi-synch replication check show status like "rpl_semi_%tx"; +-----------------------------+-------+ | variable_name | value | +-----------------------------+-------+ | RPL_SEMI_SYNC_MASTER_NO_TX | 0 | | RPL_SEMI_SYNC_MASTER_YES_TX | 0 | +-----------------------------+-------+Tuesday, April 17, 12 10
  11. 11. semi-synch replication test master> create table t1 ( i int); Query OK, 0 rows affected (0.01 sec) master> show status like "rpl_semi_%tx"; +-----------------------------+-------+ | Variable_name | Value | +-----------------------------+-------+ | Rpl_semi_sync_master_no_tx | 0 | | Rpl_semi_sync_master_yes_tx | 1 | +-----------------------------+-------+Tuesday, April 17, 12 11
  12. 12. disabling semi-synch # for each slave set global rpl_semi_sync_slave_enabled=0; stop slave io_thread; start slave io_thread;Tuesday, April 17, 12 12
  13. 13. disabled semi-synch replication test master> insert into t1 values (1); Query OK, 1 row affected (10.00 sec) master> show status like "rpl_semi_%tx"; +-----------------------------+-------+ | Variable_name | Value | +-----------------------------+-------+ | Rpl_semi_sync_master_no_tx | 1 | | Rpl_semi_sync_master_yes_tx | 1 | +-----------------------------+-------+ 2 rows in set (0.00 sec)Tuesday, April 17, 12 13
  14. 14. disabled semi-synch replication test master> insert into t1 values (2); Query OK, 1 row affected (0.01 sec) master> show status like "rpl_semi_%tx"; +-----------------------------+-------+ | Variable_name | Value | +-----------------------------+-------+ | Rpl_semi_sync_master_no_tx | 2 | | Rpl_semi_sync_master_yes_tx | 1 | +-----------------------------+-------+ 2 rows in set (0.00 sec)Tuesday, April 17, 12 14
  15. 15. re-enabling semi-synch # in one slave set global rpl_semi_sync_slave_enabled=1; stop slave io_thread; start slave io_thread;Tuesday, April 17, 12 15
  16. 16. reenabled semi-synch replication test master> insert into t1 values (3); Query OK, 1 row affected (0.01 sec) master> show status like "rpl_semi_%tx"; +-----------------------------+-------+ | Variable_name | Value | +-----------------------------+-------+ | Rpl_semi_sync_master_no_tx | 2 | | Rpl_semi_sync_master_yes_tx | 2 | +-----------------------------+-------+ 2 rows in set (0.00 sec)Tuesday, April 17, 12 16
  17. 17. DA AG EN delayed replicationTuesday, April 17, 12 17
  18. 18. delayed replication in practice STOP SLAVE; change master to master_delay=60; START SLAVE; SHOW SLAVE STATUSG (...) SQL_Delay: 60 SQL_Remaining_Delay: NULLTuesday, April 17, 12 18
  19. 19. delayed replication in practice master > use test; master > create table t2 (i int); SHOW SLAVE STATUSG (...) SQL_Delay: 60 SQL_Remaining_Delay: 55 slave> SHOW TABLES FROM test; +----------------+ | Tables_in_test | +----------------+ | t1 | +----------------+Tuesday, April 17, 12 19
  20. 20. delayed replication in practice # after 1 minute SHOW SLAVE STATUSG (...) SQL_Delay: 60 SQL_Remaining_Delay: NULL slave> SHOW TABLES FROM test; +----------------+ | Tables_in_test | +----------------+ | t1 | | t2 | +----------------+Tuesday, April 17, 12 20
  21. 21. DA AG EN Server UUIDTuesday, April 17, 12 21
  22. 22. testing some replication make_replication_sandbox mysql-5.6.5-m8- osx10.7-.tar.gz .... .... replication directory installed in $HOME/sandboxes/rsandbox_mysql-5_6_5Tuesday, April 17, 12 22
  23. 23. testing some replication ~/sandboxes/rsandbox_mysql-5_6_5/s1 show slave statusG ******** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 127.0.0.1 Master_User: rsandbox Master_Port: 12630 Connect_Retry: 60 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 2524 Relay_Log_File: mysql_sandbox12631- relay-bin.000002 Relay_Log_Pos: 2677 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: YesTuesday, April 17, 12 23
  24. 24. testing some replication ~/sandboxes/rsandbox_mysql-5_6_5/s1 show slave statusG .... Master_Server_Id: 1 Master_UUID: be3c022a-726f-11e1-a26a-a64f991393aa Master_Info_File: /Users/gmax/sandboxes/ rsandbox_mysql-5_6_5/node1/data/master.info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update itTuesday, April 17, 12 24
  25. 25. DA AG EN crash safe slaveTuesday, April 17, 12 25
  26. 26. uncovering replication features show variables like %info%; +---------------------------+----------------+ | Variable_name | Value | +---------------------------+----------------+ | master_info_repository | FILE | | relay_log_info_file | relay-log.info | | relay_log_info_repository | FILE | | sync_master_info | 0 | | sync_relay_log_info | 0 | +---------------------------+----------------+ show variables like %worker%; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | slave_parallel_workers | 0 | +------------------------+-------+Tuesday, April 17, 12 26
  27. 27. uncovering replication features STOP SLAVE; set global master_info_repository=table; Query OK, 0 rows affected (0.00 sec) slave1 [localhost] {msandbox} ((none)) > set global relay_log_info_repository=table; Query OK, 0 rows affected (0.00 sec) slave1 [localhost] {msandbox} ((none)) > set global slave_parallel_workers=3; Query OK, 0 rows affected (0.00 sec)Tuesday, April 17, 12 27
  28. 28. fixing replication tables use mysql; slave1 [localhost] {msandbox} (mysql) > alter table slave_master_info engine=innodb; Query OK, 1 row affected (0.01 sec) Records: 1 Duplicates: 0 Warnings: 0 slave1 [localhost] {msandbox} (mysql) > alter table slave_relay_log_info engine=innodb; Query OK, 1 row affected (0.01 sec) Records: 1 Duplicates: 0 Warnings: 0 slave1 [localhost] {msandbox} (mysql) > alter table slave_worker_info engine=innodb; Query OK, 0 rows affected (0.01 sec) Records: 0 Duplicates: 0 Warnings: 0Tuesday, April 17, 12 28
  29. 29. Look at the new features show slave statusG .... .... Master_UUID: be3c022a-726f-11e1-a26a- a64f991393aa Master_Info_File: mysql.slave_master_infoTuesday, April 17, 12 29
  30. 30. Look at the new features select * from mysql.slave_master_infoG *************************** 1. row ****** Master_id: 101 Number_of_lines: 22 Master_log_name: mysql-bin.000001 Master_log_pos: 2524 Host: 127.0.0.1 User_name: rsandbox User_password: rsandbox Port: 12630 .... Heartbeat: 1800 Bind: Ignored_server_ids: 0 Uuid: be3c022a-726f-11e1-a26a-a64f991393aa Retry_count: 86400Tuesday, April 17, 12 30
  31. 31. Look at the new features select * from mysql.slave_relay_log_infoG *************************** 1. row *************** Master_id: 101 Number_of_lines: 6 Relay_log_name: ./mysql_sandbox12631-relay-bin. 000002 Relay_log_pos: 2677 Master_log_name: mysql-bin.000001 Master_log_pos: 2524 Sql_delay: 0 Number_of_workers: 3Tuesday, April 17, 12 31
  32. 32. Look at the new features select * from mysql.slave_worker_infoG ************** 3. row ********************* Master_id: 101 Worker_id: 2 Relay_log_name: ./mysql_sandbox12631-relay- bin.000003 Relay_log_pos: 1394 Master_log_name: mysql-bin.000001 Master_log_pos: 3651 Checkpoint_relay_log_name: ./mysql_sandbox12631-relay- bin.000003 Checkpoint_relay_log_pos: 1199 Checkpoint_master_log_name: mysql-bin.000001 Checkpoint_master_log_pos: 3456 Checkpoint_seqno: 0 Checkpoint_group_size: 64 Checkpoint_group_bitmap:Tuesday, April 17, 12 32
  33. 33. DA AG EN multi-threaded slaveTuesday, April 17, 12 33
  34. 34. facts about multiple threaded slave a.k.a. parallel replication • Requires MySQL 5.6 in both master and slave • Parallel replication with a 5.5 master will slow down replication • Data gets parallelized by schemaTuesday, April 17, 12 34
  35. 35. enabling multi-threaded slave set global slave_parallel_workers=10; show variables like %worker%; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | slave_parallel_workers | 10 | +------------------------+-------+ stop slave; start slave;Tuesday, April 17, 12 35
  36. 36. DA AG EN global transaction identifierTuesday, April 17, 12 36
  37. 37. global transaction identifier • Requires MySQL 5.6 in both master and slave • requires all servers in the cluster to run these options: • log-bin • log-slave-updates • gtid-mode=ON • disable-gtid-unsafe-statementsTuesday, April 17, 12 37
  38. 38. global transaction identifier issues • Cant work with: • non-transactional updates. • temporary tables within transactions • CREATE TABLE ... SELECT • disable-gtid-unsafe-statements will make the server fail on any of the above cases.Tuesday, April 17, 12 38
  39. 39. enabling global transaction identifiers # change my.cnf in ALL nodes # (master and slaves) [mysqld] log-bin log-slave-updates gtid-mode=ON disable-gtid-unsafe-statements # restart the serversTuesday, April 17, 12 39
  40. 40. testing global transaction identifiers create table t1 (i int not null primary key); show binlog eventsG ********* 3. row *************************** Log_name: mysql-bin.000002 Pos: 147 Event_type: Gtid Server_id: 1 End_log_pos: 191 Info: SET @@SESSION.GTID_NEXT=44556A96-8417-11E1-9589-2BD5ACDD51FD:1 ********* 4. row *************************** Log_name: mysql-bin.000002 Pos: 191 Event_type: Query Server_id: 1 End_log_pos: 305 Info: use `test`; create table t1 (i int not null primary key)Tuesday, April 17, 12 40
  41. 41. testing global transaction identifiers SHOW SLAVE STATUSG (...) Retrieved_Gtid_Set: 44556A96-8417-11E1-9589-2BD5ACDD51FD:1-2 Executed_Gtid_Set: 44556A96-8417-11E1-9589-2BD5ACDD51FD:1-2Tuesday, April 17, 12 41
  42. 42. DEMOTuesday, April 17, 12 42
  43. 43. ADVERTISING ©Continuent 2012 43Tuesday, April 17, 12 43
  44. 44. WE ARE HIRING! • Cluster implementation engineer • QA engineer • Documentation writer http://www.continuent.com/about/careers ©Continuent 2012 44Tuesday, April 17, 12 44

×