恢复MySQL5.7中被Truncate掉的表

恢复MySQL被Truncate掉的表
innodb_file_per_table=ON 场景下,truncate 表后,.ibd 文件会收缩,需要扫描磁盘获取相应的数据页进行恢复。
下面以innodb_file_per_table=ON 场景下恢复为例
一.安装undrop-for-innodb软件
1:上传undrop-for-innodb-develop.zip

2:安装编译环境
yum install make gcc flex bison
3:解压

[root@localhost /]# unzip undrop-for-innodb-master.zip
Archive:  undrop-for-innodb-master.zip
ade0fbb31218f655eeff97f559d47c6545478734
   creating: undrop-for-innodb-master/
  inflating: undrop-for-innodb-master/LICENSE  
  inflating: undrop-for-innodb-master/Makefile  
  inflating: undrop-for-innodb-master/README.md  
  inflating: undrop-for-innodb-master/c_parser.c  
  inflating: undrop-for-innodb-master/check_data.c  
   creating: undrop-for-innodb-master/dictionary/
  inflating: undrop-for-innodb-master/dictionary/SYS_COLUMNS.sql  
  inflating: undrop-for-innodb-master/dictionary/SYS_FIELDS.sql  
  inflating: undrop-for-innodb-master/dictionary/SYS_INDEXES.sql  
  inflating: undrop-for-innodb-master/dictionary/SYS_TABLES.sql  
  inflating: undrop-for-innodb-master/fetch_data.sh  
   creating: undrop-for-innodb-master/include/
  inflating: undrop-for-innodb-master/include/bchange.c  
  inflating: undrop-for-innodb-master/include/bcmp.c  
  inflating: undrop-for-innodb-master/include/bfill.c  
  inflating: undrop-for-innodb-master/include/bmove.c  
  inflating: undrop-for-innodb-master/include/bmove512.c  
  inflating: undrop-for-innodb-master/include/bmove_upp.c  
  inflating: undrop-for-innodb-master/include/btr0btr.h  
  inflating: undrop-for-innodb-master/include/btr0btr.ic  
  inflating: undrop-for-innodb-master/include/btr0cur.h  
  inflating: undrop-for-innodb-master/include/btr0cur.ic  
  inflating: undrop-for-innodb-master/include/btr0types.h  
  inflating: undrop-for-innodb-master/include/buf0buf.h  
  inflating: undrop-for-innodb-master/include/buf0buf.ic  
  inflating: undrop-for-innodb-master/include/buf0flu.h  
  inflating: undrop-for-innodb-master/include/buf0flu.ic  
  inflating: undrop-for-innodb-master/include/buf0lru.h  
  inflating: undrop-for-innodb-master/include/buf0lru.ic  
  inflating: undrop-for-innodb-master/include/buf0rea.h  
  inflating: undrop-for-innodb-master/include/buf0types.h  
  inflating: undrop-for-innodb-master/include/check_data.h  
  inflating: undrop-for-innodb-master/include/ctype-bin.c  
  inflating: undrop-for-innodb-master/include/ctype-latin1.c  
  inflating: undrop-for-innodb-master/include/ctype-mb.c  
  inflating: undrop-for-innodb-master/include/ctype-simple.c  
  inflating: undrop-for-innodb-master/include/ctype-utf8.c  
  inflating: undrop-for-innodb-master/include/ctype.c  
  inflating: undrop-for-innodb-master/include/data0data.h  
  inflating: undrop-for-innodb-master/include/data0data.ic  
  inflating: undrop-for-innodb-master/include/data0type.h  
  inflating: undrop-for-innodb-master/include/data0type.ic  
  inflating: undrop-for-innodb-master/include/data0types.h  
  inflating: undrop-for-innodb-master/include/db0err.h  
  inflating: undrop-for-innodb-master/include/decimal.c  
  inflating: undrop-for-innodb-master/include/decimal.h  
  inflating: undrop-for-innodb-master/include/dict0dict.h  
  inflating: undrop-for-innodb-master/include/dict0dict.ic  
  inflating: undrop-for-innodb-master/include/dict0load.h  
  inflating: undrop-for-innodb-master/include/dict0load.ic  
  inflating: undrop-for-innodb-master/include/dict0mem.h  
  inflating: undrop-for-innodb-master/include/dict0mem.ic  
  inflating: undrop-for-innodb-master/include/dict0types.h  
  inflating: undrop-for-innodb-master/include/dyn0dyn.h  
  inflating: undrop-for-innodb-master/include/dyn0dyn.ic  
  inflating: undrop-for-innodb-master/include/fil0fil.h  
  inflating: undrop-for-innodb-master/include/fsp0fsp.h  
  inflating: undrop-for-innodb-master/include/fsp0fsp.ic  
  inflating: undrop-for-innodb-master/include/fut0fut.h  
  inflating: undrop-for-innodb-master/include/fut0fut.ic  
  inflating: undrop-for-innodb-master/include/fut0lst.h  
  inflating: undrop-for-innodb-master/include/fut0lst.ic  
  inflating: undrop-for-innodb-master/include/ha0ha.h  
  inflating: undrop-for-innodb-master/include/ha0ha.ic  
  inflating: undrop-for-innodb-master/include/hash0hash.h  
  inflating: undrop-for-innodb-master/include/hash0hash.ic  
  inflating: undrop-for-innodb-master/include/ib_config.h  
  inflating: undrop-for-innodb-master/include/ibuf0types.h  
  inflating: undrop-for-innodb-master/include/innochecksum.h  
  inflating: undrop-for-innodb-master/include/int2str.c  
  inflating: undrop-for-innodb-master/include/is_prefix.c  
  inflating: undrop-for-innodb-master/include/llstr.c  
  inflating: undrop-for-innodb-master/include/lock0types.h  
  inflating: undrop-for-innodb-master/include/longlong2str.c  
  inflating: undrop-for-innodb-master/include/m_ctype.h  
  inflating: undrop-for-innodb-master/include/m_string.h  
  inflating: undrop-for-innodb-master/include/mach0data.h  
  inflating: undrop-for-innodb-master/include/mach0data.ic  
  inflating: undrop-for-innodb-master/include/mem0dbg.h  
  inflating: undrop-for-innodb-master/include/mem0dbg.ic  
  inflating: undrop-for-innodb-master/include/mem0mem.h  
  inflating: undrop-for-innodb-master/include/mem0mem.ic  
  inflating: undrop-for-innodb-master/include/mem0pool.h  
  inflating: undrop-for-innodb-master/include/mem0pool.ic  
  inflating: undrop-for-innodb-master/include/mtr0log.h  
  inflating: undrop-for-innodb-master/include/mtr0log.ic  
  inflating: undrop-for-innodb-master/include/mtr0mtr.h  
  inflating: undrop-for-innodb-master/include/mtr0mtr.ic  
  inflating: undrop-for-innodb-master/include/mtr0types.h  
  inflating: undrop-for-innodb-master/include/my_alloc.h  
  inflating: undrop-for-innodb-master/include/my_attribute.h  
  inflating: undrop-for-innodb-master/include/my_base.h  
  inflating: undrop-for-innodb-master/include/my_config.h  
  inflating: undrop-for-innodb-master/include/my_dbug.h  
  inflating: undrop-for-innodb-master/include/my_global.h  
  inflating: undrop-for-innodb-master/include/my_list.h  
  inflating: undrop-for-innodb-master/include/my_pthread.h  
  inflating: undrop-for-innodb-master/include/my_strtoll10.c  
  inflating: undrop-for-innodb-master/include/my_sys.h  
  inflating: undrop-for-innodb-master/include/my_vsnprintf.c  
  inflating: undrop-for-innodb-master/include/my_xml.h  
  inflating: undrop-for-innodb-master/include/myisampack.h  
  inflating: undrop-for-innodb-master/include/mysql_def.h  
  inflating: undrop-for-innodb-master/include/os0file.h  
  inflating: undrop-for-innodb-master/include/os0proc.h  
  inflating: undrop-for-innodb-master/include/os0proc.ic  
  inflating: undrop-for-innodb-master/include/os0sync.h  
  inflating: undrop-for-innodb-master/include/os0sync.ic  
  inflating: undrop-for-innodb-master/include/os0thread.h  
  inflating: undrop-for-innodb-master/include/os0thread.ic  
  inflating: undrop-for-innodb-master/include/page0cur.h  
  inflating: undrop-for-innodb-master/include/page0cur.ic  
  inflating: undrop-for-innodb-master/include/page0page.h  
  inflating: undrop-for-innodb-master/include/page0page.ic  
  inflating: undrop-for-innodb-master/include/page0types.h  
  inflating: undrop-for-innodb-master/include/print_data.h  
  inflating: undrop-for-innodb-master/include/que0types.h  
  inflating: undrop-for-innodb-master/include/r_strinstr.c  
  inflating: undrop-for-innodb-master/include/raid.h  
  inflating: undrop-for-innodb-master/include/read0types.h  
  inflating: undrop-for-innodb-master/include/rem0cmp.h  
  inflating: undrop-for-innodb-master/include/rem0cmp.ic  
  inflating: undrop-for-innodb-master/include/rem0rec.h  
  inflating: undrop-for-innodb-master/include/rem0rec.ic  
  inflating: undrop-for-innodb-master/include/rem0types.h  
  inflating: undrop-for-innodb-master/include/row0types.h  
  inflating: undrop-for-innodb-master/include/srv0srv.h  
  inflating: undrop-for-innodb-master/include/str2int.c  
  inflating: undrop-for-innodb-master/include/str_alloc.c  
  inflating: undrop-for-innodb-master/include/strappend.c  
  inflating: undrop-for-innodb-master/include/strcend.c  
  inflating: undrop-for-innodb-master/include/strcont.c  
  inflating: undrop-for-innodb-master/include/strend.c  
  inflating: undrop-for-innodb-master/include/strfill.c  
  inflating: undrop-for-innodb-master/include/strinstr.c  
  inflating: undrop-for-innodb-master/include/strmake.c  
  inflating: undrop-for-innodb-master/include/strmov.c  
  inflating: undrop-for-innodb-master/include/strnlen.c  
  inflating: undrop-for-innodb-master/include/strnmov.c  
  inflating: undrop-for-innodb-master/include/strstr.c  
  inflating: undrop-for-innodb-master/include/strtod.c  
  inflating: undrop-for-innodb-master/include/strtol.c  
  inflating: undrop-for-innodb-master/include/strtoll.c  
  inflating: undrop-for-innodb-master/include/strtoul.c  
  inflating: undrop-for-innodb-master/include/strtoull.c  
  inflating: undrop-for-innodb-master/include/strxmov.c  
  inflating: undrop-for-innodb-master/include/strxnmov.c  
  inflating: undrop-for-innodb-master/include/sync0arr.h  
  inflating: undrop-for-innodb-master/include/sync0arr.ic  
  inflating: undrop-for-innodb-master/include/sync0rw.h  
  inflating: undrop-for-innodb-master/include/sync0rw.ic  
  inflating: undrop-for-innodb-master/include/sync0sync.h  
  inflating: undrop-for-innodb-master/include/sync0sync.ic  
  inflating: undrop-for-innodb-master/include/sync0types.h  
  inflating: undrop-for-innodb-master/include/tables_dict.h  
  inflating: undrop-for-innodb-master/include/trx0sys.h  
  inflating: undrop-for-innodb-master/include/trx0sys.ic  
  inflating: undrop-for-innodb-master/include/trx0trx.h  
  inflating: undrop-for-innodb-master/include/trx0trx.ic  
  inflating: undrop-for-innodb-master/include/trx0types.h  
  inflating: undrop-for-innodb-master/include/trx0undo.h  
  inflating: undrop-for-innodb-master/include/trx0undo.ic  
  inflating: undrop-for-innodb-master/include/trx0xa.h  
  inflating: undrop-for-innodb-master/include/typelib.h  
  inflating: undrop-for-innodb-master/include/univ.i  
  inflating: undrop-for-innodb-master/include/usr0types.h  
  inflating: undrop-for-innodb-master/include/ut0byte.h  
  inflating: undrop-for-innodb-master/include/ut0byte.ic  
  inflating: undrop-for-innodb-master/include/ut0dbg.h  
  inflating: undrop-for-innodb-master/include/ut0lst.h  
  inflating: undrop-for-innodb-master/include/ut0mem.h  
  inflating: undrop-for-innodb-master/include/ut0mem.ic  
  inflating: undrop-for-innodb-master/include/ut0rnd.h  
  inflating: undrop-for-innodb-master/include/ut0rnd.ic  
  inflating: undrop-for-innodb-master/include/ut0ut.h  
  inflating: undrop-for-innodb-master/include/ut0ut.ic  
  inflating: undrop-for-innodb-master/include/xml.c  
  inflating: undrop-for-innodb-master/innochecksum.c  
  inflating: undrop-for-innodb-master/print_data.c  
  inflating: undrop-for-innodb-master/recover_dictionary.sh  
   creating: undrop-for-innodb-master/sakila/
  inflating: undrop-for-innodb-master/sakila/actor.sql  
  inflating: undrop-for-innodb-master/sakila/address.sql  
  inflating: undrop-for-innodb-master/sakila/category.sql  
  inflating: undrop-for-innodb-master/sakila/city.sql  
  inflating: undrop-for-innodb-master/sakila/country.sql  
  inflating: undrop-for-innodb-master/sakila/customer.sql  
  inflating: undrop-for-innodb-master/sakila/film.sql  
  inflating: undrop-for-innodb-master/sakila/film_actor.sql  
  inflating: undrop-for-innodb-master/sakila/film_category.sql  
  inflating: undrop-for-innodb-master/sakila/inventory.sql  
  inflating: undrop-for-innodb-master/sakila/language.sql  
  inflating: undrop-for-innodb-master/sakila/payment.sql  
  inflating: undrop-for-innodb-master/sakila/rental.sql  
  inflating: undrop-for-innodb-master/sakila/sakila-db.tar.gz  
  inflating: undrop-for-innodb-master/sakila/staff.sql  
  inflating: undrop-for-innodb-master/sakila/store.sql  
  inflating: undrop-for-innodb-master/sql_parser.l  
  inflating: undrop-for-innodb-master/sql_parser.y  
  inflating: undrop-for-innodb-master/stream_parser.c  
  inflating: undrop-for-innodb-master/sys_parser.c  
  inflating: undrop-for-innodb-master/tables_dict.c  
  inflating: undrop-for-innodb-master/test.sh  

