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

MySQL双主高可用架构之MMM实战

[日期:2012-11-14] 来源:Linux社区  作者:qiuzhijun [字体:大 中 小]

四、配置MySQL-M1和MySQL-M2主主模式

1.首先创建三个账号

mysql> grant file, replication salve on *.* to 'repl'@'192.168.8.%' identified by "repl";
mysql> grant process, super, replication client on *.* to 'mmm_agent'@'192.168.8.%' identified by 'mmm_agent';
mysql> grant replication client on *.* to "mmm_monitor"@"192.168.8.%" identified by "mmm_monitor";

说明:
第一个账号repl(复制账号),是用于主主复制
第二个账号mmm_agent(代理账号),是mmm agent用来变成只读模式和同步master等
第三个账号mmm_monitor(监听账号),是mmm monitor服务器用来对mysql服务器做健康检查的

要注意一点是:由于MySQL-M1和MySQL-M2之间有复制,所以只要在一台服务器上执行就可以了,不过要在MySQL-MON上执行后面两条!

2.配置主主模式

2.1 把MySQL-M1服务器作为MySQL-M2服务器主

在MySQL-M1服务器操作:

mysql> show master status;

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

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |

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

| mysql-bin.000003 | 107 | | mysql |

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

1 row in set (0.00 sec)

然后在MySQL-M2服务器操作:

mysql> change master to master_host='192.168.8.32',master_user='repl',master_password='repl',master_log_file='mysql-bin.000003',master_log_pos=107;

Query OK, 0 rows affected (0.07 sec)

mysql> start slave;

Query OK, 0 rows affected (0.00 sec)

mysql> show slave status\G

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

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.8.32

Master_User: repl

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000003

Read_Master_Log_Pos: 107

Relay_Log_File: mysql-relay.000002

Relay_Log_Pos: 253

Relay_Master_Log_File: mysql-bin.000003

Slave_IO_Running: Yes

Slave_SQL_Running: Yes
.....................................................
后面的信息省略..
.....................................................

2.2 把MySQL-M2服务器作为MySQL-M1服务器主

在MySQL-M2服务器上操作:

mysql> show master status;

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

| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |

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

| mysql-bin.000003 | 605 | | |

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

1 row in set (0.00 sec)

在MySQL-M1服务器上操作:

mysql> change master to master_host='192.168.8.33',master_user='repl',master_password='repl',master_log_file='mysql-bin.000003',master_log_pos=605;

Query OK, 0 rows affected (0.06 sec)

mysql> start slave;

Query OK, 0 rows affected (0.00 sec)

mysql> show slave status\G;

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

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.8.33

Master_User: repl

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000003

Read_Master_Log_Pos: 605

Relay_Log_File: mysql-relay.000002

Relay_Log_Pos: 253

Relay_Master_Log_File: mysql-bin.000003

Slave_IO_Running: Yes

Slave_SQL_Running: Yes
.....................................................
后面的信息省略..
.....................................................

OK...主主模式配置成功!主主复制同步测试这里不再说明,接着下面的步骤。

linux
相关资讯       高可用  MySQL高可用  MMM  MySQL MMM实战 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

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