Mysql雙機熱備實現

部署環境:
操作系統版本:cent-os-7
數據庫版本:mysql-5.7
master1的IP地址:192.168.1.100
master2的IP地址:192.168.1.101



1.登錄master1和master2分別修改my.cnf:

#======master1========#
server-id = 1
log-bin=mysql-bin 
binlog-do-db = test
binlog-ignore-db = mysql
log-slave-updates
sync_binlog = 1
auto_increment_offset = 1
auto_increment_increment = 2
replicate-do-db = test
replicate-ignore-db = mysql,information_schema

#======master2========#
server-id = 2
log-bin=mysql-bin
binlog-do-db = test
binlog-ignore-db = mysql
log-slave-updates
sync_binlog = 1
auto_increment_offset = 2
auto_increment_increment = 2
replicate-do-db = test
replicate-ignore-db = mysql,information_schema

修改完後,重啓服務。


2.創建同步賬戶
#======master1========#
mysql>grant replication slave on *.* to [email protected] identified by "123";
mysql>flush privileges;

#======master1========#
mysql>grant replication slave on *.* to [email protected] identified by "123";
mysql>flush privileges;

3.修改需同步的主數據庫
#======master1========#
mysql>change master to
>master_host='192.168.1.101',master_user='user',master_password='123',
>master_log_file='mysql-bin.000001',master_log_pos=154;

>start slave;

#======master2========#
mysql>change master to
>master_host='192.168.1.100',master_user='user',master_password='123',
>master_log_file=' mysql-bin.00001',master_log_pos=154;

>start slave;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章