2

我有 2 个从属 mysql 实例在主机上运行,​​它从不同主机上的主机复制数据。所有实例都是mysql 5.6。从属实例的中继箱日志不断变化,即使主实例没有变化。以下是show slave status\Gslave1的:

           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

有没有人遇到过这样的事情?以这种方式运行多个实例是否需要自定义命名中继日志?谢谢。

4

1 回答 1

2

事实证明,两个从站的 log-bin 名称需要不同。我已经把它们从

[mysqld1]
log-bin=mysql-bin
[mysqld2]
log-bin=mysql-bin

[mysqld1]
log-bin=slave1-bin
[mysqld2]
log-bin-slave2-bin

使用 MySQL Utilities 轻松实现复制和自动故障转移的示例配置提供了有关此方面的提示。

于 2012-11-20T17:59:18.453 回答