kubernetes 环境中运行的mysql一直重启,启动报错如下:
[System] [MY-013576] [InnoDB] InnoDB initialization has started.
[ERROR] [MY-012592] [InnoDB] Operating system error number 5 in a file operation.
[ERROR] [MY-012596] [InnoDB] Error number 5 means 'Input/output error'
[ERROR] [MY-012646] [InnoDB] File (unknown): 'close' returned OS error 105. Cannot continue operation
ERROR] [MY-012981] [InnoDB] Cannot continue operation.
关闭mysql查看mysql数据目录:
[root@VM-6-120-centos data]# ls -lh
total 935M
-rw-r----- 1 systemd-coredump input 56 Dec 19 2022 auto.cnf
-rw-r----- 1 systemd-coredump input 626M Mar 15 15:36 binlog.000063
-rw-r----- 1 systemd-coredump input 67M May 13 03:00 binlog.000064
-rw-r----- 1 systemd-coredump input 32 Mar 15 15:36 binlog.index
-rw------- 1 systemd-coredump input 1.7K Dec 19 2022 ca-key.pem
-rw-r--r-- 1 systemd-coredump input 1.1K Dec 19 2022 ca.pem
-rw-r--r-- 1 systemd-coredump input 1.1K Dec 19 2022 client-cert.pem
-rw------- 1 systemd-coredump input 1.7K Dec 19 2022 client-key.pem
drwxr-x--- 2 systemd-coredump input 16K May 13 00:31 cnpc
-rw-r----- 1 systemd-coredump input 64K May 12 03:03 '#ib_16384_0.dblwr'
-rw-r----- 1 systemd-coredump input 64K May 12 03:03 '#ib_16384_10.dblwr'
-rw-r----- 1 systemd-coredump input 3.5K Dec 19 2022 ib_buffer_pool
-rw-r----- 1 systemd-coredump input 12M May 12 20:30 ibdata1
-rw-r----- 1 systemd-coredump input 48M May 13 16:47 ib_logfile0
-rw-r----- 1 systemd-coredump input 48M May 3 13:14 ib_logfile1
-rw-r----- 1 systemd-coredump input 12M Mar 15 15:35 ibtmp1
drwxr-x--- 2 systemd-coredump input 4.0K Mar 15 15:35 '#innodb_temp'
drwxr-x--- 2 systemd-coredump input 137 Dec 19 2022 mysql
srwxrwxrwx 1 systemd-coredump input 0 Mar 15 15:36 mysqld.sock
-rw------- 1 systemd-coredump input 2 Mar 15 15:36 mysqld.sock.lock
-rw-r----- 1 systemd-coredump input 48M May 12 03:02 mysql.ibd
-rw-r----- 1 systemd-coredump input 2 Mar 15 15:36 mysql-sts-0.pid
srwxrwxrwx 1 systemd-coredump input 0 Mar 15 15:35 mysqlx.sock
-rw------- 1 systemd-coredump input 3 Mar 15 15:35 mysqlx.sock.lock
drwxr-x--- 2 systemd-coredump input 4.0K Dec 22 2022 nacos
drwxr-x--- 2 systemd-coredump input 8.0K Dec 19 2022 performance_schema
-rw------- 1 systemd-coredump input 1.7K Dec 19 2022 private_key.pem
-rw-r--r-- 1 systemd-coredump input 452 Dec 19 2022 public_key.pem
-rw-r--r-- 1 systemd-coredump input 1.1K Dec 19 2022 server-cert.pem
-rw------- 1 systemd-coredump input 1.7K Dec 19 2022 server-key.pem
-rw-r----- 1 systemd-coredump input 639K Apr 24 12:13 slow-sql.log
drwxr-x--- 2 systemd-coredump input 27 Dec 19 2022 sys
-rw-r----- 1 systemd-coredump input 32M May 12 03:01 undo_001
-rw-r----- 1 systemd-coredump input 32M May 12 03:02 undo_002
查看数据目录发现mysql关闭后mysql socket文件和pid文件 任然存在:
备份、恢复、清理数据:
# 备份原数据
cp -rp data data-bak
# 删除原目录数据
rm -rf data/*
# 拷贝备份数据到原数据目录 这样操作是放在原来目录异常数据影响。
cp -rp data-bak/* data/
# 删除锁文件和socket文件
cd data
rm -rf mysqld.sock mysqld.sock.lock mysql-sts-0.pid mysqlx.sock mysqlx.sock.lock
# 启动mysql
# 发现mysql正常启动
网上说可能有另一种问题,磁盘损坏导致数据出问题,这种暂时没有遇到过。
评论区