我在主机上运行了2个slave mysql实例,它们从不同主机上的master复制数据。所有实例都是mysql 5.6。即使主站没有变化,从站实例的中继箱日志也会不断变化。
以下是slave1:{/ p>的show slave status\G
Slave_IO_State: Waiting for master to send event
Master_Log_File: mysql-bin.000008
Read_Master_Log_Pos: 210424
Relay_Log_File: mysqld1-relay-bin.000878
Relay_Log_Pos: 354
Relay_Master_Log_File: mysql-bin.000008
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
... : ...
一段时间后,slave1的Relay_Log_File发生了变化,
Slave_IO_State: Waiting for master to send event
Master_Log_File: mysql-bin.000008
Read_Master_Log_Pos: 210424
Relay_Log_File: mysqld1-relay-bin.001374
Relay_Log_Pos: 354
Relay_Master_Log_File: mysql-bin.000008
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
... : ...
但没有对master,slave1或slave2进行任何更改。 slave2也发生了同样的事情。 我怀疑这两个奴隶是以某种方式共享配置/设置他们不应该,但我无法确定出了什么问题。 my.cnf文件有
# The MySQL server mysqld1
[mysqld1]
user = mysql
port = 3301
pid-file = /usr/local/mysql1/data/mysqld1.pid
socket = /tmp/mysql1.sock
datadir = /usr/local/mysql1/data
log-bin=mysql-bin
binlog_format=mixed
gtid-mode=on
disable-gtid-unsafe-statements=true
log-slave-updates=true # needed to enable gtid
sync-master-info = 1
master-info-repository=TABLE
relay-log-info-repository=TABLE
server-id = 2
innodb_data_home_dir = /usr/local/mysql1/data
innodb_log_group_home_dir = /usr/local/mysql1/data
innodb_flush_log_at_trx_commit = 1
sync_binlog=1
[mysqld2]
user = mysql
port = 3302
pid-file = /usr/local/mysql2/data/mysqld2.pid
socket = /tmp/mysql2.sock
datadir = /usr/local/mysql2/data
log-bin=mysql-bin
binlog_format=mixed
gtid-mode=on
disable-gtid-unsafe-statements=true
log-slave-updates=true # needed to enable gtid
sync-master-info = 1
master-info-repository=TABLE
relay-log-info-repository=TABLE
server-id = 3
innodb_data_home_dir = /usr/local/mysql2/data
innodb_log_group_home_dir = /usr/local/mysql2/data
innodb_flush_log_at_trx_commit = 1
sync_binlog=1
有没有人遇到过这样的事情?以这种方式运行多个实例需要自定义命名中继日志吗? 感谢。
答案 0 :(得分:1)
事实证明,两个奴隶的log-bin名称需要不同。我已将其改为
[mysqld1]
log-bin=mysql-bin
[mysqld2]
log-bin=mysql-bin
到
[mysqld1]
log-bin=slave1-bin
[mysqld2]
log-bin-slave2-bin
来自Replication and auto-failover made easy with MySQL Utilities的示例配置提供了相关提示。