码迷,mamicode.com
首页 > 数据库 > 详细

mysql半同步复制及复制过滤

时间:2016-11-01 21:37:43      阅读:322      评论:0      收藏:0      [点我收藏+]

标签:mysql半同步

配置mysql半同步,前提是已经有master和slave环境。

MySQL半同步配置

Master配置

安装semisync_master插件

mysql> INSTALL PLUGIN rpl_semi_sync_master SONAME ‘semisync_master.so‘;

Query OK, 0 rows affected (0.02 sec)


mysql>show plugins;

+----------------------------+----------+--------------------+--------------------+---------+

| Name                       | Status   | Type               | Library            | License |

+----------------------------+----------+--------------------+--------------------+---------+

| rpl_semi_sync_master       | ACTIVE   | REPLICATION        | semisync_master.so | GPL     |


vim /etc/my.cnf

[mysqld]

rpl_semi_sync_master_enabled=ON


service mysqld restart

mysql> show global variables like ‘%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    |

+------------------------------------+-------+

4 rows in set (0.00 sec)


Slave配置

mysql> INSTALL PLUGIN rpl_semi_sync_slave SONAME ‘semisync_slave.so‘;

Query OK, 0 rows affected (0.00 sec)


vim /etc/my.cnf

[mysqld]

rpl_semi_sync_slave_enabled=ON


service mysqld restart


mysql> show global variables like ‘%semi%‘;

+---------------------------------+-------+

| Variable_name                   | Value |

+---------------------------------+-------+

| rpl_semi_sync_slave_enabled     | ON    |

| rpl_semi_sync_slave_trace_level | 32    |

+---------------------------------+-------+

2 rows in set (0.00 sec)


mysql> start slave;

Query OK, 0 rows affected, 1 warning (0.00 sec)


配置完成后在Master查看半同步复制状态

mysql> show global status like ‘%sem%‘;

+--------------------------------------------+-------+

| Variable_name                              | Value |

+--------------------------------------------+-------+

| Rpl_semi_sync_master_clients               | 1     |

| Rpl_semi_sync_master_net_avg_wait_time     | 703   |

| Rpl_semi_sync_master_net_wait_time         | 703   |

| 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      | 777   |

| Rpl_semi_sync_master_tx_wait_time          | 777   |

| 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     |

+--------------------------------------------+-------+

14 rows in set (0.00 sec)


mysql复制过滤

slave配置:

vim /etc/my.cnf

[mysqld]

replicate-do-db =sync_db  //复制时指定要复制的DB

mysql> show slave status\G;

*************************** 1. row ***************************

               Slave_IO_State: Waiting for master to send event

                  Master_Host: 192.168.1.202

                  Master_User: repluser

                  Master_Port: 3306

                Connect_Retry: 60

              Master_Log_File: master_bin.000006

          Read_Master_Log_Pos: 344

               Relay_Log_File: relay_log.000019

                Relay_Log_Pos: 284

        Relay_Master_Log_File: master_bin.000006

             Slave_IO_Running: Yes

            Slave_SQL_Running: Yes

              Replicate_Do_DB: sync_db


mysql半同步复制及复制过滤

标签:mysql半同步

原文地址:http://linuxinfo.blog.51cto.com/412748/1868189

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!