What's new
                        in MySQL 5.5 and 5.6
                                 replication
                                  Giuseppe Maxia
                                  Continuent, Inc


   ©Continuent 2012.


Tuesday, April 17, 12                               1
AGENDA

                        •   5.5
                            •   semi-synchronous replication

                        •   5.6
                            •   delayed replication

                            •   server UUID

                            •   crash-safe slave

                            •   multi-thread slave

                            •   Global transaction identi!ers



   ©Continuent 2012                                   2


Tuesday, April 17, 12                                           2
DA
     AG
        EN              semi-synch replication




Tuesday, April 17, 12                            3
semi-synchronous
                                  replication


                        • Available in 5.5 and higher
                        • Makes sure that at least one slave has
                          copied the data.
                        • Increases reliability


Tuesday, April 17, 12                                              4
client
                                                           master   transaction
                                               1                    with regular
                                    commit                           replication



                                               execute     2

                                                                      slave
                         returns
        4               to client
                                             binary log        3



                                      5      replication
                                                                               5
Tuesday, April 17, 12                                                              5
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
                                                                                      6
Tuesday, April 17, 12                                                                    6
semi-synchronous
                              replication in practice



                        • installation:
                          •   it’s a plugin.

                          •   Actually, two plugins




Tuesday, April 17, 12                                   7
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 servers




Tuesday, April 17, 12                                    8
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
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
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
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
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
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
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
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
DA
     AG
        EN              delayed replication




Tuesday, April 17, 12                         17
delayed replication in practice
  STOP SLAVE;
  change master to master_delay=60;
  START SLAVE;

  SHOW SLAVE STATUSG
  (...)
                                    SQL_Delay: 60
                           SQL_Remaining_Delay: NULL




Tuesday, April 17, 12                                     18
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
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
DA
     AG
        EN              Server UUID




Tuesday, April 17, 12                 21
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_5




Tuesday, April 17, 12                              22
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: Yes


Tuesday, April 17, 12                                        23
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 it




Tuesday, April 17, 12                                     24
DA
     AG
        EN              crash safe slave




Tuesday, April 17, 12                      25
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
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
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: 0


Tuesday, April 17, 12                                      28
Look at the new features
     show slave statusG
     ....
     ....
     Master_UUID: be3c022a-726f-11e1-a26a-
     a64f991393aa
     Master_Info_File:
     mysql.slave_master_info




Tuesday, April 17, 12                              29
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: 86400


Tuesday, April 17, 12                                  30
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: 3




Tuesday, April 17, 12                                     31
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
DA
     AG
        EN              multi-threaded slave




Tuesday, April 17, 12                          33
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 schema

Tuesday, April 17, 12                                                   34
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
DA
     AG
        EN              global transaction identifier




Tuesday, April 17, 12                                  36
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-statements

Tuesday, April 17, 12                                    37
global transaction identifier issues

          • Can't 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
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 servers




Tuesday, April 17, 12                              39
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
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-2




Tuesday, April 17, 12                                                     41
DEMO




Tuesday, April 17, 12          42
ADVERTISING


   ©Continuent 2012          43


Tuesday, April 17, 12                 43
WE ARE HIRING!
    • Cluster implementation engineer
    • QA engineer
    • Documentation writer


      http://www.continuent.com/about/careers

   ©Continuent 2012      44


Tuesday, April 17, 12                           44

More Related Content

PDF
Solving_the_C20K_problem_PHP_Performance_and_Scalability-phpquebec_2009
PPTX
Streaming Replication Made Easy in v9.3
PDF
Percona Live 2012PPT: introduction-to-mysql-replication
DOCX
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs
PPTX
006 performance tuningandclusteradmin
PPTX
ProxySQL para mysql
PDF
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PPTX
SecZone 2011: Scrubbing SAP clean with SOAP
Solving_the_C20K_problem_PHP_Performance_and_Scalability-phpquebec_2009
Streaming Replication Made Easy in v9.3
Percona Live 2012PPT: introduction-to-mysql-replication
12c: Testing audit features for Data Pump (Export & Import) and RMAN jobs
006 performance tuningandclusteradmin
ProxySQL para mysql
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
SecZone 2011: Scrubbing SAP clean with SOAP

What's hot (20)

PDF
PostgreSQL Performance Tuning
PDF
MySQL Multi-Source Replication for PL2016
PDF
Ns2leach
PDF
Athenticated smaba server config with open vpn
PDF
Learning MySQL 5.7
PDF
FOSDEM 2012: MySQL synchronous replication in practice with Galera
PDF
12c for Developers - Feb 2014
DOC
Arp Dan Ipconfig Syntax
PDF
PostgreSQL Portland Performance Practice Project - Database Test 2 Tuning
PPTX
005 cluster monitoring
PDF
23769377 lab-bgp-juniper
PDF
Out of the box replication in postgres 9.4
PPTX
Git tutorial
PPTX
Db2 V12 incompatibilities_&_improvements_over_V11
PDF
Comandos
DOC
Upgrade 10204-to-10205 on-2-node_rac_linux_x86_64_detail-steps_v0.1
PPTX
NIC 2013 - Hyper-V Replica
PPTX
DB2 Basic Commands - UDB
PDF
Mastering PostgreSQL Administration
 
