首页 > 数据库 >mysql在启动时报错"Failed to open log xxxxxx/mysql-bin.000003 not found,errno 2"

mysql在启动时报错"Failed to open log xxxxxx/mysql-bin.000003 not found,errno 2"

时间:2023-08-20 17:34:42浏览次数:42  
标签:230820 15 log bin.000003 03 InnoDB mysql MySQL5518

问题描述:mysql在启动时报错"Failed to open log xxxxxx/mysql-bin.000003 not found,errno 2",如下所示:
数据库:mysql 5.5.18
系统:rhel 6.5 64位
架构:一主一从
场景描述:主库最新binlog文件被手动删除后,重启数据库报错.
1、异常重现
230820 14:52:19 InnoDB: 1.1.8 started; log sequence number 1604156
/usr/local/webserver/mysql/bin/mysqld: File '/var/mysql/binlog/mysql-bin.000003' not found (Errcode: 2)
230820 14:52:19 [ERROR] Failed to open log (file '/var/mysql/binlog/mysql-bin.000003', errno 2)
230820 14:52:19 [ERROR] Could not open log file
230820 14:52:19 [ERROR] Can't init tc log
230820 14:52:19 [ERROR] Aborting

230820 14:52:19  InnoDB: Starting shutdown...
230820 14:52:19  InnoDB: Shutdown completed; log sequence number 1604156
230820 14:52:19 [Note] /usr/local/webserver/mysql/bin/mysqld: Shutdown complete

230820 14:52:19 mysqld_safe mysqld from pid file /var/mysql/data/MySQL5518-Master.pid ended

2、解决过程
2.1、重建mysql-bin.000003
[mysql@MySQL5518-Master ~]$ touch /var/mysql/binlog/mysql-bin.000003
[mysql@MySQL5518-Master ~]$ logout
[root@MySQL5518-Master ~]# service mysqld start
Starting MySQL..The server quit without updating PID file ([FAILED]ql/data/MySQL5518-Master.pid).

日志文件:
230820 15:03:53 mysqld_safe Starting mysqld daemon with databases from /var/mysql/data
230820 15:03:53 InnoDB: The InnoDB memory heap is disabled
230820 15:03:53 InnoDB: Mutexes and rw_locks use GCC atomic builtins
230820 15:03:53 InnoDB: Compressed tables use zlib 1.2.3
230820 15:03:53 InnoDB: Initializing buffer pool, size = 1.0G
230820 15:03:53 InnoDB: Completed initialization of buffer pool
230820 15:03:53 InnoDB: highest supported file format is Barracuda.
230820 15:03:54  InnoDB: Waiting for the background threads to start
230820 15:03:55 InnoDB: 1.1.8 started; log sequence number 1604156
230820 15:03:55 [ERROR] I/O error reading the header from the binary log, errno=175, io cache code=0
230820 15:03:55 [ERROR] I/O error reading the header from the binary log
230820 15:03:55 [ERROR] Can't init tc log
230820 15:03:55 [ERROR] Aborting

230820 15:03:55  InnoDB: Starting shutdown...
230820 15:03:55  InnoDB: Shutdown completed; log sequence number 1604156
230820 15:03:55 [Note] /usr/local/webserver/mysql/bin/mysqld: Shutdown complete

230820 15:03:55 mysqld_safe mysqld from pid file /var/mysql/data/MySQL5518-Master.pid ended

说明:如上所示,创建同名日志文件后开启mysql进程失败,因为mysql知道文件已不是原有的日志文件.

2.2、删除index中的记录信息
[mysql@MySQL5518-Master ~]$ cd /var/mysql/binlog
[mysql@MySQL5518-Master binlog]$ ll
total 12
-rw-rw----. 1 mysql mysql 1404 Aug 20 13:37 mysql-bin.000001
-rw-rw----. 1 mysql mysql  126 Aug 20 13:40 mysql-bin.000002
-rw-rw-r--. 1 mysql mysql    0 Aug 20 15:03 mysql-bin.000003
-rw-rw----. 1 mysql mysql  105 Aug 20 13:40 mysql-bin.index
[mysql@MySQL5518-Master binlog]$ vi mysql-bin.index
说明:删除mysql-bin.000003条目.
/var/mysql/binlog/mysql-bin.000001
/var/mysql/binlog/mysql-bin.000002
/var/mysql/binlog/mysql-bin.000003

[mysql@MySQL5518-Master binlog]$ cat mysql-bin.index
/var/mysql/binlog/mysql-bin.000001
/var/mysql/binlog/mysql-bin.000002

--系统层面删除mysql-bin.000003
[mysql@MySQL5518-Master binlog]$ ll
total 12
-rw-rw----. 1 mysql mysql 1404 Aug 20 13:37 mysql-bin.000001
-rw-rw----. 1 mysql mysql  126 Aug 20 13:40 mysql-bin.000002
-rw-rw-r--. 1 mysql mysql    0 Aug 20 15:03 mysql-bin.000003
-rw-rw----. 1 mysql mysql   70 Aug 20 15:09 mysql-bin.index
[mysql@MySQL5518-Master binlog]$ rm mysql-bin.000003
[mysql@MySQL5518-Master binlog]$ logout

2.3、重启数据库
[root@MySQL5518-Master ~]# service mysqld start
Starting MySQL..                                           [  OK  ]

