mysql5.5 Semi-synchronous replication

Source: Internet
Author: User

First, the purpose of the experiment:

MySQL also supports semi-synchronous replication in master-slave replication, andmysql replication is asynchronous because the synchronization performance is very poor. After the main library distribution event, you must wait for the end of the copy data from the library and receive a normal response from the library before you can proceed to the next step. The main library is unknown when the asynchronous pattern causes the main library to lag behind the library. So mysql5.5 after the introduction of Google patch semi-synchronous replication,2 plugins:semisync_master.so and semisync_slave.so . Semi-synchronous: In a master multi-slave architecture, the main library waits for only one copy from the library to complete the data and returns to the normal response, it is considered that the synchronization completes the next step, so that there is asynchronous high-speed, and synchronization security. Once the main library waits for a response timeout from the library, the semi-synchronous replication is automatically demoted to asynchronous replication. semi-synchronous replication premise at least one from the library and the main library in the same room, to ensure sufficient bandwidth, data replication is fast enough . Because of the great impact on write performance and need synchronous confirmation wait.


Second, the experimental steps

1.mysql supported modules / plugins

[Email protected]~]# ls-t/usr/local/mysql/lib/plugin/debug semisync_slave.so mypluglib.so qa_auth_interface.so qa_a uth_client.so adt_null.so daemon_example.ini semisync_master.so libdaemon_example.so qa_auth_server.so auth_test_plu gin.so auth_socket.so auth.so

2. semi-synchronous module installation

2.1 Main Library

mysql>install plugin rpl_semi_sync_master soname  ' semisync_master.so '; Mysql>SHOW  GLOBAL VARIABLES LIKE  '%semi% ';   server variable +------------------------------------+--- ----+| variable_name                       | value |+------------------------------------+-------+|rpl_semi_sync_master_enabled        | off   | | rpl_semi_sync_master_timeout       |10000 |  Master-Slave library connection timeout value, automatically dropped to asynchronous. Ms |rpl_semi_sync_master_trace_level   |32    | | rpl_semi_sync_master_wait_no_slave | on   |  not from the library to wait a bit +-------------------------- ----------+-------+mysql>set global rpl_semi_sync_master_enabled=1;mysql>set global  Rpl_semi_sync_master_timeout=1000;mysql>show global status LIKE  '%semi% '; +--------------------------------------------+-------+| variable_name                               | value |+------ --------------------------------------+-------+| rpl_semi_sync_master_clients               | 1     |  1 from Nodes | rpl_semi_sync_master_net_avg_wait_time    | 0     | | rpl_semi_sync_master_net_wait_time        | 0      | | Rpl_semi_sync_master_net_waits            | 0      | | rpl_semi_sync_master_no_times             |  0     | | rpl_semi_sync_master_no_tx                 | 0     | | rpl_semi_sync_master_status                | on    | | rpl_semi_sync_master_timefunc_failures    | 0     | | rpl_semi_sync_master_tx_avg_wait_time     | 0     | | rpl_semi_sync_master_tx_wait_time         | 0      | | rpl_semi_sync_master_tx_waits             |  0     | | rpl_semi_sync_master_wait_pos_backtraverse | 0     | | Rpl_semi_sync_master_wait_sessions        | 0     | | rpl_semi_sync_master_yes_tx                | 0     |+--------------------------------------------+-------+mysql >USE SCHOOL;MYSQL>CREATE TABLE TB2 (Name char ());mysql>show global  status like  '%semi% '; +--------------------------------------------+-------+| variable_name                              | value |+------------ --------------------------------+-------+| rpl_semi_sync_master_clients               | 1     | | rpl_semi_sync_master_net_avg_wait_time    | 800   |  waiting to return report time from service | rpl_semi_sync_master_net_wait_time        | 800   | | Rpl_semi_sync_master_net_waits            | 1      | | rpl_semi_sync_master_no_times             |  0     | | rpl_semi_sync_master_no_tx                 | 0     | | rpl_semi_sync_master_status                | on    | | rpl_semi_sync_master_timefunc_failures    | 0     | | rpl_semi_sync_master_tx_avg_wait_time     | 715   |  Waiting to return report time from service | rpl_semi_sync_master_tx_wait_time         | 715   | | rpl_semi_sync_master_tx_waits             |  1     | | rpl_semi_sync_master_wait_pos_backtraverse | 0     | | rpl_semi_sync_master_wait_sessions        | 0      | | rpl_semi_sync_master_yes_tx                | 1     |+--------------------------------------------+-------+mysql >INSERT INTO tb2 VALUES  (' Tom '), (' Jerry '), (' Jack ');mysql>show global  status like  '%semi% '; +--------------------------------------------+-------+| variable_name                              | value |+------------ --------------------------------+-------+| rpl_semi_sync_master_clients               | 1     | | rpl_semi_sync_master_net_avg_wait_time    | 1518  | | rpl_semi_sync_master_net_wait_time        | 3037  | | Rpl_semi_sync_master_net_waits            | 2      | | rpl_semi_sync_master_no_times             |  0     | | rpl_semi_sync_master_no_tx                 | 0     | | rpl_semi_sync_master_status                | on    | | Rpl_semi_sync_master_timefunc_failures    | 0     | | rpl_semi_sync_master_tx_avg_wait_time     | 715   | | rpl_semi_sync_master_tx_wait_time          | 715   | | rpl_semi_sync_master_tx_waits             |  1     | | rpl_semi_sync_master_wait_pos_backtraverse | 0     | | rpl_semi_sync_master_wait_sessions        | 0      | | rpl_semi_sync_master_yes_tx                | 2     |+--------------------------------------------+-------+

From the Library

mysql>install plugin rpl_semi_sync_slave soname  ' semisync_slave.so ';mysql>SHOW  global variables like  '%semi% '; +---------------------------------+-------+| variable_name                    | value |+---------------------------------+-------+|rpl_semi_sync_slave_enabled      | off   | | rpl_semi_sync_slave_trace_level | 32    |+---------------------------------+---- ---+mysql>set global rpl_semi_sync_slave_enabled=1;mysql>stop slave;mysql>start  slave;mysql>show global status like  '%semi% '; +----------------------------+-------+| Variable_name              | value  |+----------------------------+-------+| rpl_semi_sync_slave_status | on    |+----------------------------+-------+ 

permanently configured in Master and Slave in the my.cnf Editor:

# onmaster [[email protected]~]# vim /etc/my.cnf[mysqld] rpl_semi_sync_master_ enabled=1 rpl_semi_sync_master_timeout=1000# 1 second  Verification mysql>show global  variables like  '%semi% '; +------------------------------------+-------+| variable_name                       | value |+------------------------------------+-------+|rpl_semi _sync_master_enabled       | on    | | rpl_semi_sync_master_timeout       |1000  | | rpl_semi_sync_master_trace_level   |32    | | rpl_semi_sync_master_wait_no_slave | on   |+------------------------------------+---- ---+ # onslave [[email protected]~]# vim /etc/my.cnf[mysqld] rpl_semi_sync_ Slave_enabled=1  verify mysql>show global variables like  '%semi% '; +--------------------------- ------+-------+| variable_name                    | value |+---------------------------------+-------+|rpl_semi_sync_slave_enabled      | on    | | rpl_semi_sync_slave_trace_level | 32    |+---------------------------------+---- ---+


This article is from the "Aha45" blog, make sure to keep this source http://manfred12.blog.51cto.com/137312/1416412

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.