PPTX
HBaseCon 2013: A Developer’s Guide to Coprocessors
PostgreSQL Performance Tuning
MySQL Multi-Source Replication for PL2016
Ns2leach
Athenticated smaba server config with open vpn
Learning MySQL 5.7
FOSDEM 2012: MySQL synchronous replication in practice with Galera
12c for Developers - Feb 2014
Arp Dan Ipconfig Syntax
PostgreSQL Portland Performance Practice Project - Database Test 2 Tuning
005 cluster monitoring
23769377 lab-bgp-juniper
Out of the box replication in postgres 9.4
Git tutorial
Db2 V12 incompatibilities_&_improvements_over_V11
Comandos
Upgrade 10204-to-10205 on-2-node_rac_linux_x86_64_detail-steps_v0.1
NIC 2013 - Hyper-V Replica
DB2 Basic Commands - UDB
Mastering PostgreSQL Administration
 
HBaseCon 2013: A Developer’s Guide to Coprocessors
Ad

Similar to Mysql 5.5 and 5.6 replication (20)

PPTX
MySQL Replication Overview -- PHPTek 2016
PDF
Solving the C20K Problem: PHP Performance and Scalability
PDF
Solving the C20K Problem: PHP Performance and Scalability
PDF
Rails Application Optimization Techniques & Tools
PDF
Reducing Risk When Upgrading MySQL
PDF
Thoughts on consistency models
PDF
Oracle中加速索引创建或重建的方法
PDF
Tips and Tricks for SAP Sybase ASE
PPTX
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
PDF
Demystifying postgres logical replication percona live sc
PDF
MySQL Replication Update -- Zendcon 2016
PDF
Postgres Vienna DB Meetup 2014
PDF
MySQL Replication Basics -Ohio Linux Fest 2016
ODP
MySQL 101 PHPTek 2017
PDF
Perforce Administration: Optimization, Scalability, Availability and Reliability
PPTX
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
PDF
Replication features, technologies and 3rd party Extinction
PDF
MySQL 5.7 innodb_enhance_partii_20160527
ZIP
My sql replication advanced techniques presentation
PPTX
MariaDB High Availability
MySQL Replication Overview -- PHPTek 2016
Solving the C20K Problem: PHP Performance and Scalability
Solving the C20K Problem: PHP Performance and Scalability
Rails Application Optimization Techniques & Tools
Reducing Risk When Upgrading MySQL
Thoughts on consistency models
Oracle中加速索引创建或重建的方法
Tips and Tricks for SAP Sybase ASE
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
Demystifying postgres logical replication percona live sc
MySQL Replication Update -- Zendcon 2016
Postgres Vienna DB Meetup 2014
MySQL Replication Basics -Ohio Linux Fest 2016
MySQL 101 PHPTek 2017
Perforce Administration: Optimization, Scalability, Availability and Reliability
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
Replication features, technologies and 3rd party Extinction
MySQL 5.7 innodb_enhance_partii_20160527
My sql replication advanced techniques presentation
MariaDB High Availability
Ad

More from Giuseppe Maxia (20)

PDF
MySQL NDB 8.0 clusters in your laptop with dbdeployer
PDF
Test like a_boss
PDF
Dbdeployer, the universal installer
PDF
Test complex database systems in your laptop with dbdeployer
PDF
Dbdeployer
PDF
Dbdeployer
PDF
A quick tour of Mysql 8 roles
PDF
MySQL document_store
PDF
Replication skeptic
PDF
Synchronise your data between MySQL and MongoDB
PDF
Juggle your data with Tungsten Replicator
PDF
MySQL in your laptop
PDF
Script it
PDF
Tungsten Replicator tutorial
PDF
Preventing multi master conflicts with tungsten
PDF
MySQL high availability power and usability
PDF
Solving MySQL replication problems with Tungsten
PDF
State of the art of MySQL replication and clustering
PDF
Testing mysql creatively in a sandbox
PDF
Lightning talks percona live mysql_2012
MySQL NDB 8.0 clusters in your laptop with dbdeployer
Test like a_boss
Dbdeployer, the universal installer
Test complex database systems in your laptop with dbdeployer
Dbdeployer
Dbdeployer
A quick tour of Mysql 8 roles
MySQL document_store
Replication skeptic
Synchronise your data between MySQL and MongoDB
Juggle your data with Tungsten Replicator
MySQL in your laptop
Script it
Tungsten Replicator tutorial
Preventing multi master conflicts with tungsten
MySQL high availability power and usability
Solving MySQL replication problems with Tungsten
State of the art of MySQL replication and clustering
Testing mysql creatively in a sandbox
Lightning talks percona live mysql_2012

Recently uploaded (20)

