Assume
Master1 = 172.16.1.1
Master2 = 172.16.1.2
Database users
GRANT ALL PRIVILEGES ON *.* TO 'slaveuser'@'localhost'IDENTIFIED BY 'slavepw' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'slaveuser'@'%' IDENTIFIED BY 'slavepw' WITH GRANT OPTION;
Master1
=========================================================
[mysqld]
auto_increment_increment=2
auto_increment_offset=1
# Replication Master Server
# binary logging is required for replication
log-bin=master1-bin
binlog-ignore-db=mysql
binlog-ignore-db=test
# required unique id between 1 and 2^32 - 1
server-id = 1
#following is the slave settings so this server can connect to master2
master-host = 172.16.1.2
master-user = slaveuser
master-password = slavepw
master-port = 3306
#If you want to enable log add this entry for [mysqld] section:
log-error=/var/log/mysqld.log
========================================================
Master 2
==========================================================
[mysqld]
auto_increment_increment=2
auto_increment_offset=2
# Replication Master Server
# binary logging is required for replication
log-bin=master2-bin
binlog-ignore-db=mysql
binlog-ignore-db=test
# required unique id between 1 and 2^32 - 1
server-id = 2
#following is the slave settings so this server can connect to master2
master-host = 172.16.1.1
master-user = slaveuser
master-password = slavepw
master-port = 3306
#If you want to enable log add this entry for [mysqld] section:
log-error=/var/log/mysqld.log
==============================================================
Master 1
grant replication slave on *.* to slaveuser@'172.16.1.2' identified by 'slavepw';
Master 2
grant replication slave on *.* to slaveuser@'172.16.1.1' identified by 'slavepw';
=============================================
Restart both
=============================================
show slave status\G
No comments:
Post a Comment