mysql版本
mysql> select version();
+-------------------------------------------+
| version() |
+-------------------------------------------+
| 5.6.22-enterprise-commercial-advanced-log |
+-------------------------------------------+
1 row in set (0.00 sec)
mysql> select database();
+------------+
| database() |
+------------+
| live_koo |
+------------+
1 row in set (0.00 sec)
测试用表
mysql> select count(*) from live_users;
+----------+
| count(*) |
+----------+
| 34258 |
+----------+
1 row in set (0.00 sec)
共享表空间模式
mysql> show variables like 'innodb_file_per_table';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_file_per_table | OFF |
+-----------------------+-------+
1 row in set (0.00 sec)
存储引擎
mysql> select table_name,engine from information_schema.tables where table_schema='live_koo' and table_name='live_users';
+------------+--------+
| table_name | engine |
+------------+--------+
| live_users | InnoDB |
+------------+--------+
1 row in set (0.00 sec)
删除数据
mysql> delete from live_users;
Query OK, 34258 rows affected (0.02 sec)
mysql> select count(*) from live_users;
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.00 sec)
停止mysql服务
[root@test11g scripts]# /etc/init.d/mysqld stop
Shutting down MySQL.. [ OK ]
拷贝数据文件
[root@test11g data]# cp ibdata1 ../
解析ibd文件
[root@test11g percona-data-recovery-tool]# ./page_parser -5 -f /tol/mysql/ibdata1
Opening file: /tol/mysql/data/ibdata1:
2065 ID of device containing file
252182581 inode number
33200 protection
1 number of hard links
27 user ID of owner
27 group ID of owner
0 device ID (if special file)
79691776 total size, in bytes
4096 blocksize for filesystem I/O
155648 number of blocks allocated
1420098358 time of last access
1420098358 time of last modification
1420098358 time of last status change
79691776 Size to process in bytes
104857600 Disk cache size in bytes
21.20% done. 2015-01-01 15:48:40 ETA(in 00:00 hours). Processing speed: 16891904 B/sec
启动mysql服务
[root@test11g scripts]# /etc/init.d/mysqld start
Starting MySQL.. [ OK ]
mysql> use live_koo;
Database changed
mysql> CREATE TABLE innodb_table_monitor (id int) ENGINE=InnoDB;
Query OK, 0 rows affected, 1 warning (0.01 sec)
查看live_users表的index ID
[root@test11g mylog]# vim mysql.err
--------------------------------------
TABLE: name live_koo/live_users, id 26, flags 1, columns 9, indexes 1, appr.rows 0
COLUMNS: id: DATA_INT DATA_BINARY_TYPE DATA_NOT_NULL len 4; user_name: DATA_VARMYSQL len 270; channel: DATA_VARMYSQL len 150; s
ub_channel: DATA_VARMYSQL len 150; email: DATA_VARMYSQL len 750; mobile: DATA_VARMYSQL len 60; DB_ROW_ID: DATA_SYS prtype 256 len
6; DB_TRX_ID: DATA_SYS prtype 257 len 6; DB_ROLL_PTR: DATA_SYS prtype 258 len 7;
INDEX: name PRIMARY, id 34, fields 1/8, uniq 1, type 3
root page 4170, appr.key vals 0, leaf pages 1, size pages 1
FIELDS: id DB_TRX_ID DB_ROLL_PTR user_name channel sub_channel email mobile
--------------------------------------
生成表定义
[root@test11g percona-data-recovery-tool]# ./create_defs.pl -host 192.168.100.141 -user root -password root -db live_koo -table live_users >include/table_defs.h
从页中提取行记录
[root@test11g percona-data-recovery-tool]# ./constraints_parser -5 -f pages-1420098516/FIL_PAGE_INDEX/0-34 > /tmp/live_users3.data
LOAD DATA INFILE '/root/percona-data-recovery-tool/dumps/default/live_users' REPLACE INTO TABLE `live_users` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 'live_users\t' (id, user_name, channel, sub_channel, email, mobile);
导入数据到数据库中
mysql> LOAD DATA INFILE '/tmp/live_users3.data' REPLACE INTO TABLE `live_users` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 'live_users\t' (id, user_name, channel, sub_channel, email, mobile);
Query OK, 4026 rows affected (0.08 sec)
Records: 4026 Deleted: 0 Skipped: 0 Warnings: 0
mysql> select count(*) from live_users;
+----------+
| count(*) |
+----------+
| 2565 |
+----------+
1 row in set (0.01 sec)
mysql> exit
Bye
[root@test11g scripts]# wc -l /tmp/live_users3.data
4026 /tmp/live_users3.data
从这次恢复测试发现,共享表空间中恢复,也会丢失很多数据,情况跟独享表空间一样。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23249684/viewspace-1386926/
,如需转载,请注明出处,否则将追究法律责任。