MySQL DBA Linux SA C/C++ Perl PHP Python Hadoop
分类: Mysql/postgreSQL
2014-12-04 10:22:03
mysql告警日志alert.log里面每个小时都有以下报错:
141203 11:45:22 [ERROR] MYSQL_BIN_LOG::purge_logs was called with file /u01/my3431/log/mysql-bin.000001 not listed in the index.
$ll mysql-bin.*
-rw-rw---- 1 mysql dba 26073 Dec 10 2013 mysql-bin.000001
-rw-rw---- 1 mysql dba 912964 Dec 10 2013 mysql-bin.000002
-rw-rw---- 1 mysql dba 9157 Dec 10 2013 mysql-bin.000003
-rw-rw---- 1 mysql dba 524288336 Feb 21 2014 mysql-bin.000004
-rw-rw---- 1 mysql dba 524288056 Apr 15 2014 mysql-bin.000005
-rw-rw---- 1 mysql dba 524288085 Jul 21 18:17 mysql-bin.000006
-rw-rw---- 1 mysql dba 524288047 Oct 27 06:43 mysql-bin.000007
-rw-rw---- 1 mysql dba 200600175 Dec 3 13:56 mysql-bin.000008
-rw-rw---- 1 mysql dba 264 Oct 27 06:43 mysql-bin.index
$sudo cat mysql-bin.index
/u01/mybase/log/mysql-bin.000001 // 路径错误,应该是/u01/my3431/log/
/u01/mybase/log/mysql-bin.000002 // 路劲错误,应该是/u01/my3431/log/
/u01/mybase/log/mysql-bin.000003 // 路劲错误,应该是/u01/my3431/log/
/u01/my3431/log/mysql-bin.000004
/u01/my3431/log/mysql-bin.000005
/u01/my3431/log/mysql-bin.000006
/u01/my3431/log/mysql-bin.000007
/u01/my3431/log/mysql-bin.000008
应该已经看出问题了。binlog的索引文件里面,前3个文件的路径是错误的,purge的时候,和/u01/my3431/log/mysql-bin.000001这个目录对应不上,故清理失败报错。
解决方法:
修改mysql-bin.index文件中的错误路径;需要注意的是,这里需要sudo到mysql账号,如果用个人账号或者root,vim后保存,
将导致mysql账号没有权限。
# 修改后如下:
cat mysql-bin.index
/u01/my3431/log/mysql-bin.000001
/u01/my3431/log/mysql-bin.000002
/u01/my3431/log/mysql-bin.000003
/u01/my3431/log/mysql-bin.000004
/u01/my3431/log/mysql-bin.000005
/u01/my3431/log/mysql-bin.000006
/u01/my3431/log/mysql-bin.000007
/u01/my3431/log/mysql-bin.000008
# 登陆mysql,执行flush logs;
为啥要flush logs,留个思考题,哈哈。