show master status;
mysql-bin.000001 245 mysql,information_schema,performance_schema
配置节点2
vim /etc/mysql/my.cnf
server-id = 2
log_bin = mysql-bin.log
relay_log = mysql-relay-bin.log #中继日志
log_slave_updates = ON #中继日志执行后,变化计入日志
read_only = 0
binlog_format = “ROW”
auto_increment_increment = 2
auto_increment_offset = 2
binlog_ignore_db=mysql
binlog_ignore_db=information_schema
binlog_ignore_db=performance_schema
replicate_ignore_db=mysql
replicate_ignore_db=information_schema
replicate_ignore_db=performance_schema
配置主从
mysql -u root -p
CHANGE MASTER TO
MASTER_HOST=‘192.168.1.21’,
MASTER_USER=‘root’,
MASTER_PASSWORD=‘root’,
MASTER_LOG_FILE=‘mysql-bin.000001’,
MASTER_LOG_POS=245;
#开启同步
start slave
#查看同步状态 Slave_IO_Running和Slave_SQL_Running需要均为Yes
show slave status;
记录节点2的binlog日志位置
show master status;
mysql-bin.000001 1029 mysql,information_schema,performance_schema
配置主主(节点1)
vim /etc/mysql/my.cnf
relay_log = mysql-relay-bin.log
log_slave_updates = ON
read_only = 0
replicate_ignore_db=mysql
replicate_ignore_db=information_schema
replicate_ignore_db=performance_schema
开启同步
mysql -u root -p