告警日志:
230820 15:10:25 mysqld_safe Starting mysqld daemon with databases from /var/mysql/data
230820 15:10:25 InnoDB: The InnoDB memory heap is disabled
230820 15:10:25 InnoDB: Mutexes and rw_locks use GCC atomic builtins
230820 15:10:25 InnoDB: Compressed tables use zlib 1.2.3
230820 15:10:25 InnoDB: Initializing buffer pool, size = 1.0G
230820 15:10:26 InnoDB: Completed initialization of buffer pool
230820 15:10:26 InnoDB: highest supported file format is Barracuda.
230820 15:10:26  InnoDB: Waiting for the background threads to start
230820 15:10:27 InnoDB: 1.1.8 started; log sequence number 1604156
230820 15:10:27 [Note] Event Scheduler: Loaded 0 events
230820 15:10:27 [Note] /usr/local/webserver/mysql/bin/mysqld: ready for connections.
Version: '5.5.18-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution

说明:如上所示,修改完mysql-bin.index后,mysql成功被开启.

3、数据验证
root@MySQL5518-Master [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| booksDB            |
| fruitsDB           |
| mysql              |
| performance_schema |
| test               |
+--------------------+
6 rows in set (0.00 sec)

root@MySQL5518-Master [(none)]> use booksDB;
Database changed
root@MySQL5518-Master [booksDB]> show tables;
+-------------------+
| Tables_in_booksDB |
+-------------------+
| authorbook        |
| authors           |
| books             |
+-------------------+
3 rows in set (0.00 sec)

root@MySQL5518-Master [booksDB]> select * from authorbook;
+---------+-------+
| auth_id | bk_id |
+---------+-------+
|    1001 | 11033 |
|    1002 | 11035 |
|    1003 | 11072 |
|    1004 | 11028 |
|    1011 | 11078 |
|    1012 | 11026 |
|    1012 | 11041 |
|    1014 | 11069 |
+---------+-------+
8 rows in set (0.00 sec)

说明:最新update的数据在启动数据库后依然存在.

参考网址:
https://blog.csdn.net/weixin_30200131/article/details/113328482
https://www.yzktw.com.cn/post/861139.html

标签:230820,15,log,bin.000003,03,InnoDB,mysql,MySQL5518
From: https://blog.51cto.com/u_12991611/7162527

相关文章

  • mysql 根据字段值显示不同内容,case when的使用
    在表中的数据很多类型或状态保存的内容往往是1,2,3等字符或数字来代表不同的含义.有时候使用sql查询不希望输出的是数字而是对应的字符串,这时就可以使用casewhen来进行多条件显示具体如下:SELECTid,code,CASEWHENtype='1'THEN'小'WHENtype='2'THEN'中'ELSE'大'E......
  • MySQL中查询和事务的大小
    有时候了解事务的大小非常重要,尤其是当计划迁移到HA环境,为了保证集群的最佳性能,事务的大小是有限制的。这里来尝试分析一下了解事务大小的不同方法。首先要将事务分成两种类型:1.生成数据的事务(写操作,比如insert、delete、update等DML操作)2.只读的事务(查询操作)在HA环境,第一......
  • block:global_blog
    block:global_blog 本标签文档以最新的TWCMS_v2.03版本为测试基础  {block:global_blogmid="2"pagenum="10"} <divclass=""> <divclass=""> {loop:$gdata[list]$v} <dlclass=""> <......
  • MySql Workbench 迁移工具 migration 提示缺少pyodbc 2.1.8 的解决方法
    想把公司的数据库转到MySQL,所以想装个MySQL测试,发现新版的MySQL(8.0.34)默认安装还是有不少问题,##一、譬如表、字段大小写的问题:lower_case_table_names=0--表名存储为给定的大小和比较是区分大小写的(linux默认)lower_case_table_names=1--表名存储在磁......
  • 请大家支持博客园,购买VIP会员,https://cnblogs.vip
    很多认识我的朋友都是读到我的文章而来的,博客园是国内最早的技术博客平台,近二十年来始终如一地保持本色,不忘初心,为广大的技术爱好者经营着一块相对干净的田地。我也是最早的一批博主之一吧,在那个物资还没有很丰富,相对单纯的年代,天南地北的朋友们,以文会友,追一些大牛的系列文章跟......
  • rhel 6.5搭建MySQL 5.5.18一主一从高可用架构
    文档课题:rhel6.5搭建MySQL5.5.18一主一从高可用架构.系统:rhel6.564位数据库:MySQL5.5.18数据库安装包:mysql-5.5.18.tar.gzXtrabackup安装包:percona-xtrabackup-24-2.4.6-2.el6.x86_64.rpm架构信息如下:1、主从搭建1.1、前期准备安装两台MySQL数据库主机后,配置好主机IP地......
  • Centos安装MySQL数据库
    写在前面本文使用的root账户进行操作,若不是root账户需要在操作前加上sudo大家一定要注意数据库安全问题啊......
  • MySQL中的事务基础
    事务的ACID特性MySQL中的事务指的是在数据库操作中,将一组SQL语句作为一个不可分割的执行单元进行处理的机制。事务具有原子性、一致性、隔离性和持久性的特性(ACID特性)。原子性(Atomicity):事务中的所有操作要么全部成功执行,要么全部失败回滚。如果事务执行过程中发生错误或中断,系统......
  • TiDB dumpling 导出MySQL 数据遇异常
    最近在学习研究TiDB数据库运维,据介绍逻辑导出工具dumpling是可以兼容MySQL数据库的,于是进行了测试数据库版本信息如下: 新建了两张表t1,t2: 利用存储过程批量插入500000行记录:dropPROCEDUREp_load2;delimiter$$createPROCEDUREp_load2(INtbnamevarchar(64),IN......
  • PHP查询MySQL 数据库后返回中文为问号
    面向对象1$conn=newmysqli($servername,$user,$password);3增加$conn->query("setnamesutf8");$pdo=newPDO("mysql:host=$servername",$username,$password);增加$pdo->query("setnamesutf8");  面向过程$conn=mysql......