在主从的基础上,改为互为主从。需要注意某些配置文件。
A库配置文件
/etc/my.cnf
[mysqld]
basedir =/usr/local/mysql
datadir =/datal/mysql/data
port = 3306
server_id = 1
log-bin= mysql-bin
binlog_format = mixed
read-only=0
#binlog-do-db=test
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
auto-increment-offset=1
auto-increment-increment=2
#设置自增参数ID初始为1,不长2,也就是A库的自动ID为1、3、5、7、9。。。
#主主复制的从库设置(新增)
#replicate-do-db=test
replicate-ignore-db=mysql
replicate-ignore-db=information_schema
replicate-ignore-db=performance_schema
relay_log=mysql-relay-bin
log-slave-updates=on
B库配置文件
/etc/my.cnf
[mysqld]
basedir =/usr/local/mysql
datadir =/data/mysql/data
port = 3306
server_id = 2
log-bin= mysql-bin
binlog_format = mixed
read-only=0
#replicate-do-db=test
replicate-ignore-db=mysql
replicate-ignore-db=information_schema
replicate-ignore-db=performance_schema
relay_log=mysql-relay-bin
log-slave-updates=on
#主主复制的主库设置(新增)
#binlog-do-db=test
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
auto-increment-offset=2
auto-increment-increment=2
#设置自增ID初始值为2,步长为2,也就是B库的自增ID为2、4、6、8、10、、、