# 創(chuàng)建用于同步的用戶 mysql> grant replication slave on *.* to mharep@'192.168.20.%' identified by '123.com'; Query OK, 0 rows affected, 1 warning (1.00 sec) # 創(chuàng)建用戶mha的manager監(jiān)控的用戶 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主機操作如下:
# 創(chuàng)建用于同步的用戶 mysql> grant replication slave on *.* to mharep@'192.168.20.%' identified by '123.com'; Query OK, 0 rows affected, 1 warning (1.00 sec) # 創(chuàng)建用戶mha的manager監(jiān)控的用戶 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無需做備主,所以不用創(chuàng)建用于同步數(shù)據(jù)的賬戶
#創(chuàng)建manager監(jiān)控賬號 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主機上分別執(zhí)行一次,以便同步master主機的數(shù)據(jù)。