MySQL主主模式

使用主主的前提
1 表的主键自增

master1
vim /etc/my.cnf
auto_increment_increment = 2 自增ID的间隔如 1 3 5 间隔为2
auto_increment_offset = 1 ID的初始位置
log-slave-updates
log-bin

master2
vim /etc/my.cnf
auto_increment_increment = 2 自增ID的间隔如 2 4 6 间隔为2
auto_increment_offset = 2 ID的初始位置
log-slave-updates
log-bin

两台机器上都有能同步的用户

master 1
mysql> change master to
-> master_host=‘192.168.56.5’,
-> master_port=3306,
-> master_user=‘rep’,
-> master_password=‘slave.REP’;

master 1
mysql> change master to
-> master_host=‘192.168.56.6’,
-> master_port=3306,
-> master_user=‘rep’,
-> master_password=‘slave.REP’;

都开启start slave;

猜你喜欢

转载自blog.csdn.net/bjgaocp/article/details/88135001