文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>how to recovery innodb from Pages from .idb (Part V)

how to recovery innodb from Pages from .idb (Part V)

时间:2010-08-22  来源:Steven1981

TEST STEP6:用"constraints_parser"试着从一个PAGE(找到INDEX_ID相对应的文件夹)中找出你的数据

TEST STEP7: 如果你觉得你的数据没有问题,那么你可以将所有的表连接起来(cat *.page > table.page),用此方法恢复所有的数据.


把数据导回表中


TEST STEP6:用"constraints_parser"试着从一个PAGE(找到INDEX_ID相对应的文件夹)中找出你的数据
----------------------
|| cd /opt/percona-innodb-recovery-tool
|| [root@localhost percona-innodb-recovery-tool]# ./constraints_parser -5 -U -f pages-1282459607/0-447/8-00000008.page | more
|| recover1 1970303589 NULL NULL
|| recover1 83886080 "" ""
|| recover1 629145619 "Taaaaa" NULL
|| recover1 629145619 "baaaaa" NULL
|| recover1 629145619 "paaaaa" NULL
|| recover1 629145619 "~aaaaa" NULL
|| recover1 4879 "aaaaaa" "bbbbbb"
|| recover1 4881 "aaaaaa" "bbbbbb"
|| recover1 4883 "aaaaaa" "bbbbbb"
|| recover1 4885 "aaaaaa" "bbbbbb"
|| recover1 4887 "aaaaaa" "bbbbbb"
|| recover1 4889 "aaaaaa" "bbbbbb"
|| recover1 4891 "aaaaaa" "bbbbbb"
|| recover1 4893 "aaaaaa" "bbbbbb"
|| recover1 4895 "aaaaaa" "bbbbbb"
|| recover1 629145619 "naaaaa" NULL
|| recover1 4899 "aaaaaa" "bbbbbb"
|| recover1 629145619 "&aaaaa" NULL
|| recover1 629145619 "4aaaaa" NULL
|| recover1 629145619 "Baaaaa" NULL
|| recover1 629145619 "Paaaaa" NULL
|| recover1 629145619 "^aaaaa" NULL
|| recover1 629145619 "laaaaa" NULL
|| recover1 629145619 "zaaaaa" NULL
|| recover1 4915 "aaaaaa" "bbbbbb"
|| recover1 4917 "aaaaaa" "bbbbbb"
|| recover1 4919 "aaaaaa" "bbbbbb"
|| recover1 4921 "aaaaaa" "bbbbbb"
|| recover1 4923 "aaaaaa" "bbbbbb"
|| recover1 4925 "aaaaaa" "bbbbbb"
|| recover1 4927 "aaaaaa" "bbbbbb"
|| recover1 4929 "aaaaaa" "bbbbbb"
|| recover1 4931 "aaaaaa" "bbbbbb"
|| recover1 4933 "aaaaaa" "bbbbbb"
|| recover1 4935 "aaaaaa" "bbbbbb"
|| recover1 4937 "aaaaaa" "bbbbbb"
|| ... ...


TEST STEP7: 如果你觉得你的数据没有问题,那么你可以将所有的表连接起来(cat *.page > table.page),用此方法恢复所有的数据.
----------------------
|| cd /opt/percona-innodb-recovery-tool/pages-1282459607/0-447
|| cat *.page > recover.page
|| cd /opt/percona-innodb-recovery-tool
|| ./constraints_parser -5 -U -f pages-1282459607/0-447/recover.page | more

#到这里,你可能会发现此工具恢复了一些与表数据无关或是不正确的数据。我们在table_defs.h中可以做一些过滤:
|| { /* int(11) */
|| name: "id",
|| type: FT_INT,
|| fixed_length: 4,
||
|| has_limits: TRUE,
|| limits: {
|| can_be_null: FALSE,
|| int_min_val: -2147483648LL,
|| int_max_val: 2147483647LL
|| },
||
|| can_be_null: FALSE
|| },
#把最小值改成0
||{ /* int(11) */
|| name: "id",
|| type: FT_INT,
|| fixed_length: 4,
||
|| has_limits: TRUE,
|| limits: {
|| can_be_null: FALSE,
|| int_min_val: 0LL,
|| int_max_val: 2147483647LL
|| },
||
|| can_be_null: FALSE
||},


