MySQL 复制在 binlog 轮换后关闭

MySQL 复制在 binlog 轮换后关闭

我遇到了以下问题。我已成功设置主从服务器(基于行)。它已运行 2-3 小时。在 bin-log 轮换后 -> mysql-bin.index 文件在主服务器上损坏。

这里显示主日志;

显示主日志\G

*************************** 1. row ***************************
 Log_name: mysql-bin.000001
File_size: 27682022

 *************************** 2. row ***************************
 Log_name: mysqld  Ver 5.1.73-5-beget-log for debian-linux-gnu on x86_64 ((LTD BeGet))
 File_size: 0

 *************************** 3. row ***************************
 Log_name: or its affiliates
 File_size: 0

 *************************** 4. row ***************************
 Log_name: or its affiliates. All rights reserved.
 File_size: 0

 4 rows in set (0.00 sec)

Master上mysql的配置文件:

cat /etc/mysql/my.cnf  | grep -v -E "^$" | grep -v -E "^#"
[mysqld]
event_scheduler = 1
interactive_timeout = 30
set-variable        = wait_timeout=30
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /home/mysql
tmpdir          = /home/tmpfs
server_id = 1
log-bin = mysql-bin
binlog-do-db = somedb
binlog-format = row
skip-external-locking
bind-address                = 0.0.0.0
default-character-set   = UTF8
innodb_file_per_table = 1
max_allowed_packet      = 128M
thread_stack            = 512K
thread_cache_size       = 64
myisam-recover          = BACKUP
thread_concurrency      = 48
max_user_connections    = 100
max_connections         = 200
back_log                = 500
join_buffer_size        = 4M
read_buffer_size        = 4M
read_rnd_buffer_size    = 8M
sort_buffer_size        = 4M
myisam_sort_buffer_size = 512M
query_cache_limit       = 4M
query_cache_size        = 128M
tmp_table_size          = 5000M
max_heap_table_size     = 5000M
key_buffer              = 128M
max_connect_errors      = 65000
max_error_count         = 65000
key_buffer_size         = 102M
open_files_limit        = 1040000
table_open_cache        = 10000
table_definition_cache  = 100000

mysql-bin.index 文件包含 mysqld --help 的输出

show slave status 有以下错误:

Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 4
Relay_Log_File: mysqld-relay-bin.000003
Relay_Log_Pos: 152
Relay_Master_Log_File: mysql-bin.000002
Last_IO_Errno: 1236
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'
Last_SQL_Errno: 0
Last_SQL_Error: 

mysql 版本:

mysql -V
mysql  Ver 14.14 Distrib 5.1.73, for debian-linux-gnu (x86_64) using readline 5.1

我在错误日志中没有发现任何奇怪的东西。实际上我不知道如何调试它。任何帮助都将不胜感激。

答案1

好的,回答我自己的问题。这是我们在 MySQL 服务器中发现的一个错误。为了简单起见,我们用 nagios 检查了一下,结果如下

mysqld --verbose --help 2>&1 >&-

好的,问题就在这里,stdout 已关闭。mysql 将输出打印到之前打开的索引文件中。

针对此案例,我们已打开 bug: https://bugs.launchpad.net/percona-server/+bug/1401547

修复很容易,只需删除 >&-,这样我们就不会关闭标准输出,但这仍然是奇怪的行为。

相关内容