PPTX
Blending method and technology for hydrogen.pptx
PDF
Introduction to c language from lecture slides
PDF
Child-friendly e-learning for artificial intelligence education in Indonesia:...
PDF
GDG Cloud Southlake #45: Patrick Debois: The Impact of GenAI on Development a...
PPTX
CRM(Customer Relationship Managmnet) Presentation
PDF
Intravenous drug administration application for pediatric patients via augmen...
PPTX
Slides World Game (s) Great Redesign Eco Economic Epochs.pptx
PPTX
Presentation - Principles of Instructional Design.pptx
PDF
Applying Agentic AI in Enterprise Automation
PDF
TicketRoot: Event Tech Solutions Deck 2025
PPTX
From Curiosity to ROI — Cost-Benefit Analysis of Agentic Automation [3/6]
PDF
Domain-specific knowledge and context in large language models: challenges, c...
PDF
Altius execution marketplace concept.pdf
PDF
State of AI in Business 2025 - MIT NANDA
PDF
Addressing the challenges of harmonizing law and artificial intelligence tech...
PDF
Human Computer Interaction Miterm Lesson
PDF
TrustArc Webinar - Data Minimization in Practice_ Reducing Risk, Enhancing Co...
PDF
Revolutionizing recommendations a survey: a comprehensive exploration of mode...
PDF
Technical Debt in the AI Coding Era - By Antonio Bianco
PPTX
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]
Blending method and technology for hydrogen.pptx
Introduction to c language from lecture slides
Child-friendly e-learning for artificial intelligence education in Indonesia:...
GDG Cloud Southlake #45: Patrick Debois: The Impact of GenAI on Development a...
CRM(Customer Relationship Managmnet) Presentation
Intravenous drug administration application for pediatric patients via augmen...
Slides World Game (s) Great Redesign Eco Economic Epochs.pptx
Presentation - Principles of Instructional Design.pptx
Applying Agentic AI in Enterprise Automation
TicketRoot: Event Tech Solutions Deck 2025
From Curiosity to ROI — Cost-Benefit Analysis of Agentic Automation [3/6]
Domain-specific knowledge and context in large language models: challenges, c...
Altius execution marketplace concept.pdf
State of AI in Business 2025 - MIT NANDA
Addressing the challenges of harmonizing law and artificial intelligence tech...
Human Computer Interaction Miterm Lesson
TrustArc Webinar - Data Minimization in Practice_ Reducing Risk, Enhancing Co...
Revolutionizing recommendations a survey: a comprehensive exploration of mode...
Technical Debt in the AI Coding Era - By Antonio Bianco
Strategic Picks — Prioritising the Right Agentic Use Cases [2/6]

Mysql 5.5 and 5.6 replication

  • 1. What's new in MySQL 5.5 and 5.6 replication Giuseppe Maxia Continuent, Inc ©Continuent 2012. Tuesday, April 17, 12 1
  • 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 2 Tuesday, April 17, 12 2
  • 3. DA AG EN semi-synch replication Tuesday, April 17, 12 3
  • 4. semi-synchronous replication • Available in 5.5 and higher • Makes sure that at least one slave has copied the data. • Increases reliability Tuesday, April 17, 12 4
  • 5. client master transaction 1 with regular commit replication execute 2 slave returns 4 to client binary log 3 5 replication 5 Tuesday, April 17, 12 5
  • 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 6 Tuesday, April 17, 12 6
  • 7. semi-synchronous replication in practice • installation: • it’s a plugin. • Actually, two plugins Tuesday, April 17, 12 7
  • 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 servers Tuesday, April 17, 12 8
  • 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. 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. 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. 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. 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. 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. 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. 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. DA AG EN delayed replication Tuesday, April 17, 12 17
  • 18. delayed replication in practice STOP SLAVE; change master to master_delay=60; START SLAVE; SHOW SLAVE STATUSG (...) SQL_Delay: 60 SQL_Remaining_Delay: NULL Tuesday, April 17, 12 18
  • 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. 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. DA AG EN Server UUID Tuesday, April 17, 12 21
  • 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_5 Tuesday, April 17, 12 22
  • 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: Yes Tuesday, April 17, 12 23
  • 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 it Tuesday, April 17, 12 24
  • 25. DA AG EN crash safe slave Tuesday, April 17, 12 25
  • 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. 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. 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: 0 Tuesday, April 17, 12 28
  • 29. Look at the new features show slave statusG .... .... Master_UUID: be3c022a-726f-11e1-a26a- a64f991393aa Master_Info_File: mysql.slave_master_info Tuesday, April 17, 12 29
  • 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: 86400 Tuesday, April 17, 12 30
  • 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: 3 Tuesday, April 17, 12 31
  • 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. DA AG EN multi-threaded slave Tuesday, April 17, 12 33
  • 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 schema Tuesday, April 17, 12 34
  • 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. DA AG EN global transaction identifier Tuesday, April 17, 12 36
  • 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-statements Tuesday, April 17, 12 37
  • 38. global transaction identifier issues • Can't 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. 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 servers Tuesday, April 17, 12 39
  • 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. 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-2 Tuesday, April 17, 12 41
  • 43. ADVERTISING ©Continuent 2012 43 Tuesday, April 17, 12 43
  • 44. WE ARE HIRING! • Cluster implementation engineer • QA engineer • Documentation writer http://www.continuent.com/about/careers ©Continuent 2012 44 Tuesday, April 17, 12 44