四、配置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...主主模式配置成功!主主复制同步测试这里不再说明,接着下面的步骤。
