声明:本文从爱可生博客(数据库表空间被 rm 后,怎么处理)中了解到,不属于原创。
问题现象:
- innodb表的.ibd文件被删除
- 执行DML不会报错,而DDL却会报错如下:
[ERROR] InnoDB: Cannot rename './test/t_school_auth.ibd' to './test/#sql-ib34523-911103856.ibd' for space ID 31366 because the source file does not exist.
处理:
- 不要重启mysql
- lsof | grep t_school_auth.ibd
[root@k8s-worker tmp]# lsof |grep t_school_auth mysqld 2093 mysql 97uW REG 8,3 163840 1 mysqld 2093 2134 mysql 97uW REG 8,3 163840 1 mysqld 2093 2135 mysql 97uW REG 8,3 163840 1 mysqld 2093 2136 mysql 97uW REG 8,3 163840 1 mysqld 2093 2137 mysql 97uW REG 8,3 163840 1 mysqld 2093 2138 mysql 97uW REG 8,3 163840 1 mysqld 2093 2139 mysql 97uW REG 8,3 163840 1 mysqld 2093 2140 mysql 97uW REG 8,3 163840 1 mysqld 2093 2141 mysql 97uW REG 8,3 163840
- ls -l /proc/2093/fd/97
其中2093为上面第2列,97位第5列前缀数字[root@k8s-worker tmp]# ls -l /proc/2093/fd/97 lrwx------ 1 mysql mysql 64 Aug 9 09:25 /proc/2093/fd/97 -> /var/lib/mysql/test/t_school_auth.ibd (deleted)
- cp /proc/2093/fd/97 /var/lib/mysql/test/t_school_auth.ibd
- chown mysql:mysql /var/lib/mysql/test/t_school_auth.ibd
- 重启mysql
Comments