4:编译

[root@localhost /]# cd undrop-for-innodb-master
[root@localhost undrop-for-innodb-master]# ll
total 208
-rw-r--r--. 1 root root  6271 Oct  2  2015 check_data.c
-rw-r--r--. 1 root root 28689 Oct  2  2015 c_parser.c
drwxr-xr-x. 2 root root    92 Oct  2  2015 dictionary
-rw-r--r--. 1 root root  1978 Oct  2  2015 fetch_data.sh
drwxr-xr-x. 2 root root  4096 Oct  2  2015 include
-rw-r--r--. 1 root root  8936 Oct  2  2015 innochecksum.c
-rw-r--r--. 1 root root 18047 Oct  2  2015 LICENSE
-rw-r--r--. 1 root root  1816 Oct  2  2015 Makefile
-rw-r--r--. 1 root root 16585 Oct  2  2015 print_data.c
-rw-r--r--. 1 root root  3467 Oct  2  2015 README.md
-rwxr-xr-x. 1 root root  1536 Oct  2  2015 recover_dictionary.sh
drwxr-xr-x. 2 root root  4096 Oct  2  2015 sakila
-rw-r--r--. 1 root root  7244 Oct  2  2015 sql_parser.l
-rw-r--r--. 1 root root 25607 Oct  2  2015 sql_parser.y
-rw-r--r--. 1 root root 23004 Oct  2  2015 stream_parser.c
-rw-r--r--. 1 root root 14764 Oct  2  2015 sys_parser.c
-rw-r--r--. 1 root root  2237 Oct  2  2015 tables_dict.c
-rwxr-xr-x. 1 root root  6178 Oct  2  2015 test.sh
[root@localhost undrop-for-innodb-master]# make
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c stream_parser.c
stream_parser.c: In function ‘valid_innodb_page’:
stream_parser.c:151:31: warning: variable ‘oldcsumfield’ set but not used [-Wunused-but-set-variable]
     unsigned int page_n_heap, oldcsumfield;
                               ^
stream_parser.c: In function ‘process_ibpage’:
stream_parser.c:313:9: warning: variable ‘sem’ set but not used [-Wunused-but-set-variable]
     int sem = (page_type == FIL_PAGE_INDEX) 
         ^
stream_parser.c: In function ‘process_ibfile’:
stream_parser.c:333:13: warning: variable ‘prev_disk_offset’ set but not used [-Wunused-but-set-variable]
     off64_t prev_disk_offset = 0;
             ^
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include  -pthread -lm  stream_parser.o -o stream_parser
flex  sql_parser.l
bison  -o sql_parser.c sql_parser.y
sql_parser.y: warning: 6 shift/reduce conflicts [-Wconflicts-sr]
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c sql_parser.c 
sql_parser.y: In function ‘yyparse’:
sql_parser.y:166:39: warning: variable ‘none’ set but not used [-Wunused-but-set-variable]
         field_def_t trx_id, roll_ptr, none;
                                       ^
In file included from sql_parser.y:660:0:
sql_parser.y: At top level:
lex.yy.c:3085:17: warning: ‘yyunput’ defined but not used [-Wunused-function]
     static void yyunput (int c, register char * yy_bp )
                 ^
