我有多台服务器设置了 MySQL 单向复制以用于备份目的。在其中一个奴隶上,我遇到了问题。恰好每 10 分钟它就会失去连接并重新连接而不会出现问题。错误日志中的示例:
121216 18:05:49 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.000002' at position 782733912
121216 18:05:49 [ERROR] Slave I/O: error reconnecting to master 'repl@127.0.0.1:5002' - retry-time: 60 retries: 86400, Error_code: 2013
121216 18:06:49 [Note] Slave: connected to master 'repl@127.0.0.1:5002',replication resumed in log 'mysql-bin.000002' at position 782733912
121216 18:15:49 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013)
121216 18:15:49 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.000002' at position 822218944
121216 18:15:49 [ERROR] Slave I/O: error reconnecting to master 'repl@127.0.0.1:5002' - retry-time: 60 retries: 86400, Error_code: 2013
121216 18:16:49 [Note] Slave: connected to master 'repl@127.0.0.1:5002',replication resumed in log 'mysql-bin.000002' at position 822218944
121216 18:25:49 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013)
121216 18:25:49 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.000002' at position 850106111
121216 18:25:49 [ERROR] Slave I/O: error reconnecting to master 'repl@127.0.0.1:5002' - retry-time: 60 retries: 86400, Error_code: 2013
因此,一切正常,但错误日志中充满了消息。
我查看了各种 MySQL 设置,但没有看到任何设置为 10 分钟或 600 秒。
FWIW,复制通过使用 AutoSSH 的 SSH 隧道进行。我查看了 sshd_config,但也没有看到任何超时设置。
我应该查看哪个设置?
最佳答案
我最近在看一些类似的问题,事实证明我们的防火墙阻止了 autossh 监控端口,因此 autossh 每 10 分钟重新启动一次 ssh。这也可能发生在你身上。
检查您的 autossh 日志。它通常是/var/log/syslog 除非你指定 AUTOSSH_LOGFILE
关于MySQL 复制从站每 10 分钟失去一次连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13904111/