ibdata1文件损坏时恢复InnoDB单表测试
- [root@zlm1 :: ~]
- #innobackupex --defaults-file=/data/mysql/mysql3306/my3306.cnf --user=root --password=Passw0rd /data/backup
- :: innobackupex: Starting the backup operation
- ... //Omitted.
- [root@zlm1 :: /data/backup]
- #ls -l
- total
- drwxr-x--- root root Aug : --05_13--
- [root@zlm1 :: /data/backup]
Check the target table which we want to rescue in plan.
- zlm@192.168.56.100: [sysbench]>show tables;
- +--------------------+
- | Tables_in_sysbench |
- +--------------------+
- | sbtest1 |
- | sbtest2 |
- | sbtest3 |
- | sbtest4 |
- +--------------------+
- rows in set (0.00 sec)
- zlm@192.168.56.100: [sysbench]>select count(*) from sbtest4;
- +----------+
- | count(*) |
- +----------+
- | |
- +----------+
- row in set (0.05 sec)
- zlm@192.168.56.100: [sysbench]>delete from sbtest4 limit ;
- Query OK, rows affected (0.17 sec)
- zlm@192.168.56.100: [sysbench]>select count(*) from sbtest4;
- +----------+
- | count(*) |
- +----------+
- | |
- +----------+
- row in set (0.00 sec)
Destroy the ibdata1 file with "dd" command.
- [root@zlm1 :: ~]
- #cd /data/mysql/mysql3306/data
- [root@zlm1 :: /data/mysql/mysql3306/data]
- #ls -l
- total
- -rw-r----- mysql mysql Mar : auto.cnf
- -rw-r----- mysql mysql Aug : error.log
- -rw-r----- mysql mysql Jul : ib_buffer_pool
- -rw-r----- mysql mysql Aug : ibdata1
- -rw-r----- mysql mysql Aug : ib_logfile0
- -rw-r----- mysql mysql Aug : ib_logfile1
- -rw-r----- mysql mysql Jul : ib_logfile2
- -rw-r----- mysql mysql Aug : ibtmp1
- -rw-r----- mysql mysql Aug : innodb_status.
- -rw-r----- mysql mysql Jul : innodb_status.
- -rw-r----- mysql mysql Jun : innodb_status.
- drwxr-x--- mysql mysql Jul : mrbs
- drwxr-x--- mysql mysql Mar : mysql
- -rw-r----- mysql mysql Aug : mysql.pid
- drwxr-x--- mysql mysql Mar : performance_schema
- -rw-r----- mysql mysql Jun : relay-bin.
- -rw-r----- mysql mysql Jun : relay-bin.index
- -rw-r----- mysql mysql Aug : slow.log
- drwxr-x--- mysql mysql Mar : sys
- drwxr-x--- mysql mysql Jul : sysbench
- -rw-r----- mysql mysql Jul : zlm1.log
- [root@zlm1 :: /data/mysql/mysql3306/data]
- #dd if=/dev/zero of=./ibdata1 bs= count=
- + records in
- + records out
- bytes ( MB) copied, 1.61997 s, MB/s
- [root@zlm1 :: /data/mysql/mysql3306/data]
- #ls -l|grep ibdata1
- -rw-r----- mysql mysql Aug : ibdata1 //The ibdata1 turned out to be 256M and filled with zero.
Restart the MySQL instance.
- zlm@192.168.56.100: [sysbench]>exit
- Bye
- [root@zlm1 :: ~]
- #mysqladmin shutdown
- [root@zlm1 :: ~]
- #ps aux|grep mysqld
- root 0.0 0.0 pts/ R+ : : grep --color=auto mysqld
- [root@zlm1 :: ~]
- #./mysqld.sh
- [root@zlm1 :: ~]
- #mysql
- ERROR (HY000): Can't connect to MySQL server on '192.168.56.100' (111)
- [root@zlm1 :: ~]
- #mysql
- ERROR (HY000): Can't connect to MySQL server on '192.168.56.100' (111)
- [root@zlm1 :: ~]
- #cd /data/mysql/mysql3306/data
- [root@zlm1 :: /data/mysql/mysql3306/data]
- #tail error.log
- ... /Omitted.
- --05T12::.242723Z [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
- --05T12::.242806Z [Note] mysqld (mysqld 5.7.-log) starting as process ...
- --05T12::.249168Z [Note] InnoDB: PUNCH HOLE support available
- --05T12::.249207Z [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
- --05T12::.249213Z [Note] InnoDB: Uses event mutexes
- --05T12::.249218Z [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
- --05T12::.249222Z [Note] InnoDB: Compressed tables use zlib 1.2.
- --05T12::.249227Z [Note] InnoDB: Using Linux native AIO
- --05T12::.249426Z [Note] InnoDB: Number of pools:
- --05T12::.249507Z [Note] InnoDB: Using CPU crc32 instructions
- --05T12::.251488Z [Note] InnoDB: Initializing buffer pool, total size = 100M, instances = , chunk size = 100M
- --05T12::.256630Z [Note] InnoDB: Completed initialization of buffer pool
- --05T12::.257913Z [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
- --05T12::.280321Z [Note] InnoDB: Highest supported file format is Barracuda.
- :: UTC - mysqld got signal ;
- This could be because you hit a bug. It is also possible that this binary
- or one of the libraries it was linked against is corrupt, improperly built,
- or misconfigured. This error can also be caused by malfunctioning hardware.
- Attempting to collect some information that could help diagnose the problem.
- As this is a crash and something is definitely wrong, the information
- collection process might fail.
- key_buffer_size=
- read_buffer_size=
- max_used_connections=
- max_threads=
- thread_count=
- connection_count=
- It is possible that mysqld could use up to
- key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = K bytes of memory
- Hope that's ok; if not, decrease some variables in the equation.
- Thread pointer: 0x0
- Attempting backtrace. You can use the following information to find out
- where mysqld died. If you see no messages after this, something went
- terribly wrong...
- stack_bottom = thread_stack 0x30000
- mysqld(my_print_stacktrace+0x35)[0xf4a495]
- mysqld(handle_fatal_signal+0x4a4)[0x7ce2f4]
- /lib64/libpthread.so.(+0xf130)[0x7f6bbee76130]
- mysqld(_Z26page_cur_search_with_matchPK11buf_block_tPK12dict_index_tPK8dtuple_t15page_cur_mode_tPmS9_P10page_cur_tP8rtr_info+0x148)[0x1074478]
- mysqld(_Z27btr_cur_search_to_nth_levelP12dict_index_tmPK8dtuple_t15page_cur_mode_tmP9btr_cur_tmPKcmP5mtr_t+0x1598)[0x11806d8]
- mysqld(_Z30btr_pcur_open_on_user_rec_funcP12dict_index_tPK8dtuple_t15page_cur_mode_tmP10btr_pcur_tPKcmP5mtr_t+0x212)[0x1184b62]
- mysqld[0x11df28d]
- mysqld(_Z19dict_load_sys_tableP12dict_table_t+0x69)[0x11e0609]
- mysqld(_Z9dict_bootv+0xdfb)[0x11bf48b]
- mysqld(_Z34innobase_start_or_create_for_mysqlv+0x3212)[0x11150a2]
- mysqld[0x100023a]
- mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x51)[0x819721]
- mysqld[0xd39226]
- mysqld(_Z40plugin_register_builtin_and_init_core_sePiPPc+0x3e4)[0xd397a4]
- mysqld[0x7c48f7]
- mysqld(_Z11mysqld_mainiPPc+0x92f)[0x7c7e9f]
- /lib64/libc.so.(__libc_start_main+0xf5)[0x7f6bbd857af5]
- mysqld[0x7be479]
- The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
- information that should help you find out what is causing the crash.
- [root@zlm1 :: /data/mysql/mysql3306/data]
- //Okay,becasue of the lack of normal ibdata1 file in datadir,the instance cannot be started again.
- //Then,how can we resuce the data in target table 'sbtest4'?
- //First of all,let's get the ibd and frm file of it from the crashed server.
Copy ibd and frm file of table "sbtest4" to another newly initialized instance on zlm2.
- [root@zlm1 :: /data/mysql/mysql3306/data/sysbench]
- #scp sbtest4.* zlm2:/data/backup
- sbtest4.frm % .4KB/s :
- sbtest4.ibd % 10MB .0MB/s :
Install mysql-utilities package on zlm2.
- [root@zlm2 :: ~]
- #mysqlfrm --help
- -bash: mysqlfrm: command not found
- [root@zlm2 :: ~]
- #yum install mysql-utilities
- Loaded plugins: fastestmirror
- base | 3.6 kB ::
- epel/x86_64/metalink | 7.0 kB ::
- epel | 3.2 kB ::
- extras | 3.4 kB ::
- updates | 3.4 kB ::
- (/): epel/x86_64/group_gz | kB ::
- (/): epel/x86_64/updateinfo | kB ::
- (/): extras//x86_64/primary_db | kB ::
- (/): epel/x86_64/primary | 3.6 MB ::
- (/): updates//x86_64/primary_db | 4.3 MB ::
- Loading mirror speeds from cached hostfile
- * base: mirrors.shu.edu.cn
- * epel: mirrors.tongji.edu.cn
- * extras: mirrors..com
- * updates: mirrors..com
- epel /
- Resolving Dependencies
- --> Running transaction check
- ---> Package mysql-utilities.noarch :1.3.-.el7 will be installed
- --> Processing Dependency: mysql-connector-python for package: mysql-utilities-1.3.-.el7.noarch
- --> Running transaction check
- ---> Package mysql-connector-python.noarch :1.1.-.el7 will be installed
- --> Finished Dependency Resolution
- ... //Omitted.
- Installed:
- mysql-utilities.noarch :1.3.-.el7
- Dependency Installed:
- mysql-connector-python.noarch :1.1.-.el7
- Complete!
Restore the table structure by mysqlfrm.
- [root@zlm2 :: ~]
- #cd /data/backup/
- [root@zlm2 :: /data/backup]
- #ls -l|grep sbtest4
- -rw-r----- root root Aug : sbtest4.frm
- -rw-r----- root root Aug : sbtest4.ibd
- [root@zlm2 :: /data/backup]
- #mysqlfrm --basedir=/usr/local/mysql --port= --diagnostic ./sbtest4.frm
- # WARNING The --port option is not used in the --diagnostic mode.
- # WARNING: Cannot generate character set or collation names without the --server option.
- # CAUTION: The diagnostic mode is a best-effort parse of the .frm file. As such, it may not identify all of the components of the table correctly. This is especially true for damaged files. It will also not read the default values for the columns and the resulting statement may not be syntactically correct.
- # Reading .frm file for ./sbtest4.frm:
- # The .frm file is a TABLE.
- # CREATE TABLE Statement:
- CREATE TABLE `sbtest4` (
- `id` int() NOT NULL AUTO_INCREMENT,
- `k` int() NOT NULL,
- `c` char() NOT NULL,
- `pad` char() NOT NULL,
- PRIMARY KEY `PRIMARY` (`id`),
- KEY `k_4` (`k`)
- ) ENGINE=InnoDB;
- #...done.
Create a same table structure in the new instance using the restored "create table" statement.
- [root@zlm2 :: /data/backup]
- #mysql
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is
- Server version: 5.7.-log MySQL Community Server (GPL)
- Copyright (c) , , Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- zlm@192.168.56.101: [(none)]>show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | mrbs |
- | mysql |
- | performance_schema |
- | sys |
- +--------------------+
- rows in set (0.00 sec)
- zlm@192.168.56.101: [(none)]>create database sysbench;
- Query OK, row affected (0.00 sec)
- zlm@192.168.56.101: [(none)]>use sysbench
- Database changed
- zlm@192.168.56.101: [sysbench]>show tables;
- Empty set (0.00 sec)
- zlm@192.168.56.101: [sysbench]>CREATE TABLE `sbtest4` (
- -> `id` int() NOT NULL AUTO_INCREMENT,
- -> `k` int() NOT NULL,
- -> `c` char() NOT NULL,
- -> `pad` char() NOT NULL,
- -> PRIMARY KEY `PRIMARY` (`id`),
- -> KEY `k_4` (`k`)
- -> ) ENGINE=InnoDB;
- ERROR (): Column length too big for column 'c' (max = ); use BLOB or TEXT instead
- zlm@192.168.56.101: [sysbench]>CREATE TABLE `sbtest4` (
- -> `id` int() NOT NULL AUTO_INCREMENT,
- -> `k` int() NOT NULL,
- -> `c` char() NOT NULL,
- -> `pad` char() NOT NULL,
- -> PRIMARY KEY `PRIMARY` (`id`),
- -> KEY `k_4` (`k`)
- -> ) ENGINE=InnoDB;
- ERROR (42S02): Table 'sysbench.sbtest4' doesn't exist
- zlm@192.168.56.101: [sysbench]>CREATE TABLE `sbtest4_bak` (
- -> `id` int() NOT NULL AUTO_INCREMENT,
- -> `k` int() NOT NULL,
- -> `c` char() NOT NULL,
- -> `pad` char() NOT NULL,
- -> PRIMARY KEY `PRIMARY` (`id`),
- -> KEY `k_4` (`k`)
- -> ) ENGINE=InnoDB;
- Query OK, rows affected (0.01 sec)
- zlm@192.168.56.101: [sysbench]>rename table sbtest4_bak to sbtest4;
- Query OK, rows affected (0.00 sec)
- zlm@192.168.56.101: [sysbench]>show tables;
- +--------------------+
- | Tables_in_sysbench |
- +--------------------+
- | sbtest4 |
- +--------------------+
- row in set (0.00 sec)
- zlm@192.168.56.101: [sysbench]>show create table sbtest4\G
- *************************** . row ***************************
- Table: sbtest4
- Create Table: CREATE TABLE `sbtest4` (
- `id` int() NOT NULL AUTO_INCREMENT,
- `k` int() NOT NULL,
- `c` char() NOT NULL,
- `pad` char() NOT NULL,
- PRIMARY KEY (`id`),
- KEY `k_4` (`k`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
- row in set (0.00 sec)
- zlm@192.168.56.101: [sysbench]>select count(*) from sbtest4;
- +----------+
- | count(*) |
- +----------+
- | |
- +----------+
- row in set (0.00 sec)
Discard the tablesapce of new table "sbtest4".
- zlm@192.168.56.101: [sysbench]>alter table sbtest4 discard tablespace;
- Query OK, rows affected (0.00 sec)
- [root@zlm2 :: /data/mysql/mysql3306/data/sysbench]
- #ls -l
- total
- -rw-r----- mysql mysql Aug : db.opt
- -rw-r----- mysql mysql Aug : sbtest4.frm
- //After the discard operation,the new ibd file has gone.
Copy the ibd file of table "sbtest4" to the sysbench directory in datadir(notice the owner of file).
- [root@zlm2 :: /data/backup]
- #cp sbtest4.ibd /data/mysql/mysql3306/data/sysbench/
- [root@zlm2 :: /data/backup]
- #ll /data/mysql/mysql3306/data/sysbench/ |grep sbtest4
- -rw-r----- mysql mysql Aug : sbtest4.frm
- -rw-r----- root root Aug : sbtest4.ibd
- [root@zlm2 :: /data/backup]
- #chown mysql.mysql /data/mysql/mysql3306/data/sysbench/sbtest4.ibd
- [root@zlm2 :: /data/backup]
- #ll /data/mysql/mysql3306/data/sysbench/ |grep sbtest4
- -rw-r----- mysql mysql Aug : sbtest4.frm
- -rw-r----- mysql mysql Aug : sbtest4.ibd
Import the original tablespace of table "sbtest4".
- zlm@192.168.56.101: [sysbench]>alter table sbtest4 import tablespace;
- Query OK, rows affected, warning (1.77 sec)
- zlm@192.168.56.101: [sysbench]>select count(*) from sbtest4;
- +----------+
- | count(*) |
- +----------+
- | |
- +----------+
- row in set (0.01 sec)
- //Now the table has been rescued.
- //Because of the destroying of ibdata1 in the original instance,it should be restored by Xtrabackup again.
- This method is only used to resuce a single table without backup when MySQL instance cannot startup beause of the destoryed ibdata file.
- mysqlfrm is a tool which can load table structure from .frm files.We need to install the mysql-utilities package first.
- If we don't have a properly full Xtrabackup and binlog,the .ibd file may lose the undo information on target table.In this situation,it's an incompletely recovery.
ibdata1文件损坏时恢复InnoDB单表测试的更多相关文章
- Innodb单表数据物理恢复
本文将介绍使用物理备份恢复Innodb单表数据的方法 前言: 随着innodb的普及,innobackup也成为了主流备份方式.物理备份对于新建slave,全库恢复的需求都能从容应对. 但当面临单表数 ...
- 记录SQL Server2008日志文件损坏的恢复过程
记录SQL Server2008日志文件损坏的恢复过程: 环境: 系 统:Windows Server2003 数据库:SQL Server2008 故障原因: 通过mstsc链接同一服务器时,用户界 ...
- mysql启动后随即关闭问题解决(ibdata1文件损坏导致)
机房一台服务器上的mysql运行一段时间了,突然出现了一个很奇怪的现象:重启后无法恢复了!准确情况是:启动mysql后随即就又关闭了. 查看mysql错误日志如下: 160920 22:41:41 m ...
- mongodb文件损坏的恢复--无可恢复数据
1.mongodb 启动异常error code 100,检查日志,数据文件损坏 2 检查collection-15-6548623434943640018.wt 可恢复数据,为空,不存在恢复的数据 ...
- django第8天(在测试文件中运行django项目|单表操作)
django第8天 在测试文件中运行django项目 1.将项目配置文件数据库该为mysql,修改配置信息 PORT = '127.0.0.1' DATABASES = { 'default': { ...
- 详解MySQL表空间以及ibdata1文件过大问题
ibdata1文件过大 原因分析 ibdata1是一个用来构建innodb系统表空间的文件,关于系统表空间详细介绍参考MySQL官网文档 上面是一个数据库的ibdata1文件,达到了780多G,而且还 ...
- ibdata1文件--缩小mysql数据库的ibdata1文件
摘要 在MySQL数据库中,如果不指定innodb_file_per_table参数,单独存在每个表的数据,MySQL的数据都会存放在ibdata1文件. mysql ibdata1存放数据,索引等, ...
- Oracle - 各类文件损坏处理办法(附实验步骤)
一.概述 本文将给大家介绍oracle各类文件损坏的现象和应对策略,请注意所有的恢复都是基于有备份的情况,所以请开启数据库的日常备份.文章将从以下文件展开 a. 密码文件 b. 参数文件 c. 控制文 ...
- SQL Server单表已700w+将普通表转换成分区表
最近项目中,某个表数据量爆发时增长,单表已700w+,读写性能急剧下降,所以考虑加入分区表以解燃眉之急,后续还是要分表分库,当然这是后话.下面简要说一下将普通表转为分区表的步骤. 一.创建文件组 ...
随机推荐
- POJ 1984 Navigation Nightmare 【经典带权并查集】
任意门:http://poj.org/problem?id=1984 Navigation Nightmare Time Limit: 2000MS Memory Limit: 30000K To ...
- 【luogu P1268 树的重量】 题解
题目链接:https://www.luogu.org/problemnew/show/P1268 给定所有点间的最短路求原图所有路径和 形如: 我们需要计算红边+绿边 绿边 = (红边+蓝边+紫边)/ ...
- Trident中 FixedBatchSpout分析
FixedBatchSpout 继承自 IBatchSpout IBatchSpout 方法 public interface IBatchSpout extends Serializable { v ...
- UIlable上下居中
- (void)setView{ self.chooseImg = [[UIImageView alloc] initWithFrame:CGRectMake(TO_LEFT_D, (ROW_HEIG ...
- wsgiref手写一个web服务端
''' 通过wsgiref写一个web服务端先讲讲wsgiref吧,基于网络通信其根本就是基于socket,所以wsgiref同样也是通过对socket进行封装,避免写过多的代码,将一系列的操作封装成 ...
- Vue+node.js+express+mysql实例---对图书信息进行管理
一个简单的 CURD 实例 ---对图书信息进行管理 目录 1 开发环境 1.1 前端开发环境 1.2 后端开发环境 2 数据库设计和创建 2.1 数据库和表设计 2.2 book 表设计 2.3 s ...
- Evercookie
1. Evercookie Evercookie是一个Javascript API,可以在浏览器中生成极其持久的cookie. 它的目标是在客户删除标准cookie,Flash cookie(本地共享 ...
- 数论(一)LOJ1282
1.题目来源LOJ1282 You are given two integers: n and k, your task is to find the most significant three d ...
- 动态规划(二)HDU1114
1.题目来源HDU1114 Sample Input 3 10 110 2 1 1 30 50 10 110 2 1 1 50 30 1 6 2 10 3 20 4 Sample Output The ...
- ABAP术语-Business Object
Business Object 原文:http://www.cnblogs.com/qiangsheng/archive/2008/01/07/1028364.html Represents a ce ...