gpt4 book ai didi

一台主机上有多个slave实例的mysql复制,relay bin不断变化

转载 作者:行者123 更新时间:2023-11-29 00:38:02 26 4
gpt4 key购买 nike

我有 2 个在主机上运行的从属 mysql 实例,它们从不同主机上的主服务器复制数据。所有实例都是 mysql 5.6。即使没有来自主实例的更改,从实例的中继 bin 日志也会不断变化。以下是 slave1 的 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

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

最佳答案

事实证明,两个从站的 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 的示例配置对此给出了提示。

关于一台主机上有多个slave实例的mysql复制,relay bin不断变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13466979/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com