ITPub博客

首页 > 数据库 > MySQL > 测试percona-data-recovery-tool是否能恢复被truncate的数据

测试percona-data-recovery-tool是否能恢复被truncate的数据

原创 MySQL 作者:goolen 时间:2015-01-01 19:02:36 0 删除 编辑
版本:
mysql> select version();
+-------------------------------------------+
| version()                                 |
+-------------------------------------------+
| 5.6.22-enterprise-commercial-advanced-log |
+-------------------------------------------+

mysql> use livekoo;
Database changed
mysql> select count(*) from live_room;
+----------+
| count(*) |
+----------+
|     1437 |
+----------+
1 row in set (0.00 sec)

mysql> truncate table live_room;
Query OK, 0 rows affected (0.01 sec)

mysql> select count(*) from live_room;
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.00 sec)

开始恢复:
[root@test11g percona-data-recovery-tool]#  ./page_parser -5 -f /tol/mysql/data/livekoo/live_room.ibd 
Opening file: /tol/mysql/data/livekoo/live_room.ibd:
2065            ID of device containing file
252192856               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)
114688          total size, in bytes
4096            blocksize for filesystem I/O
224             number of blocks allocated
1420109797      time of last access
1420109799      time of last modification
1420109799      time of last status change
114688  Size to process in bytes
104857600       Disk cache size in bytes
[root@test11g percona-data-recovery-tool]#  ./create_defs.pl -host 192.168.100.141 -user root -password root -db livekoo -table live_room >include/table_defs.h 
DBI connect('database=livekoo;host=192.168.100.141;port=3306','root',...) failed: Host '192.168.100.141' is not allowed to connect to this MySQL server at ./create_defs.pl line 37
[root@test11g percona-data-recovery-tool]#  ./create_defs.pl -host 192.168.100.141 -user root -password root -db livekoo -table live_room >include/table_defs.h

重新编译
[root@test11g percona-data-recovery-tool]# make
gcc -DHAVE_OFFSET64_T -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE=1 -D_LARGEFILE_SOURCE=1 -Wall -O3 -g -I include -I mysql-source/include -I mysql-source/innobase/include -c tables_dict.c -o lib/tables_dict.o
gcc -DHAVE_OFFSET64_T -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE=1 -D_LARGEFILE_SOURCE=1 -Wall -O3 -g -I include -I mysql-source/include -I mysql-source/innobase/include -c check_data.c -o lib/check_data.o
gcc -DHAVE_OFFSET64_T -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE=1 -D_LARGEFILE_SOURCE=1 -Wall -O3 -g -I include -I mysql-source/include -I mysql-source/innobase/include -o constraints_parser constraints_parser.c lib/tables_dict.o lib/print_data.o lib/check_data.o lib/libut.a lib/libmystrings.a
gcc -DHAVE_OFFSET64_T -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE=1 -D_LARGEFILE_SOURCE=1 -Wall -O3 -g -I include -I mysql-source/include -I mysql-source/innobase/include  -o page_parser page_parser.c lib/tables_dict.o lib/libut.a 
[root@test11g percona-data-recovery-tool]# ./constraints_parser -5 -D -f pages-1420109824/FIL_PAGE_INDEX/0-2 >/tmp/live_room.data 
0-26/ 0-27/ 
[root@test11g percona-data-recovery-tool]# ./constraints_parser -5 -D -f pages-1420109824/FIL_PAGE_INDEX/0-26 >/tmp/live_room.data
LOAD DATA INFILE '/root/percona-data-recovery-tool/dumps/default/live_room' REPLACE INTO TABLE `live_room` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 'live_room\t' (id, consumer_type, consumer_id, provider_type, status);
[root@test11g percona-data-recovery-tool]# ./constraints_parser -5 -D -f pages-1420109824/FIL_PAGE_INDEX/0-27 >>/tmp/live_room.data
LOAD DATA INFILE '/root/percona-data-recovery-tool/dumps/default/live_room' REPLACE INTO TABLE `live_room` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 'live_room\t' (id, consumer_type, consumer_id, provider_type, status);

查看恢复出来的文件,发现没有数据,说明这个工具无法恢复被truncate的表数据
[root@test11g percona-data-recovery-tool]# wc -l /tmp/live_room.data 
0 /tmp/live_room.data
[root@test11g percona-data-recovery-tool]# more /tmp/live_room.data 
[root@test11g percona-data-recovery-tool]# 



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23249684/viewspace-1387020/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-10-20

  • 博文量
    121
  • 访问量
    731656