|| { /* varchar(100) */
|| name: "c2",
|| type: FT_CHAR,
|| min_length: 0,
|| max_length: 100,
||
|| has_limits: TRUE,
|| limits: {
|| can_be_null: TRUE,
|| char_min_len: 0,
|| char_max_len: 100,
|| char_ascii_only: TRUE
|| },
||
|| can_be_null: TRUE
|| },
## c2字段最小长度为1 ,且不为空
|| { /* varchar(100) */
|| name: "c2",
|| type: FT_CHAR,
|| min_length: 0,
|| max_length: 100,
||
|| has_limits: TRUE,
|| limits: {
|| can_be_null: TRUE,
|| char_min_len: 1,
|| char_max_len: 100,
|| char_ascii_only: TRUE
|| },
||
|| can_be_null: FALSE
|| },

## 改了table_defs.h后,让"constraints_parser"能重新解析,需要重新MAKE:
|| make clean;make
||[root@localhost percona-innodb-recovery-tool]# ./constraints_parser -5 -U -f pages-1282459607/0-447/recover.page | more
||recover1 8539 "aaaaaa" "bbbbbb"
||recover1 8541 "aaaaaa" "bbbbbb"
||recover1 8543 "aaaaaa" "bbbbbb"
||recover1 8545 "aaaaaa" "bbbbbb"
||recover1 8547 "aaaaaa" "bbbbbb"
||recover1 8549 "aaaaaa" "bbbbbb"
||recover1 8551 "aaaaaa" "bbbbbb"
||recover1 8553 "aaaaaa" "bbbbbb"
||recover1 8555 "aaaaaa" "bbbbbb"
||recover1 8557 "aaaaaa" "bbbbbb"
||recover1 8559 "aaaaaa" "bbbbbb"
||recover1 8561 "aaaaaa" "bbbbbb"
||recover1 8563 "aaaaaa" "bbbbbb"
||recover1 8565 "aaaaaa" "bbbbbb"
||recover1 8567 "aaaaaa" "bbbbbb"
||recover1 8569 "aaaaaa" "bbbbbb"
||recover1 8571 "aaaaaa" "bbbbbb"
||recover1 8573 "aaaaaa" "bbbbbb"
||recover1 8575 "aaaaaa" "bbbbbb"
||recover1 8577 "aaaaaa" "bbbbbb"
||recover1 8579 "aaaaaa" "bbbbbb"
||recover1 8581 "aaaaaa" "bbbbbb"
||recover1 8583 "aaaaaa" "bbbbbb"
||recover1 8585 "aaaaaa" "bbbbbb"
||recover1 8587 "aaaaaa" "bbbbbb"
||recover1 8589 "aaaaaa" "bbbbbb"
||recover1 8591 "aaaaaa" "bbbbbb"
||recover1 8593 "aaaaaa" "bbbbbb"
||recover1 8595 "aaaaaa" "bbbbbb"
||recover1 8597 "aaaaaa" "bbbbbb"
||recover1 8599 "aaaaaa" "bbbbbb"
||recover1 8601 "aaaaaa" "bbbbbb"
||recover1 8603 "aaaaaa" "bbbbbb"
||recover1 8605 "aaaaaa" "bbbbbb"
||recover1 8607 "aaaaaa" "bbbbbb"
||recover1 8609 "aaaaaa" "bbbbbb"
... ...

## 现在我们可以将我们的数据全部导出来:
./constraints_parser -5 -U -f pages-1282459607/0-447/recover.page > /opt/recover.dat
##导出来的数据中,我们发现有一些重复ID,但数据量还是对的.
[root@localhost percona-innodb-recovery-tool]# cat /opt/recover.dat | sort -n -u -k 2 | wc -l
4096


把数据导回表中
-------------------
到这里,我们就可以用
mysql> LOAD DATA INFILE '/opt/recover.dat' REPLACE INTO TABLE <recover1>
将数据导回表中。



Reference :
http://code.google.com/p/innodb-tools/wiki/InnodbRecoveryHowto
http://www.percona.tv/mysql/innodb-recovery-tutorial

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载