手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

MySQL 主从复制详解

[日期:2013-10-01] 来源:Linux社区  作者:limian [字体:大 中 小]

四、半同步复制

1、在主服务器上安装master模块,

MySQL> install plugin rpl_semi_sync_master soname 'semisync_master.so';

2、开启半同步功能

mysql> set global rpl_semi_sync_master_enabled =1;
mysql> set global rpl_semi_sync_master_timeout = 1000;

3、查看启动结果

mysql> show global status like 'rpl_semi%';
+--------------------------------------------+-------+
| Variable_name                              | Value |
+--------------------------------------------+-------+
| Rpl_semi_sync_master_clients              | 0    |
| 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    |
+--------------------------------------------+-------+
14 rows in set (0.04 sec)
显示已启动

4、在从服务器执行相同命令

[root@node2 mysql]# mysql
mysql> install plugin rpl_semi_sync_slave soname 'semisync_slave.so';
mysql> set global rpl_semi_sync_slave_enabled = 1;

5、重启IO线程

mysql> stop slave io_thread;
mysql> start slave io_thread;

6、在主服务器上查看semi_sync是否开启

mysql> show global status like 'rpl_semi%';
+--------------------------------------------+-------+
| Variable_name                              | Value |
+--------------------------------------------+-------+
| Rpl_semi_sync_master_clients              | 1    |
| 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    |
+--------------------------------------------+-------+
14 rows in set (0.00 sec)
结果显示已经有一个从服务器连接

7、测试:

主服务器:

mysql> drop database mydb;
mysql> show databases;
+--------------------+
| Database          |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test              |
+--------------------+
4 rows in set (0.08 sec)

从服务器:

mysql> show databases;
+--------------------+
| Database          |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test              |
+--------------------+
4 rows in set (0.01 sec)
结果显示数据同步完成

linux
相关资讯       MySQL主从复制 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款