# 创建用于同步的用户 mysql> grant replication slave on *.* to mharep@'192.168.20.%' identified by '123.com'; Query OK, 0 rows affected, 1 warning (1.00 sec) # 创建用户mha的manager监控的用户 mysql> grant all on *.* to manager@'192.168.20.%' identified by '123.com'; Query OK, 0 rows affected, 1 warning (0.00 sec) # 查看master二进制相关的信息 mysql> show master statusG *************************** 1. row *************************** File: mysql-bin.000001 Position: 744 Binlog_Do_DB: Binlog_Ignore_DB: Executed_Gtid_Set: 1 row in set (0.00 sec) 2)slave1主机操作如下:
# 创建用于同步的用户 mysql> grant replication slave on *.* to mharep@'192.168.20.%' identified by '123.com'; Query OK, 0 rows affected, 1 warning (1.00 sec) # 创建用户mha的manager监控的用户 mysql> grant all on *.* to manager@'192.168.20.%' identified by '123.com'; Query OK, 0 rows affected, 1 warning (0.00 sec) 3)slave2主机操作如下:
由于slave2无需做备主,所以不用创建用于同步数据的账户
#创建manager监控账号 mysql> grant all on *.* to manager@'192.168.20.%' identified by '123.com'; Query OK, 0 rows affected, 1 warning (0.00 sec) 6、配置主从复制 以下操作需要在slave1和slave2主机上分别执行一次,以便同步master主机的数据。