【前言】测试环境中,磁盘空间爆满了。发现有一百多个的binlog文件,每个文件默认都是1GB,这些binlog占用了90%的空间。然后就用rm -rf命令删除了binlog,紧接着重启数据库的时候发现启动报错了;
150915 16:22:21 mysqld_safe mysqld from pid file /data/mysql/localhost.localdomain.pid ended 150915 16:25:09 mysqld_safe Starting mysqld daemon with databases from /data/mysql 150915 16:25:09 InnoDB: The InnoDB memory heap is disabled 150915 16:25:09 InnoDB: Mutexes and rw_locks use GCC atomic builtins 150915 16:25:09 InnoDB: Compressed tables use zlib 1.2.3 150915 16:25:09 InnoDB: Initializing buffer pool, size = 128.0M 150915 16:25:09 InnoDB: Completed initialization of buffer pool 150915 16:25:10 InnoDB: highest supported file format is Barracuda. 150915 16:25:10 InnoDB: Waiting for the background threads to start 150915 16:25:11 InnoDB: 1.1.8 started; log sequence number 1870953 /usr/local/mysql/bin/mysqld: File './mysql-bin.000121' not found (Errcode: 2) 150915 16:25:11 [ERROR] Failed to open log (file './mysql-bin.000121', errno 2) 150915 16:25:11 [ERROR] Could not open log file 150915 16:25:11 [ERROR] Can't init tc log 150915 16:25:11 [ERROR] Aborting |
【解决方法】
1、MySQL在启动的时候会通过mysql-bin.index文件,查找当前的对应binlog文件信息,直接删除mysql-bin.index的内容后就可以了;
2、增加mysql参数: expire_logs_days = 2 保留两天的binlog日志;
注:删除之前需要进行备份一下
150915 16:26:22 mysqld_safe mysqld from pid file /data/mysql/localhost.localdomain.pid ended 150915 16:26:49 mysqld_safe Starting mysqld daemon with databases from /data/mysql 150915 16:26:49 InnoDB: The InnoDB memory heap is disabled 150915 16:26:49 InnoDB: Mutexes and rw_locks use GCC atomic builtins 150915 16:26:49 InnoDB: Compressed tables use zlib 1.2.3 150915 16:26:49 InnoDB: Initializing buffer pool, size = 128.0M 150915 16:26:49 InnoDB: Completed initialization of buffer pool 150915 16:26:49 InnoDB: highest supported file format is Barracuda. 150915 16:26:49 InnoDB: Waiting for the background threads to start 150915 16:26:50 InnoDB: 1.1.8 started; log sequence number 1870953 150915 16:26:50 [Note] Event Scheduler: Loaded 0 events 150915 16:26:50 [Note] /usr/local/mysql/bin/mysqld: ready for connections. Version: '5.5.23-log' socket: '/tmp/mysql.sock' port: 3306 Source distribution |
【说明】rm -rf是一个很危险的操作,删除日志建议按mysql提供的命令去操作,鉴于这里是测试环境,所以就比较大意;
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
本文作者:JOHN,某上市公司DBA,业余时间专注于数据库的技术管理,从管理的角度去运用技术。
技术博客:猎人笔记 数据库技术群:367875324 (请备注数据库类型)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++