lex.yy.c:3126:16: warning: ‘input’ defined but not used [-Wunused-function]
     static int input  (void)
                ^
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c c_parser.c
In file included from c_parser.c:39:0:
decimal.c: In function ‘decimal_intg’:
decimal.c:1923:9: warning: variable ‘tmp_res’ set but not used [-Wunused-but-set-variable]
In file included from c_parser.c:35:0:
c_parser.c: At top level:
./include/ctype-latin1.c:359:5: warning: ‘my_mb_wc_latin1’ defined but not used [-Wunused-function]
 int my_mb_wc_latin1(CHARSET_INFO *cs  __attribute__((unused)),
     ^
./include/ctype-latin1.c:372:5: warning: ‘my_wc_mb_latin1’ defined but not used [-Wunused-function]
 int my_wc_mb_latin1(CHARSET_INFO *cs  __attribute__((unused)),
     ^
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c tables_dict.c
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c print_data.c
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe  -I./include -c check_data.c
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe   -I./include  sql_parser.o c_parser.o tables_dict.o print_data.o check_data.o -o c_parser -pthread -lm
cc -D_FILE_OFFSET_BITS=64 -Wall -g -O3 -pipe   -I./include -o innochecksum_changer innochecksum.c
[root@localhost undrop-for-innodb-master]# ll
total 2904
-rw-r--r--. 1 root root    6271 Oct  2  2015 check_data.c
-rw-r--r--. 1 root root   66088 Jan 17 16:59 check_data.o
-rwxr-xr-x. 1 root root  725572 Jan 17 16:59 c_parser
-rw-r--r--. 1 root root   28689 Oct  2  2015 c_parser.c
-rw-r--r--. 1 root root 1038536 Jan 17 16:59 c_parser.o
drwxr-xr-x. 2 root root      92 Oct  2  2015 dictionary
-rw-r--r--. 1 root root    1978 Oct  2  2015 fetch_data.sh
drwxr-xr-x. 2 root root    4096 Oct  2  2015 include
-rw-r--r--. 1 root root    8936 Oct  2  2015 innochecksum.c
-rwxr-xr-x. 1 root root   36399 Jan 17 16:59 innochecksum_changer
-rw-r--r--. 1 root root  134778 Jan 17 16:59 lex.yy.c
-rw-r--r--. 1 root root   18047 Oct  2  2015 LICENSE
-rw-r--r--. 1 root root    1816 Oct  2  2015 Makefile
-rw-r--r--. 1 root root   16585 Oct  2  2015 print_data.c
-rw-r--r--. 1 root root  127136 Jan 17 16:59 print_data.o
-rw-r--r--. 1 root root    3467 Oct  2  2015 README.md
-rwxr-xr-x. 1 root root    1536 Oct  2  2015 recover_dictionary.sh
drwxr-xr-x. 2 root root    4096 Oct  2  2015 sakila
-rw-r--r--. 1 root root  102053 Jan 17 16:59 sql_parser.c
-rw-r--r--. 1 root root    7244 Oct  2  2015 sql_parser.l
-rw-r--r--. 1 root root  287296 Jan 17 16:59 sql_parser.o
-rw-r--r--. 1 root root   25607 Oct  2  2015 sql_parser.y
-rwxr-xr-x. 1 root root   63657 Jan 17 16:59 stream_parser
-rw-r--r--. 1 root root   23004 Oct  2  2015 stream_parser.c
-rw-r--r--. 1 root root  114944 Jan 17 16:59 stream_parser.o
-rw-r--r--. 1 root root   14764 Oct  2  2015 sys_parser.c
-rw-r--r--. 1 root root    2237 Oct  2  2015 tables_dict.c
-rw-r--r--. 1 root root   40176 Jan 17 16:59 tables_dict.o
-rwxr-xr-x. 1 root root    6178 Oct  2  2015 test.sh
[root@localhost undrop-for-innodb-master]#  make sys_parser
/mysqlsoft/mysql/bin/mysql_config
cc -o sys_parser sys_parser.c `mysql_config --cflags` `mysql_config --libs`

5:验证
编译完成后在undrop-for-innodb 目录下生成stream_parser 和c_parser, sys_parser 文件。

[root@localhost undrop-for-innodb-master]# ll
total 2928
-rw-r--r--. 1 root root    6271 Oct  2  2015 check_data.c
-rw-r--r--. 1 root root   66088 Jan 17 16:59 check_data.o
-rwxr-xr-x. 1 root root  725572 Jan 17 16:59 c_parser
-rw-r--r--. 1 root root   28689 Oct  2  2015 c_parser.c
-rw-r--r--. 1 root root 1038536 Jan 17 16:59 c_parser.o
drwxr-xr-x. 2 root root      92 Oct  2  2015 dictionary
-rw-r--r--. 1 root root    1978 Oct  2  2015 fetch_data.sh
drwxr-xr-x. 2 root root    4096 Oct  2  2015 include
-rw-r--r--. 1 root root    8936 Oct  2  2015 innochecksum.c
-rwxr-xr-x. 1 root root   36399 Jan 17 16:59 innochecksum_changer
-rw-r--r--. 1 root root  134778 Jan 17 16:59 lex.yy.c
-rw-r--r--. 1 root root   18047 Oct  2  2015 LICENSE
-rw-r--r--. 1 root root    1816 Oct  2  2015 Makefile
-rw-r--r--. 1 root root   16585 Oct  2  2015 print_data.c
-rw-r--r--. 1 root root  127136 Jan 17 16:59 print_data.o
-rw-r--r--. 1 root root    3467 Oct  2  2015 README.md
-rwxr-xr-x. 1 root root    1536 Oct  2  2015 recover_dictionary.sh
drwxr-xr-x. 2 root root    4096 Oct  2  2015 sakila
-rw-r--r--. 1 root root  102053 Jan 17 16:59 sql_parser.c
-rw-r--r--. 1 root root    7244 Oct  2  2015 sql_parser.l
-rw-r--r--. 1 root root  287296 Jan 17 16:59 sql_parser.o
-rw-r--r--. 1 root root   25607 Oct  2  2015 sql_parser.y
-rwxr-xr-x. 1 root root   63657 Jan 17 16:59 stream_parser
-rw-r--r--. 1 root root   23004 Oct  2  2015 stream_parser.c
-rw-r--r--. 1 root root  114944 Jan 17 16:59 stream_parser.o
-rwxr-xr-x. 1 root root   20650 Jan 17 17:05 sys_parser
-rw-r--r--. 1 root root   14764 Oct  2  2015 sys_parser.c
-rw-r--r--. 1 root root    2237 Oct  2  2015 tables_dict.c
-rw-r--r--. 1 root root   40176 Jan 17 16:59 tables_dict.o
-rwxr-xr-x. 1 root root    6178 Oct  2  2015 test.sh

二.执行truncate table恢复操作
1:执行truncate table命令删除表中所有记录

mysql> select * from t2;
+------+
| i    |
+------+
|    3 |
|    7 |
|   11 |
|   15 |
|    2 |
|    6 |
|   10 |
|   14 |
+------+
8 rows in set (0.00 sec)

mysql> truncate table t2;
Query OK, 0 rows affected (0.27 sec)

mysql> select * from t2;
Empty set (0.00 sec)

2:确认硬盘分区

[root@localhost undrop-for-innodb-master]# more /mysqlsoft/mysql/my.cnf | grep datadir
datadir=/mysqldata/mysql

[root@localhost undrop-for-innodb-master]# df -h /mysqldata/mysql
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/ol-root   72G   64G  8.0G  89% /

3:扫描硬盘分区
由于truncate 操作会把磁盘上对应的ibd 文件也一起删除,因此需要扫描磁盘,找到对应的数据页

[root@localhost undrop-for-innodb-master]# ./stream_parser -f /dev/mapper/ol-root -t 72G
Opening file: /dev/mapper/ol-root
File information:

Opening file: /dev/mapper/ol-root
File information:

Opening file: /dev/mapper/ol-root
File information:

ID of device containing file:            5
ID of device containing file:            5
ID of device containing file:            5
inode number:                        10610
inode number:                        10610
inode number:                        10610
protection:                          60660 protection:                          60660 protection:                          60660 (block device)
(block device)
(block device)
number of hard links:                    1
number of hard links:                    1
number of hard links:                    1
user ID of owner:                        0
user ID of owner:                        0
user ID of owner:                        0
group ID of owner:                       6
group ID of owner:                       6
group ID of owner:                       6
device ID (if special file):         64768
device ID (if special file):         64768
device ID (if special file):         64768
blocksize for filesystem I/O:         4096
blocksize for filesystem I/O:         4096
blocksize for filesystem I/O:         4096
number of blocks allocated:              0
number of blocks allocated:              0
number of blocks allocated:              0
time of last access:            1705593249 Thu Jan 18 23:54:09 2024
time of last access:            1705593249 Thu Jan 18 23:54:09 2024
time of last access:            1705593249 Thu Jan 18 23:54:09 2024
time of last modification:      1661337281 Wed Aug 24 18:34:41 2022
time of last modification:      1661337281 Wed Aug 24 18:34:41 2022
time of last modification:      1661337281 Wed Aug 24 18:34:41 2022
time of last status change:     1661337281 Wed Aug 24 18:34:41 2022
time of last status change:     1661337281 Wed Aug 24 18:34:41 2022
time of last status change:     1661337281 Wed Aug 24 18:34:41 2022
total size, in bytes:                    0 (0.000 exp(+0))

total size, in bytes:                    0 (0.000 exp(+0))

total size, in bytes:                    0 (0.000 exp(+0))

Size to process:               77309411328 (72.000 GiB)
Size to process:               77309411328 (72.000 GiB)
Size to process:               77309411328 (72.000 GiB)
Opening file: /dev/mapper/ol-root
File information:

ID of device containing file:            5
inode number:                        10610
protection:                          60660 (block device)
number of hard links:                    1
user ID of owner:                        0
group ID of owner:                       6
device ID (if special file):         64768
blocksize for filesystem I/O:         4096
number of blocks allocated:              0
time of last access:            1705593249 Thu Jan 18 23:54:09 2024
time of last modification:      1661337281 Wed Aug 24 18:34:41 2022
time of last status change:     1661337281 Wed Aug 24 18:34:41 2022
total size, in bytes:                    0 (0.000 exp(+0))

Size to process:               77309411328 (72.000 GiB)
Worker(1): 1.08% done. 2024-01-22 22:26:54 ETA(in 00:07:55). Processing speed: 38.325 MiB/sec
Worker(0): 1.08% done. 2024-01-22 22:26:55 ETA(in 00:07:55). Processing speed: 38.325 MiB/sec
Worker(2): 1.08% done. 2024-01-22 22:26:55 ETA(in 00:07:55). Processing speed: 38.328 MiB/sec
Worker(3): 1.08% done. 2024-01-22 22:26:55 ETA(in 00:07:55). Processing speed: 38.325 MiB/sec
Worker(1): 2.12% done. 2024-01-22 22:26:54 ETA(in 00:07:50). Processing speed: 38.325 MiB/sec
Worker(2): 2.12% done. 2024-01-22 22:26:55 ETA(in 00:07:50). Processing speed: 38.325 MiB/sec
Worker(3): 2.12% done. 2024-01-22 22:26:55 ETA(in 00:07:50). Processing speed: 38.325 MiB/sec
Worker(0): 2.12% done. 2024-01-22 22:26:55 ETA(in 00:07:50). Processing speed: 38.325 MiB/sec
Worker(1): 3.16% done. 2024-01-22 22:25:20 ETA(in 00:06:12). Processing speed: 47.907 MiB/sec
Worker(2): 3.16% done. 2024-01-22 22:25:21 ETA(in 00:06:12). Processing speed: 47.907 MiB/sec
Worker(3): 3.16% done. 2024-01-22 22:26:55 ETA(in 00:07:45). Processing speed: 38.325 MiB/sec
Worker(0): 3.16% done. 2024-01-22 22:26:55 ETA(in 00:07:45). Processing speed: 38.326 MiB/sec
Worker(1): 4.20% done. 2024-01-22 22:26:53 ETA(in 00:07:40). Processing speed: 38.328 MiB/sec
Worker(2): 4.20% done. 2024-01-22 22:25:21 ETA(in 00:06:08). Processing speed: 47.906 MiB/sec
Worker(3): 4.20% done. 2024-01-22 22:25:22 ETA(in 00:06:08). Processing speed: 47.906 MiB/sec
Worker(0): 4.20% done. 2024-01-22 22:26:55 ETA(in 00:07:40). Processing speed: 38.325 MiB/sec
Worker(1): 5.24% done. 2024-01-22 22:25:21 ETA(in 00:06:04). Processing speed: 47.907 MiB/sec
Worker(2): 5.24% done. 2024-01-22 22:26:53 ETA(in 00:07:35). Processing speed: 38.326 MiB/sec
Worker(3): 5.24% done. 2024-01-22 22:26:54 ETA(in 00:07:35). Processing speed: 38.325 MiB/sec
Worker(0): 5.24% done. 2024-01-22 22:26:55 ETA(in 00:07:35). Processing speed: 38.325 MiB/sec
Worker(1): 6.28% done. 2024-01-22 22:26:52 ETA(in 00:07:30). Processing speed: 38.325 MiB/sec
Worker(2): 6.28% done. 2024-01-22 22:25:22 ETA(in 00:06:00). Processing speed: 47.907 MiB/sec
Worker(3): 6.28% done. 2024-01-22 22:25:23 ETA(in 00:06:00). Processing speed: 47.906 MiB/sec
Worker(0): 6.28% done. 2024-01-22 22:26:55 ETA(in 00:07:30). Processing speed: 38.325 MiB/sec
Worker(1): 7.32% done. 2024-01-22 22:25:22 ETA(in 00:05:56). Processing speed: 47.911 MiB/sec
Worker(2): 7.32% done. 2024-01-22 22:26:52 ETA(in 00:07:25). Processing speed: 38.325 MiB/sec
Worker(3): 7.32% done. 2024-01-22 22:28:23 ETA(in 00:08:54). Processing speed: 31.938 MiB/sec
Worker(2): 8.36% done. 2024-01-22 22:23:54 ETA(in 00:04:24). Processing speed: 63.921 MiB/sec
Worker(0): 7.32% done. 2024-01-22 22:28:25 ETA(in 00:08:54). Processing speed: 31.943 MiB/sec
Worker(1): 8.36% done. 2024-01-22 22:26:51 ETA(in 00:07:20). Processing speed: 38.327 MiB/sec
Worker(3): 8.36% done. 2024-01-22 22:25:25 ETA(in 00:05:52). Processing speed: 47.906 MiB/sec
Worker(2): 9.40% done. 2024-01-22 22:26:50 ETA(in 00:07:15). Processing speed: 38.338 MiB/sec
Worker(0): 8.36% done. 2024-01-22 22:28:25 ETA(in 00:08:48). Processing speed: 31.945 MiB/sec
Worker(1): 9.40% done. 2024-01-22 22:28:19 ETA(in 00:08:42). Processing speed: 31.940 MiB/sec
Worker(3): 9.40% done. 2024-01-22 22:28:21 ETA(in 00:08:42). Processing speed: 31.938 MiB/sec
Worker(2): 10.44% done. 2024-01-22 22:28:17 ETA(in 00:08:36). Processing speed: 31.940 MiB/sec
Worker(0): 9.40% done. 2024-01-22 22:25:29 ETA(in 00:05:48). Processing speed: 47.945 MiB/sec
Worker(1): 10.44% done. 2024-01-22 22:26:52 ETA(in 00:07:10). Processing speed: 38.325 MiB/sec
Worker(3): 10.44% done. 2024-01-22 22:25:27 ETA(in 00:05:44). Processing speed: 47.910 MiB/sec
Worker(0): 10.44% done. 2024-01-22 22:25:29 ETA(in 00:05:44). Processing speed: 47.962 MiB/sec
Worker(2): 11.48% done. 2024-01-22 22:25:25 ETA(in 00:05:40). Processing speed: 47.910 MiB/sec
Worker(1): 11.48% done. 2024-01-22 22:25:26 ETA(in 00:05:40). Processing speed: 47.914 MiB/sec
Worker(3): 11.48% done. 2024-01-22 22:26:53 ETA(in 00:07:05). Processing speed: 38.333 MiB/sec
Worker(2): 12.52% done. 2024-01-22 22:25:25 ETA(in 00:05:36). Processing speed: 47.978 MiB/sec
Worker(0): 11.48% done. 2024-01-22 22:25:29 ETA(in 00:05:40). Processing speed: 47.907 MiB/sec
Worker(1): 12.52% done. 2024-01-22 22:26:51 ETA(in 00:07:00). Processing speed: 38.325 MiB/sec
Worker(3): 12.52% done. 2024-01-22 22:26:53 ETA(in 00:07:00). Processing speed: 38.331 MiB/sec
Worker(2): 13.56% done. 2024-01-22 22:31:01 ETA(in 00:11:04). Processing speed: 23.965 MiB/sec
Worker(0): 12.52% done. 2024-01-22 22:32:35 ETA(in 00:12:37). Processing speed: 21.295 MiB/sec
Worker(1): 13.56% done. 2024-01-22 22:31:04 ETA(in 00:11:05). Processing speed: 23.953 MiB/sec
Worker(3): 13.56% done. 2024-01-22 22:29:42 ETA(in 00:09:42). Processing speed: 27.375 MiB/sec
Worker(2): 14.60% done. 2024-01-22 22:25:29 ETA(in 00:05:28). Processing speed: 47.938 MiB/sec
Worker(0): 13.56% done. 2024-01-22 22:26:58 ETA(in 00:06:55). Processing speed: 38.328 MiB/sec
Worker(1): 14.60% done. 2024-01-22 22:25:31 ETA(in 00:05:28). Processing speed: 47.906 MiB/sec
Worker(3): 14.60% done. 2024-01-22 22:26:55 ETA(in 00:06:50). Processing speed: 38.325 MiB/sec
Worker(2): 15.64% done. 2024-01-22 22:25:29 ETA(in 00:05:24). Processing speed: 47.906 MiB/sec
Worker(1): 15.64% done. 2024-01-22 22:25:31 ETA(in 00:05:24). Processing speed: 47.906 MiB/sec
Worker(0): 14.60% done. 2024-01-22 22:28:21 ETA(in 00:08:12). Processing speed: 31.938 MiB/sec
Worker(2): 16.68% done. 2024-01-22 22:26:50 ETA(in 00:06:40). Processing speed: 38.325 MiB/sec
Worker(3): 15.64% done. 2024-01-22 22:26:55 ETA(in 00:06:45). Processing speed: 38.328 MiB/sec
Worker(1): 16.68% done. 2024-01-22 22:25:31 ETA(in 00:05:20). Processing speed: 47.912 MiB/sec
Worker(2): 17.72% done. 2024-01-22 22:24:10 ETA(in 00:03:57). Processing speed: 63.880 MiB/sec
Worker(1): 17.72% done. 2024-01-22 22:24:11 ETA(in 00:03:57). Processing speed: 63.909 MiB/sec
Worker(0): 15.64% done. 2024-01-22 22:26:59 ETA(in 00:06:45). Processing speed: 38.331 MiB/sec
Worker(3): 16.68% done. 2024-01-22 22:26:55 ETA(in 00:06:40). Processing speed: 38.335 MiB/sec
Worker(2): 18.76% done. 2024-01-22 22:25:29 ETA(in 00:05:12). Processing speed: 47.906 MiB/sec
Worker(1): 18.76% done. 2024-01-22 22:26:49 ETA(in 00:06:30). Processing speed: 38.325 MiB/sec
Worker(3): 17.72% done. 2024-01-22 22:25:35 ETA(in 00:05:16). Processing speed: 47.910 MiB/sec
Worker(0): 16.68% done. 2024-01-22 22:28:20 ETA(in 00:08:00). Processing speed: 31.940 MiB/sec
Worker(2): 19.80% done. 2024-01-22 22:25:29 ETA(in 00:05:08). Processing speed: 47.906 MiB/sec
Worker(1): 19.80% done. 2024-01-22 22:25:31 ETA(in 00:05:08). Processing speed: 47.906 MiB/sec
Worker(3): 18.76% done. 2024-01-22 22:26:54 ETA(in 00:06:30). Processing speed: 38.325 MiB/sec
Worker(2): 20.84% done. 2024-01-22 22:25:29 ETA(in 00:05:04). Processing speed: 47.953 MiB/sec
Worker(0): 17.72% done. 2024-01-22 22:27:00 ETA(in 00:06:35). Processing speed: 38.325 MiB/sec
Worker(1): 20.84% done. 2024-01-22 22:25:31 ETA(in 00:05:04). Processing speed: 47.906 MiB/sec
Worker(3): 19.80% done. 2024-01-22 22:25:36 ETA(in 00:05:08). Processing speed: 47.906 MiB/sec
Worker(2): 21.88% done. 2024-01-22 22:25:29 ETA(in 00:05:00). Processing speed: 47.906 MiB/sec
Worker(0): 18.76% done. 2024-01-22 22:28:19 ETA(in 00:07:48). Processing speed: 31.938 MiB/sec
Worker(1): 21.88% done. 2024-01-22 22:26:47 ETA(in 00:06:15). Processing speed: 38.325 MiB/sec
Worker(3): 20.84% done. 2024-01-22 22:26:53 ETA(in 00:06:20). Processing speed: 38.325 MiB/sec
Worker(2): 22.92% done. 2024-01-22 22:25:29 ETA(in 00:04:56). Processing speed: 47.906 MiB/sec
Worker(0): 19.80% done. 2024-01-22 22:27:01 ETA(in 00:06:25). Processing speed: 38.331 MiB/sec
Worker(1): 22.92% done. 2024-01-22 22:25:32 ETA(in 00:04:56). Processing speed: 47.906 MiB/sec
Worker(2): 23.96% done. 2024-01-22 22:25:29 ETA(in 00:04:52). Processing speed: 47.939 MiB/sec
Worker(3): 21.88% done. 2024-01-22 22:25:37 ETA(in 00:05:00). Processing speed: 47.911 MiB/sec
Worker(2): 25.00% done. 2024-01-22 22:24:16 ETA(in 00:03:36). Processing speed: 63.948 MiB/sec
Worker(1): 23.96% done. 2024-01-22 22:25:32 ETA(in 00:04:52). Processing speed: 47.914 MiB/sec
Worker(3): 22.92% done. 2024-01-22 22:25:37 ETA(in 00:04:56). Processing speed: 47.906 MiB/sec
Worker(0): 20.84% done. 2024-01-22 22:28:18 ETA(in 00:07:36). Processing speed: 31.938 MiB/sec
Worker(1): 25.00% done. 2024-01-22 22:24:19 ETA(in 00:03:36). Processing speed: 63.927 MiB/sec
Worker(2): 26.04% done. 2024-01-22 22:24:16 ETA(in 00:03:33). Processing speed: 63.875 MiB/sec
Worker(3): 23.96% done. 2024-01-22 22:26:51 ETA(in 00:06:05). Processing speed: 38.325 MiB/sec
Worker(1): 26.04% done. 2024-01-22 22:25:31 ETA(in 00:04:44). Processing speed: 47.906 MiB/sec
Worker(0): 21.88% done. 2024-01-22 22:27:02 ETA(in 00:06:15). Processing speed: 38.325 MiB/sec
Worker(2): 27.08% done. 2024-01-22 22:26:38 ETA(in 00:05:50). Processing speed: 38.331 MiB/sec
Worker(3): 25.00% done. 2024-01-22 22:25:38 ETA(in 00:04:48). Processing speed: 47.910 MiB/sec
Worker(1): 27.08% done. 2024-01-22 22:25:31 ETA(in 00:04:40). Processing speed: 47.906 MiB/sec
Worker(2): 28.12% done. 2024-01-22 22:25:28 ETA(in 00:04:36). Processing speed: 47.915 MiB/sec
Worker(0): 22.92% done. 2024-01-22 22:27:02 ETA(in 00:06:10). Processing speed: 38.328 MiB/sec
Worker(3): 26.04% done. 2024-01-22 22:26:50 ETA(in 00:05:55). Processing speed: 38.325 MiB/sec
Worker(1): 28.12% done. 2024-01-22 22:25:31 ETA(in 00:04:36). Processing speed: 47.906 MiB/sec
Worker(2): 29.16% done. 2024-01-22 22:25:28 ETA(in 00:04:32). Processing speed: 47.906 MiB/sec
Worker(0): 23.96% done. 2024-01-22 22:27:02 ETA(in 00:06:05). Processing speed: 38.325 MiB/sec
Worker(3): 27.07% done. 2024-01-22 22:25:39 ETA(in 00:04:40). Processing speed: 47.907 MiB/sec
Worker(1): 29.16% done. 2024-01-22 22:26:40 ETA(in 00:05:40). Processing speed: 38.325 MiB/sec
Worker(2): 30.20% done. 2024-01-22 22:25:28 ETA(in 00:04:28). Processing speed: 47.907 MiB/sec
Worker(0): 25.00% done. 2024-01-22 22:25:49 ETA(in 00:04:48). Processing speed: 47.912 MiB/sec
Worker(3): 28.11% done. 2024-01-22 22:26:49 ETA(in 00:05:45). Processing speed: 38.325 MiB/sec
Worker(1): 30.20% done. 2024-01-22 22:26:40 ETA(in 00:05:35). Processing speed: 38.326 MiB/sec
Worker(2): 31.24% done. 2024-01-22 22:26:35 ETA(in 00:05:30). Processing speed: 38.325 MiB/sec
Worker(0): 26.04% done. 2024-01-22 22:27:01 ETA(in 00:05:55). Processing speed: 38.334 MiB/sec
Worker(3): 29.16% done. 2024-01-22 22:24:31 ETA(in 00:03:24). Processing speed: 63.953 MiB/sec
Worker(0): 27.08% done. 2024-01-22 22:24:39 ETA(in 00:03:30). Processing speed: 63.940 MiB/sec
Worker(2): 32.28% done. 2024-01-22 22:26:35 ETA(in 00:05:25). Processing speed: 38.325 MiB/sec
Worker(1): 31.23% done. 2024-01-22 22:26:40 ETA(in 00:05:30). Processing speed: 38.325 MiB/sec
Worker(3): 30.20% done. 2024-01-22 22:25:39 ETA(in 00:04:28). Processing speed: 47.922 MiB/sec
Worker(2): 33.32% done. 2024-01-22 22:24:25 ETA(in 00:03:12). Processing speed: 63.881 MiB/sec
Worker(0): 28.12% done. 2024-01-22 22:26:59 ETA(in 00:05:45). Processing speed: 38.325 MiB/sec
Worker(1): 32.27% done. 2024-01-22 22:26:40 ETA(in 00:05:25). Processing speed: 38.325 MiB/sec
Worker(3): 31.24% done. 2024-01-22 22:26:46 ETA(in 00:05:30). Processing speed: 38.325 MiB/sec
Worker(2): 34.36% done. 2024-01-22 22:25:29 ETA(in 00:04:12). Processing speed: 47.949 MiB/sec
Worker(0): 29.16% done. 2024-01-22 22:26:59 ETA(in 00:05:40). Processing speed: 38.331 MiB/sec
Worker(1): 33.31% done. 2024-01-22 22:25:35 ETA(in 00:04:16). Processing speed: 47.906 MiB/sec
Worker(3): 32.27% done. 2024-01-22 22:24:34 ETA(in 00:03:15). Processing speed: 63.875 MiB/sec
Worker(2): 35.40% done. 2024-01-22 22:24:26 ETA(in 00:03:06). Processing speed: 63.896 MiB/sec
Worker(0): 30.20% done. 2024-01-22 22:25:51 ETA(in 00:04:28). Processing speed: 47.906 MiB/sec
Worker(1): 34.35% done. 2024-01-22 22:26:39 ETA(in 00:05:15). Processing speed: 38.325 MiB/sec
Worker(3): 33.31% done. 2024-01-22 22:26:44 ETA(in 00:05:20). Processing speed: 38.325 MiB/sec
Worker(2): 36.44% done. 2024-01-22 22:26:30 ETA(in 00:05:05). Processing speed: 38.325 MiB/sec
Worker(1): 35.39% done. 2024-01-22 22:25:36 ETA(in 00:04:08). Processing speed: 47.910 MiB/sec
Worker(0): 31.24% done. 2024-01-22 22:26:58 ETA(in 00:05:30). Processing speed: 38.325 MiB/sec
Worker(3): 34.35% done. 2024-01-22 22:25:40 ETA(in 00:04:12). Processing speed: 47.906 MiB/sec
Worker(2): 37.48% done. 2024-01-22 22:25:29 ETA(in 00:04:00). Processing speed: 47.906 MiB/sec
Worker(3): 35.40% done. 2024-01-22 22:24:37 ETA(in 00:03:06). Processing speed: 64.000 MiB/sec
Worker(1): 36.43% done. 2024-01-22 22:24:34 ETA(in 00:03:03). Processing speed: 63.875 MiB/sec
Worker(0): 32.28% done. 2024-01-22 22:24:46 ETA(in 00:03:15). Processing speed: 63.875 MiB/sec
Worker(3): 36.44% done. 2024-01-22 22:22:33 ETA(in 00:01:01). Processing speed: 192.000 MiB/sec
Worker(2): 38.52% done. 2024-01-22 22:24:29 ETA(in 00:02:57). Processing speed: 63.875 MiB/sec
Worker(3): 37.48% done. 2024-01-22 22:22:33 ETA(in 00:01:00). Processing speed: 192.000 MiB/sec
Worker(1): 37.47% done. 2024-01-22 22:23:33 ETA(in 00:02:00). Processing speed: 95.891 MiB/sec
Worker(3): 38.52% done. 2024-01-22 22:22:33 ETA(in 00:00:59). Processing speed: 192.000 MiB/sec
Worker(0): 33.32% done. 2024-01-22 22:24:46 ETA(in 00:03:12). Processing speed: 63.875 MiB/sec
Worker(3): 39.56% done. 2024-01-22 22:22:33 ETA(in 00:00:58). Processing speed: 192.000 MiB/sec
Worker(1): 38.51% done. 2024-01-22 22:23:33 ETA(in 00:01:58). Processing speed: 95.969 MiB/sec
Worker(2): 39.56% done. 2024-01-22 22:25:28 ETA(in 00:03:52). Processing speed: 47.906 MiB/sec
Worker(3): 40.60% done. 2024-01-22 22:22:33 ETA(in 00:00:57). Processing speed: 192.000 MiB/sec
Worker(0): 34.36% done. 2024-01-22 22:24:46 ETA(in 00:03:09). Processing speed: 63.875 MiB/sec
Worker(1): 39.56% done. 2024-01-22 22:23:33 ETA(in 00:01:56). Processing speed: 95.898 MiB/sec
Worker(3): 41.65% done. 2024-01-22 22:22:33 ETA(in 00:00:56). Processing speed: 192.000 MiB/sec
Worker(1): 40.60% done. 2024-01-22 22:22:35 ETA(in 00:00:57). Processing speed: 192.000 MiB/sec
Worker(3): 42.69% done. 2024-01-22 22:22:33 ETA(in 00:00:55). Processing speed: 192.000 MiB/sec
Worker(2): 40.60% done. 2024-01-22 22:23:32 ETA(in 00:01:54). Processing speed: 95.813 MiB/sec
Worker(1): 41.73% done. 2024-01-22 22:22:30 ETA(in 00:00:51). Processing speed: 208.000 MiB/sec
Worker(3): 43.73% done. 2024-01-22 22:22:33 ETA(in 00:00:54). Processing speed: 192.000 MiB/sec
Worker(0): 35.40% done. 2024-01-22 22:24:46 ETA(in 00:03:06). Processing speed: 63.885 MiB/sec
Worker(1): 42.77% done. 2024-01-22 22:23:30 ETA(in 00:01:49). Processing speed: 96.000 MiB/sec
Worker(2): 41.64% done. 2024-01-22 22:24:29 ETA(in 00:02:48). Processing speed: 63.875 MiB/sec
Worker(3): 44.77% done. 2024-01-22 22:23:27 ETA(in 00:01:46). Processing speed: 96.000 MiB/sec
Worker(0): 36.44% done. 2024-01-22 22:23:44 ETA(in 00:02:02). Processing speed: 95.898 MiB/sec
Worker(1): 43.81% done. 2024-01-22 22:22:35 ETA(in 00:00:53). Processing speed: 192.000 MiB/sec
Worker(3): 45.81% done. 2024-01-22 22:22:34 ETA(in 00:00:52). Processing speed: 192.000 MiB/sec
Worker(1): 44.89% done. 2024-01-22 22:22:33 ETA(in 00:00:50). Processing speed: 200.000 MiB/sec
Worker(3): 46.85% done. 2024-01-22 22:22:34 ETA(in 00:00:51). Processing speed: 192.000 MiB/sec
Worker(0): 37.48% done. 2024-01-22 22:22:43 ETA(in 00:01:00). Processing speed: 191.977 MiB/sec
Worker(2): 42.68% done. 2024-01-22 22:23:33 ETA(in 00:01:50). Processing speed: 95.813 MiB/sec
Worker(1): 46.93% done. 2024-01-22 22:22:10 ETA(in 00:00:26). Processing speed: 376.000 MiB/sec
Worker(3): 48.33% done. 2024-01-22 22:22:19 ETA(in 00:00:35). Processing speed: 272.000 MiB/sec
Worker(0): 38.52% done. 2024-01-22 22:25:43 ETA(in 00:03:56). Processing speed: 47.996 MiB/sec
Worker(1): 47.98% done. 2024-01-22 22:25:07 ETA(in 00:03:19). Processing speed: 48.000 MiB/sec
Worker(3): 49.37% done. 2024-01-22 22:25:02 ETA(in 00:03:14). Processing speed: 48.000 MiB/sec
Worker(0): 39.56% done. 2024-01-22 22:25:43 ETA(in 00:03:52). Processing speed: 47.996 MiB/sec
Worker(1): 49.02% done. 2024-01-22 22:25:07 ETA(in 00:03:15). Processing speed: 48.000 MiB/sec
Worker(2): 43.72% done. 2024-01-22 22:31:49 ETA(in 00:09:55). Processing speed: 17.420 MiB/sec
Worker(3): 50.41% done. 2024-01-22 22:28:16 ETA(in 00:06:20). Processing speed: 24.000 MiB/sec
Worker(1): 50.06% done. 2024-01-22 22:25:07 ETA(in 00:03:11). Processing speed: 48.000 MiB/sec
Worker(0): 40.60% done. 2024-01-22 22:26:41 ETA(in 00:04:45). Processing speed: 38.400 MiB/sec
Worker(3): 51.45% done. 2024-01-22 22:22:43 ETA(in 00:00:46). Processing speed: 192.000 MiB/sec
Worker(0): 41.64% done. 2024-01-22 22:22:53 ETA(in 00:00:56). Processing speed: 192.000 MiB/sec
Worker(1): 51.10% done. 2024-01-22 22:22:43 ETA(in 00:00:46). Processing speed: 192.000 MiB/sec
Worker(2): 44.76% done. 2024-01-22 22:24:36 ETA(in 00:02:39). Processing speed: 63.875 MiB/sec
Worker(3): 52.50% done. 2024-01-22 22:22:43 ETA(in 00:00:45). Processing speed: 192.000 MiB/sec
Worker(0): 42.69% done. 2024-01-22 22:22:53 ETA(in 00:00:55). Processing speed: 192.000 MiB/sec
Worker(1): 52.14% done. 2024-01-22 22:22:43 ETA(in 00:00:45). Processing speed: 192.000 MiB/sec
Worker(0): 44.12% done. 2024-01-22 22:22:38 ETA(in 00:00:39). Processing speed: 264.000 MiB/sec
Worker(3): 54.41% done. 2024-01-22 22:22:22 ETA(in 00:00:23). Processing speed: 352.000 MiB/sec
Worker(1): 53.18% done. 2024-01-22 22:22:43 ETA(in 00:00:44). Processing speed: 192.000 MiB/sec
Worker(2): 45.80% done. 2024-01-22 22:23:43 ETA(in 00:01:44). Processing speed: 95.813 MiB/sec
Worker(3): 56.23% done. 2024-01-22 22:22:24 ETA(in 00:00:24). Processing speed: 336.000 MiB/sec
Worker(0): 46.16% done. 2024-01-22 22:22:26 ETA(in 00:00:26). Processing speed: 376.000 MiB/sec
Worker(1): 54.79% done. 2024-01-22 22:22:28 ETA(in 00:00:28). Processing speed: 296.000 MiB/sec
Worker(3): 58.01% done. 2024-01-22 22:22:24 ETA(in 00:00:23). Processing speed: 328.000 MiB/sec
Worker(0): 48.02% done. 2024-01-22 22:22:28 ETA(in 00:00:27). Processing speed: 344.000 MiB/sec
Worker(1): 56.57% done. 2024-01-22 22:22:25 ETA(in 00:00:24). Processing speed: 328.000 MiB/sec
Worker(2): 46.84% done. 2024-01-22 22:23:43 ETA(in 00:01:42). Processing speed: 95.813 MiB/sec
Worker(1): 58.35% done. 2024-01-22 22:22:25 ETA(in 00:00:23). Processing speed: 328.000 MiB/sec
Worker(3): 59.87% done. 2024-01-22 22:22:23 ETA(in 00:00:21). Processing speed: 344.000 MiB/sec
Worker(0): 49.72% done. 2024-01-22 22:22:31 ETA(in 00:00:29). Processing speed: 312.000 MiB/sec
Worker(2): 47.88% done. 2024-01-22 22:22:52 ETA(in 00:00:50). Processing speed: 191.625 MiB/sec
Worker(0): 51.15% done. 2024-01-22 22:22:37 ETA(in 00:00:34). Processing speed: 264.000 MiB/sec
Worker(1): 60.39% done. 2024-01-22 22:22:22 ETA(in 00:00:19). Processing speed: 376.000 MiB/sec
Worker(3): 61.74% done. 2024-01-22 22:22:23 ETA(in 00:00:20). Processing speed: 344.000 MiB/sec
Worker(0): 53.02% done. 2024-01-22 22:22:29 ETA(in 00:00:25). Processing speed: 344.000 MiB/sec
Worker(1): 62.47% done. 2024-01-22 22:22:22 ETA(in 00:00:18). Processing speed: 384.000 MiB/sec
Worker(3): 63.22% done. 2024-01-22 22:22:28 ETA(in 00:00:24). Processing speed: 272.000 MiB/sec
Worker(2): 48.92% done. 2024-01-22 22:23:42 ETA(in 00:01:38). Processing speed: 95.813 MiB/sec
Worker(1): 63.90% done. 2024-01-22 22:22:30 ETA(in 00:00:25). Processing speed: 264.000 MiB/sec
Worker(0): 55.01% done. 2024-01-22 22:22:27 ETA(in 00:00:22). Processing speed: 368.000 MiB/sec
Worker(3): 65.08% done. 2024-01-22 22:22:23 ETA(in 00:00:18). Processing speed: 344.000 MiB/sec
Worker(2): 49.96% done. 2024-01-22 22:22:53 ETA(in 00:00:48). Processing speed: 191.937 MiB/sec
Worker(3): 66.73% done. 2024-01-22 22:22:26 ETA(in 00:00:20). Processing speed: 304.000 MiB/sec
Worker(0): 56.71% done. 2024-01-22 22:22:31 ETA(in 00:00:25). Processing speed: 312.000 MiB/sec
Worker(2): 51.17% done. 2024-01-22 22:22:46 ETA(in 00:00:40). Processing speed: 224.000 MiB/sec
Worker(1): 65.08% done. 2024-01-22 22:22:35 ETA(in 00:00:29). Processing speed: 216.000 MiB/sec
Worker(3): 68.47% done. 2024-01-22 22:22:25 ETA(in 00:00:18). Processing speed: 320.000 MiB/sec
Worker(2): 52.73% done. 2024-01-22 22:22:37 ETA(in 00:00:30). Processing speed: 288.000 MiB/sec
Worker(1): 66.77% done. 2024-01-22 22:22:26 ETA(in 00:00:19). Processing speed: 312.000 MiB/sec
Worker(0): 58.05% done. 2024-01-22 22:22:38 ETA(in 00:00:31). Processing speed: 248.000 MiB/sec
Worker(2): 54.60% done. 2024-01-22 22:22:32 ETA(in 00:00:24). Processing speed: 344.000 MiB/sec
Worker(1): 68.46% done. 2024-01-22 22:22:26 ETA(in 00:00:18). Processing speed: 312.000 MiB/sec
Worker(0): 59.35% done. 2024-01-22 22:22:39 ETA(in 00:00:31). Processing speed: 240.000 MiB/sec
Worker(3): 69.90% done. 2024-01-22 22:22:29 ETA(in 00:00:21). Processing speed: 264.000 MiB/sec
Worker(1): 70.28% done. 2024-01-22 22:22:25 ETA(in 00:00:16). Processing speed: 336.000 MiB/sec
Worker(3): 71.46% done. 2024-01-22 22:22:27 ETA(in 00:00:18). Processing speed: 288.000 MiB/sec
Worker(0): 60.92% done. 2024-01-22 22:22:34 ETA(in 00:00:25). Processing speed: 288.000 MiB/sec
Worker(2): 55.95% done. 2024-01-22 22:22:41 ETA(in 00:00:32). Processing speed: 248.000 MiB/sec
Worker(3): 72.94% done. 2024-01-22 22:22:28 ETA(in 00:00:18). Processing speed: 272.000 MiB/sec
Worker(0): 62.30% done. 2024-01-22 22:22:37 ETA(in 00:00:27). Processing speed: 256.000 MiB/sec
Worker(2): 57.64% done. 2024-01-22 22:22:35 ETA(in 00:00:25). Processing speed: 312.000 MiB/sec
Worker(1): 71.98% done. 2024-01-22 22:22:26 ETA(in 00:00:16). Processing speed: 312.000 MiB/sec
Worker(2): 59.59% done. 2024-01-22 22:22:31 ETA(in 00:00:20). Processing speed: 360.000 MiB/sec
Worker(1): 73.15% done. 2024-01-22 22:22:33 ETA(in 00:00:22). Processing speed: 216.000 MiB/sec
Worker(0): 63.69% done. 2024-01-22 22:22:37 ETA(in 00:00:26). Processing speed: 256.000 MiB/sec
Worker(3): 74.76% done. 2024-01-22 22:22:24 ETA(in 00:00:13). Processing speed: 336.000 MiB/sec
Worker(0): 65.21% done. 2024-01-22 22:22:34 ETA(in 00:00:22). Processing speed: 280.000 MiB/sec
Worker(1): 74.80% done. 2024-01-22 22:22:27 ETA(in 00:00:15). Processing speed: 304.000 MiB/sec
Worker(3): 76.19% done. 2024-01-22 22:22:28 ETA(in 00:00:16). Processing speed: 264.000 MiB/sec
Worker(2): 61.28% done. 2024-01-22 22:22:34 ETA(in 00:00:22). Processing speed: 312.000 MiB/sec
Worker(1): 76.62% done. 2024-01-22 22:22:25 ETA(in 00:00:12). Processing speed: 336.000 MiB/sec
Worker(0): 66.69% done. 2024-01-22 22:22:35 ETA(in 00:00:22). Processing speed: 272.000 MiB/sec
Worker(3): 77.71% done. 2024-01-22 22:22:27 ETA(in 00:00:14). Processing speed: 280.000 MiB/sec
Worker(2): 62.80% done. 2024-01-22 22:22:37 ETA(in 00:00:24). Processing speed: 280.000 MiB/sec
Worker(0): 68.21% done. 2024-01-22 22:22:34 ETA(in 00:00:20). Processing speed: 280.000 MiB/sec
Worker(3): 79.10% done. 2024-01-22 22:22:29 ETA(in 00:00:15). Processing speed: 256.000 MiB/sec
Worker(1): 78.40% done. 2024-01-22 22:22:26 ETA(in 00:00:12). Processing speed: 328.000 MiB/sec
Worker(2): 64.45% done. 2024-01-22 22:22:35 ETA(in 00:00:21). Processing speed: 304.000 MiB/sec
Worker(1): 79.92% done. 2024-01-22 22:22:28 ETA(in 00:00:13). Processing speed: 280.000 MiB/sec
Worker(0): 70.16% done. 2024-01-22 22:22:30 ETA(in 00:00:15). Processing speed: 360.000 MiB/sec
Worker(2): 65.84% done. 2024-01-22 22:22:39 ETA(in 00:00:24). Processing speed: 256.000 MiB/sec
Worker(3): 80.53% done. 2024-01-22 22:22:28 ETA(in 00:00:13). Processing speed: 264.000 MiB/sec
Worker(2): 67.10% done. 2024-01-22 22:22:42 ETA(in 00:00:26). Processing speed: 232.000 MiB/sec
Worker(1): 81.48% done. 2024-01-22 22:22:27 ETA(in 00:00:11). Processing speed: 288.000 MiB/sec
Worker(3): 82.23% done. 2024-01-22 22:22:26 ETA(in 00:00:10). Processing speed: 312.000 MiB/sec
Worker(0): 71.98% done. 2024-01-22 22:22:31 ETA(in 00:00:15). Processing speed: 336.000 MiB/sec
Worker(3): 84.01% done. 2024-01-22 22:22:25 ETA(in 00:00:08). Processing speed: 328.000 MiB/sec
Worker(0): 73.68% done. 2024-01-22 22:22:32 ETA(in 00:00:15). Processing speed: 312.000 MiB/sec
Worker(2): 68.62% done. 2024-01-22 22:22:37 ETA(in 00:00:20). Processing speed: 280.000 MiB/sec
Worker(1): 82.83% done. 2024-01-22 22:22:29 ETA(in 00:00:12). Processing speed: 248.000 MiB/sec
Worker(3): 85.53% done. 2024-01-22 22:22:27 ETA(in 00:00:09). Processing speed: 280.000 MiB/sec
Worker(2): 70.53% done. 2024-01-22 22:22:33 ETA(in 00:00:15). Processing speed: 352.000 MiB/sec
Worker(1): 84.13% done. 2024-01-22 22:22:30 ETA(in 00:00:12). Processing speed: 240.000 MiB/sec
Worker(0): 75.24% done. 2024-01-22 22:22:33 ETA(in 00:00:15). Processing speed: 288.000 MiB/sec
Worker(1): 85.43% done. 2024-01-22 22:22:30 ETA(in 00:00:11). Processing speed: 240.000 MiB/sec
Worker(0): 76.76% done. 2024-01-22 22:22:34 ETA(in 00:00:15). Processing speed: 280.000 MiB/sec
Worker(2): 72.31% done. 2024-01-22 22:22:34 ETA(in 00:00:15). Processing speed: 328.000 MiB/sec
Worker(3): 87.18% done. 2024-01-22 22:22:26 ETA(in 00:00:07). Processing speed: 304.000 MiB/sec
Worker(2): 73.83% done. 2024-01-22 22:22:37 ETA(in 00:00:17). Processing speed: 280.000 MiB/sec
Worker(3): 88.43% done. 2024-01-22 22:22:29 ETA(in 00:00:09). Processing speed: 232.000 MiB/sec
Worker(1): 87.25% done. 2024-01-22 22:22:26 ETA(in 00:00:06). Processing speed: 336.000 MiB/sec
Worker(0): 78.49% done. 2024-01-22 22:22:32 ETA(in 00:00:12). Processing speed: 320.000 MiB/sec
Worker(0): 80.10% done. 2024-01-22 22:22:33 ETA(in 00:00:12). Processing speed: 296.000 MiB/sec
Worker(1): 88.77% done. 2024-01-22 22:22:28 ETA(in 00:00:07). Processing speed: 280.000 MiB/sec
Worker(2): 75.09% done. 2024-01-22 22:22:40 ETA(in 00:00:19). Processing speed: 232.000 MiB/sec
Worker(3): 90.34% done. 2024-01-22 22:22:26 ETA(in 00:00:05). Processing speed: 352.000 MiB/sec
Worker(1): 90.60% done. 2024-01-22 22:22:27 ETA(in 00:00:05). Processing speed: 336.000 MiB/sec
Worker(3): 91.95% done. 2024-01-22 22:22:27 ETA(in 00:00:05). Processing speed: 296.000 MiB/sec
Worker(2): 76.52% done. 2024-01-22 22:22:38 ETA(in 00:00:16). Processing speed: 264.000 MiB/sec
Worker(0): 81.53% done. 2024-01-22 22:22:34 ETA(in 00:00:12). Processing speed: 264.000 MiB/sec
Worker(2): 78.17% done. 2024-01-22 22:22:36 ETA(in 00:00:13). Processing speed: 304.000 MiB/sec
Worker(3): 93.69% done. 2024-01-22 22:22:26 ETA(in 00:00:03). Processing speed: 320.000 MiB/sec
Worker(1): 92.29% done. 2024-01-22 22:22:27 ETA(in 00:00:04). Processing speed: 312.000 MiB/sec
Worker(0): 82.70% done. 2024-01-22 22:22:37 ETA(in 00:00:14). Processing speed: 216.000 MiB/sec
Worker(0): 84.27% done. 2024-01-22 22:22:34 ETA(in 00:00:10). Processing speed: 288.000 MiB/sec
Worker(1): 94.11% done. 2024-01-22 22:22:27 ETA(in 00:00:03). Processing speed: 336.000 MiB/sec
Worker(2): 79.56% done. 2024-01-22 22:22:38 ETA(in 00:00:14). Processing speed: 256.000 MiB/sec
Worker(3): 95.20% done. 2024-01-22 22:22:27 ETA(in 00:00:03). Processing speed: 280.000 MiB/sec
Worker(3): 96.68% done. 2024-01-22 22:22:27 ETA(in 00:00:02). Processing speed: 272.000 MiB/sec
Worker(2): 81.08% done. 2024-01-22 22:22:37 ETA(in 00:00:12). Processing speed: 280.000 MiB/sec
Worker(1): 95.68% done. 2024-01-22 22:22:27 ETA(in 00:00:02). Processing speed: 288.000 MiB/sec
Worker(0): 86.00% done. 2024-01-22 22:22:33 ETA(in 00:00:08). Processing speed: 320.000 MiB/sec
Worker(1): 97.32% done. 2024-01-22 22:22:27 ETA(in 00:00:01). Processing speed: 304.000 MiB/sec
Worker(2): 82.77% done. 2024-01-22 22:22:36 ETA(in 00:00:10). Processing speed: 312.000 MiB/sec
Worker(0): 88.00% done. 2024-01-22 22:22:32 ETA(in 00:00:06). Processing speed: 368.000 MiB/sec
Worker(0): 90.13% done. 2024-01-22 22:22:31 ETA(in 00:00:04). Processing speed: 392.000 MiB/sec
Worker(2): 84.90% done. 2024-01-22 22:22:34 ETA(in 00:00:07). Processing speed: 392.000 MiB/sec
Worker(1): 98.89% done. 2024-01-22 22:22:27 ETA(in 00:00:00). Processing speed: 287.969 MiB/sec
Worker(2): 87.24% done. 2024-01-22 22:22:33 ETA(in 00:00:05). Processing speed: 432.000 MiB/sec
Worker(0): 92.51% done. 2024-01-22 22:22:31 ETA(in 00:00:03). Processing speed: 440.000 MiB/sec
Worker(1): 99.93% done. 2024-01-22 22:22:28 ETA(in 00:00:00). Processing speed: 191.627 MiB/sec
Worker(2): 89.63% done. 2024-01-22 22:22:33 ETA(in 00:00:04). Processing speed: 440.000 MiB/sec
Worker(0): 94.90% done. 2024-01-22 22:22:31 ETA(in 00:00:02). Processing speed: 440.000 MiB/sec
Worker(0): 97.20% done. 2024-01-22 22:22:31 ETA(in 00:00:01). Processing speed: 424.000 MiB/sec
Worker(2): 91.97% done. 2024-01-22 22:22:33 ETA(in 00:00:03). Processing speed: 432.000 MiB/sec
Worker(0): 99.41% done. 2024-01-22 22:22:31 ETA(in 00:00:00). Processing speed: 408.000 MiB/sec
Worker(2): 94.36% done. 2024-01-22 22:22:33 ETA(in 00:00:02). Processing speed: 440.000 MiB/sec
Worker(2): 97.00% done. 2024-01-22 22:22:33 ETA(in 00:00:01). Processing speed: 488.000 MiB/sec
Worker(2): 98.65% done. 2024-01-22 22:22:33 ETA(in 00:00:00). Processing speed: 303.845 MiB/sec
Worker(2): 99.69% done. 2024-01-22 22:22:35 ETA(in 00:00:00). Processing speed: 95.820 MiB/sec
All workers finished in 221 sec

4:查找表数据对应的page 页
确认对应的索引页主键索引是61

mysql> select * from information_schema.INNODB_SYS_TABLES d where d.name='test/t2';
Empty set (0.14 sec)

mysql> select * from information_schema.INNODB_SYS_TABLES d where d.name like 'test/t2%';
+----------+--------------+------+--------+-------+-------------+------------+---------------+------------+
| TABLE_ID | NAME         | FLAG | N_COLS | SPACE | FILE_FORMAT | ROW_FORMAT | ZIP_PAGE_SIZE | SPACE_TYPE |
+----------+--------------+------+--------+-------+-------------+------------+---------------+------------+
|       53 | test/t2#P#p0 |   33 |      4 |    26 | Barracuda   | Dynamic    |             0 | Single     |
|       54 | test/t2#P#p1 |   33 |      4 |    27 | Barracuda   | Dynamic    |             0 | Single     |
|       55 | test/t2#P#p2 |   33 |      4 |    28 | Barracuda   | Dynamic    |             0 | Single     |
|       56 | test/t2#P#p3 |   33 |      4 |    29 | Barracuda   | Dynamic    |             0 | Single     |
+----------+--------------+------+--------+-------+-------------+------------+---------------+------------+
4 rows in set (0.00 sec)

mysql> show create table t2\G
*************************** 1. row ***************************
       Table: t2
Create Table: CREATE TABLE `t2` (
  `i` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
/*!50100 PARTITION BY KEY (i)
PARTITIONS 4 */
1 row in set (0.00 sec)

表test/t2是一个分区表,所以相当于4个表查找index_id语句要根据table_id来执行四次。

mysql> select * from information_schema.innodb_sys_indexes where table_id=53;
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
| INDEX_ID | NAME            | TABLE_ID | TYPE | N_FIELDS | PAGE_NO | SPACE | MERGE_THRESHOLD |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
|       44 | GEN_CLUST_INDEX |       53 |    1 |        0 |       3 |    26 |              50 |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
1 row in set (0.00 sec)

mysql> select * from information_schema.innodb_sys_indexes where table_id=54;
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
| INDEX_ID | NAME            | TABLE_ID | TYPE | N_FIELDS | PAGE_NO | SPACE | MERGE_THRESHOLD |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
|       45 | GEN_CLUST_INDEX |       54 |    1 |        0 |       3 |    27 |              50 |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
1 row in set (0.00 sec)

mysql> select * from information_schema.innodb_sys_indexes where table_id=55;
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
| INDEX_ID | NAME            | TABLE_ID | TYPE | N_FIELDS | PAGE_NO | SPACE | MERGE_THRESHOLD |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
|       46 | GEN_CLUST_INDEX |       55 |    1 |        0 |       3 |    28 |              50 |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
1 row in set (0.00 sec)

mysql> select * from information_schema.innodb_sys_indexes where table_id=56;
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
| INDEX_ID | NAME            | TABLE_ID | TYPE | N_FIELDS | PAGE_NO | SPACE | MERGE_THRESHOLD |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
|       47 | GEN_CLUST_INDEX |       56 |    1 |        0 |       3 |    29 |              50 |
+----------+-----------------+----------+------+----------+---------+-------+-----------------+
1 row in set (0.00 sec)

5:解析磁盘页中删除表的记录

[root@localhost lib]# vi /tmp/t2.sql
CREATE TABLE `t2` (
  `i` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
/*!50100 PARTITION BY KEY (i)
PARTITIONS 4 */;

因为表test/t2有四个分区所以需要解析四次

[root@localhost undrop-for-innodb-master]# ./c_parser -6f /undrop-for-innodb-master/pages-ol-root/FIL_PAGE_INDEX/0000000000000044.page -t /tmp/t2.sql > dumps/default/t2_1 2> dumps/default/t2_1_load.sql
[root@localhost undrop-for-innodb-master]# ./c_parser -6f /undrop-for-innodb-master/pages-ol-root/FIL_PAGE_INDEX/0000000000000045.page -t /tmp/t2.sql > dumps/default/t2_2 2> dumps/default/t2_2_load.sql
[root@localhost undrop-for-innodb-master]# ./c_parser -6f /undrop-for-innodb-master/pages-ol-root/FIL_PAGE_INDEX/0000000000000046.page -t /tmp/t2.sql > dumps/default/t2_3 2> dumps/default/t2_3_load.sql
[root@localhost undrop-for-innodb-master]# ./c_parser -6f /undrop-for-innodb-master/pages-ol-root/FIL_PAGE_INDEX/0000000000000047.page -t /tmp/t2.sql > dumps/default/t2_4 2> dumps/default/t2_4_load.sql

6:导入数据
因为表test/t2是分区表,生成使用load命令加载数据时生成的数据文件是t2与表名相同,并不会我所指定的文件名。所以要做修改

[root@localhost default]# cat t2_1_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);
[root@localhost default]# cat t2_2_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);

[root@localhost default]# cat t2_3_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);

[root@localhost default]# cat t2_4_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);

[root@localhost default]# vi t2_1_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2_1' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);

[root@localhost default]# vi t2_2_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2_2' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);

[root@localhost default]# vi t2_3_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2_3' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);

[root@localhost default]# vi t2_4_load.sql
SET FOREIGN_KEY_CHECKS=0;
LOAD DATA LOCAL INFILE '/undrop-for-innodb-master/dumps/default/t2_4' REPLACE INTO TABLE `t2` FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES STARTING BY 't2\t' (`i`);


mysql> source /undrop-for-innodb-master/dumps/default/t2_1_load.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)
Records: 0  Deleted: 0  Skipped: 0  Warnings: 0

mysql> source /undrop-for-innodb-master/dumps/default/t2_2_load.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)
Records: 0  Deleted: 0  Skipped: 0  Warnings: 0

mysql> source /undrop-for-innodb-master/dumps/default/t2_3_load.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 4 rows affected (0.06 sec)
Records: 4  Deleted: 0  Skipped: 0  Warnings: 0

mysql> source /undrop-for-innodb-master/dumps/default/t2_4_load.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 4 rows affected (0.03 sec)
Records: 4  Deleted: 0  Skipped: 0  Warnings: 0

mysql> select * from t2;
+------+
| i    |
+------+
|    3 |
|    7 |
|   11 |
|   15 |
|    2 |
|    6 |
|   10 |
|   14 |
+------+
8 rows in set (0.00 sec)

到此数据已经恢复了。

发表评论

电子邮件地址不会被公开。