关于表空间:故障分析-数据库表空间被-rm-后怎么处理
作者:肖亚洲 爱可生 DBA 团队成员,负责我的项目中数据库故障与平台问题解决,对数据库高可用与分布式技术情有独钟。 本文起源:原创投稿 *爱可生开源社区出品,原创内容未经受权不得随便应用,转载请分割小编并注明起源。 背景介绍客户生产环境因为运维人员误操作,将 MySQL 数据库中,某个业务表 ibd 文件给 rm 掉了。因为历史起因该环境没有可用从库。针对这种状况,咱们怎么解决呢? 情景复现在单实例中,将表 sbtest1 的数据文件 rm 删掉后,观测数据库的运行状态【文件复原前不要重启 mysql 】。 前提条件筹备数据库与测试表数据 创立一个 MySQL-5.7.28 的单实例数据库,并用 sysbench 筹备1张100w的测试表。[root@localhost ~]# sysbench --mysql-host=10.186.65.84 --mysql-port=8484 --mysql-user=xiao --mysql-password=xiao --mysql-db=test --db-driver=mysql --mysql_storage_engine=innodb --db-ps-mode=disable --test=/usr/local/sysbench1.0/share/sysbench/oltp_insert.lua --table_size=1000000 --threads=1 --tables=1 --db-ps-mode=disable --percentile=95 --report-interval=1 --time=1 prepareWARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.sysbench 1.0.17 (using bundled LuaJIT 2.1.0-beta2)Creating table 'sbtest1'...Inserting 1000000 records into 'sbtest1'Creating a secondary index on 'sbtest1'...[root@localhost ~]#查看数据库中数据:[root@localhost ~]# mysql -uroot -p -S /data/mysql/data/8484/mysqld.sockEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 6Server version: 5.7.28-log MySQL Community Server (GPL)Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respective owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> use test;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> select count(*) from sbtest1;+----------+| count(*) |+----------+| 1000000 |+----------+1 row in set (0.21 sec)查看sbtest1表的ibd文件:[root@localhost test]# ll -h /data/mysql/data/8484/test/total 241M-rw-r----- 1 actiontech-mysql actiontech-mysql 60 Jun 7 07:55 db.opt-rw-r----- 1 actiontech-mysql actiontech-mysql 8.5K Jun 7 07:57 sbtest1.frm-rw-r----- 1 actiontech-mysql actiontech-mysql 240M Jun 7 07:57 sbtest1.ibd发展测试通过 sysbench 对数据库发展读写测试,继续5分钟,期间对 sbtest1.ibd 文件进行 rm 操作,观测数据库运行状态: ...