MMM实现MySQL高可用详解(3)

[root@master-db1 ~]# scp /tmp/database-backup.sql master-db2:/tmp [root@master-db1 ~]# scp /tmp/database-backup.sql slave-db1:/tmp [root@master-db1 ~]# scp /tmp/database-backup.sql slave-db2:/tmp

9.master-db,slave-db1,slave-db2三台主机导入sql文件,并刷新权限:

[root@master-db2 ~]# mysql < /tmp/database-backup.sql [root@master-db2 ~]# mysql -e "FLUSH PRIVILEGES;"

四、设置MySQL主-从和主-主配置

1.在其他三台mysql上将master-db1设为主服务器

[root@master-db2 ~]# mysql mysql> CHANGE MASTER TO MASTER_HOST='192.168.1.11',MASTER_USER='replication',MASTER_PASSWORD='123456',MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=796; Query OK, 0 rows affected, 2 warnings (0.11 sec) mysql> start slave; Query OK, 0 rows affected (0.11 sec)
mysql
> show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.1.11 Master_User: replication Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 796 Relay_Log_File: relay-log.000002 Relay_Log_Pos: 283 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes

2.查看master-db2的master日志位置:

mysql> SHOW MASTER STATUS; +------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000001 | 636231 | | | | +------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)

3.在master-db1上操作,将master-db2设置为主:

mysql> CHANGE MASTER TO MASTER_HOST='192.168.1.12',MASTER_USER='replication',MASTER_PASSWORD='123456',MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=636231; Query OK, 0 rows affected, 2 warnings (0.03 sec) mysql> start slave; Query OK, 0 rows affected (0.01 sec) mysql> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.1.12 Master_User: replication Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 636231 Relay_Log_File: relay-log.000002 Relay_Log_Pos: 283 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes

五、安装MMM

1.创建Tools user

useradd -s /sbin/nologin mmmd #所有机器

2.查看mmm版本:

yum list all|grep ^mysql-mmm mysql-mmm.noarch 2.2.1-2.el6 @epel mysql-mmm-agent.noarch 2.2.1-2.el6 @epel mysql-mmm-monitor.noarch 2.2.1-2.el6 epel mysql-mmm-tools.noarch 2.2.1-2.el6 epel

3.在mmm-monitor上安装:

[root@mmm-monitor ~]# yum -y install mysql-mmm-monitor

4.在四台mysql服务器上安装:

yum -y install mysql-mmm-agent

5.编写配置文件,五台主机必须一致:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/4a87fd5cd8eca6a3ea21da59ec7da274.html