{"id":4522,"date":"2013-07-08T21:09:07","date_gmt":"2013-07-08T13:09:07","guid":{"rendered":"http:\/\/www.orczhou.com\/?p=4522"},"modified":"2013-07-09T09:46:43","modified_gmt":"2013-07-09T01:46:43","slug":"how-to-recover-data-from-mysql-innodb-data-file-ibd-file","status":"publish","type":"post","link":"https:\/\/www.orczhou.com\/index.php\/2013\/07\/how-to-recover-data-from-mysql-innodb-data-file-ibd-file\/","title":{"rendered":"\u5982\u4f55\u4eceMySQL\/InnoDB\u6570\u636e\u6587\u4ef6\u4e2d\u7684\u6062\u590d\u6570\u636e"},"content":{"rendered":"<p>\u5728\u4e0a\u4e0a\u5468\u7ed9\u4e0b\u53a8\u623f\u505a\u8fc7\u4e00\u6b21\u6570\u636e\u6062\u590d(\u6545\u969c\u56de\u987e\uff1a<a href=\"http:\/\/tech.xiachufang.com\/?p=18\" target=\"_blank\">\u6545\u969c\u53d1\u751f\u7684\u6280\u672f\u603b\u7ed3<\/a> <a href=\"http:\/\/blog.xiachufang.com\/article\/5601\" target=\"_blank\">\u81f4\u6b49\u4fe1<\/a>)\uff0c\u6062\u590d\u4f7f\u7528\u4e86\u5f00\u6e90\u5de5\u5177<a href=\"http:\/\/www.percona.com\/software\/mysql-innodb-data-recovery-tools\">Percona Data Recovery Tool for InnoDB<\/a>(\u540e\u9762\u7b80\u79f0PDRTI)\uff0c\u8fd9\u91cc\u5206\u4eab\u4e00\u4e0b\u671f\u95f4\u7684\u6ce8\u610f\u4e8b\u9879\uff0c\u548c\u9047\u5230MySQL\u6570\u636e\u4e22\u5931\u7684\u4e00\u4e9b\u5e94\u5bf9\u3002<\/p>\n<p>\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u5728\u4f7f\u7528<a href=\"http:\/\/www.percona.com\/software\/mysql-innodb-data-recovery-tools\" target=\"_blank\">Percona Data Recovery Tool for InnoDB<\/a>\u65f6\u5019\u7684\u4e00\u4e9b\u6ce8\u610f\u4e8b\u9879\uff0c\u5e76\u4e0d\u5305\u62ec\u5177\u4f53\u7684step by step\u7684\u4f7f\u7528\u6b65\u9aa4\uff0c\u4f7f\u7528\u6587\u6863\u53ef\u4ee5\u53c2\u8003\uff1a<a href=\"http:\/\/www.percona.com\/docs\/wiki\/innodb-data-recovery-tool:start\" target=\"_blank\">Reference Manual and Documentation<\/a>\u3002<!--more--><\/p>\n\n<h3>1. \u7b80\u8ff0\u6062\u590d\u539f\u7406<\/h3>\n<p>\u56e0\u4e3a\u6587\u6863\u4e2d\u8f83\u4e3a\u8be6\u7ec6\u7684\u63cf\u8ff0\uff0c\u8fd9\u91cc\u53ea\u7b80\u5355\u8bf4\u660e\u3002\u6240\u6709InnoDB\u7684\u6570\u636e\u90fd\u662f\u7d22\u5f15\u7684\u65b9\u5f0f\u7ec4\u7ec7\u7684\uff0c\u800c\u4e14\u6240\u6709\u7684\u6570\u636e\u90fd\u662f\u5b58\u50a8\u572816KB\u7684\u6570\u636e\u5757\u4e2d\u3002\u6062\u590d\u7684\u8fc7\u7a0b\u5206\u51e0\u6b65\uff0c\u5206\u89e3\u6240\u6709\u6570\u636e\u6587\u4ef6\u4e3a\u5355\u4e2a16KB\u5927\u5c0f\u7684\u9875\u9762\uff0c\u6839\u636e\u6bcf\u4e2a\u9875\u9762\u7684\u6807\u8bb0\u7684\u6570\u636e\u8d77\u70b9\u5f00\u59cb\u5c1d\u8bd5\u5339\u914d\uff0c\u5982\u679c\u4e0e\u7ed9\u5b9a\u8868\u5b9a\u4e49\u7684size\u5408\u9002\uff0c\u8ba4\u4e3a\u5339\u914d\u6210\u529f\uff0c\u5219\u8f93\u51fa\u8bb0\u5f55\u3002<\/p>\n<h3>2. \u5e76\u884c\u7684\u6062\u590d<\/h3>\n<p>\u6570\u636e\u6062\u590d\u901a\u5e38\u662f\u4e89\u5206\u593a\u79d2\u7684\uff0cPDRTI\u5de5\u5177\u672c\u8eab\u662f\u4e00\u4e2a\u57fa\u7840\u5de5\u5177\uff0c\u5982\u679c\u4f7f\u7528\u8be5\u5de5\u5177\u505a\u505a\u4e32\u884c\u6062\u590d\uff0c\u65f6\u95f4\u4f1a\u975e\u5e38\u957f\uff0c\u901a\u8fc7\u7b80\u5355\u7684shell\u811a\u672c\u53ef\u4ee5\u8ba9constraints_parser\u811a\u672c\u5e76\u884c\u5de5\u4f5c\uff0c\u8fd9\u6837\u53ef\u4ee5\u5927\u5927\u7f29\u77ed\u6570\u636e\u7684\u6062\u590d\u65f6\u95f4\u3002\u6839\u636e\u5b9e\u9645\u7ecf\u9a8c\uff0c\u673a\u5668\u7a0d\u5fae\u597d\u70b9\uff0c\u5b9e\u9645\u6062\u590d\u65f6\u95f4\u53ef\u4ee5\u7f29\u77ed\u5230\u4e32\u884c\u7684\u4e8c\u5341\u5206\u4e4b\u4e00\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u539f\u6765\u9700\u898140\u5c0f\u65f6\uff0c\u901a\u8fc7\u5e76\u884c\u53ef\u80fd2\u4e2a\u5c0f\u65f6\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e24\u4e2a\u5e76\u884c\u6062\u590d\u7684\u811a\u672c\uff0c\u4f9b\u53c2\u8003\uff1a<\/p>\n<pre><div class=\"mycode\">#!\/bin\/bash\r\nws=\/u01\/recovery\r\npagedir=\/u01\/recovery\/pages-1372436970\/FIL_PAGE_INDEX\r\nlogdir=\/u01\/recovery\/log\r\nrectool=\/u01\/recovery\/percona-data-recovery-tool-for-innodb-0.5\/constraints_parser\r\ncd `dirname $rectool`\r\ncount=0\r\npage_count=353894\r\npage_done=0\r\nstartdate=`date +%s`\r\nfor d1 in `ls $pagedir`\r\ndo\r\n  count=$(($count+1))\r\n  echo \"in page $d2 at dir $d1\" > $logdir\/$count.log\r\n  thedate=`date +%s`\r\n  echo \"$page_done \/ $page_count at $thedate from $startdate\"\r\n  total=`ls -l $pagedir\/$d1\/|wc -l`\r\n  page_done=$(($page_done+$total))\r\n  threads=`ps axu|grep parser_jobs|grep -v grep|wc -l`\r\n  echo $threads\r\n  while [ $threads -gt 48 ];\r\n  do\r\n    sleep 1\r\n    threads=`ps axu|grep parser_jobs|grep -v grep|wc -l`\r\n  done\r\n  $ws\/parser_jobs.sh $pagedir\/$d1 > $ws\/job.log 2>&1 &\r\ndone<\/div><\/pre>\n<pre><div class=\"mycode\">#!\/bin\/bash\r\npagedir=\/u01\/recovery\/pages-1372436970\/FIL_PAGE_INDEX\r\nlogdir=\/u01\/recovery\/log\r\nrectool=\/u01\/recovery\/percona-data-recovery-tool-for-innodb-0.5\/constraints_parser\r\nlogfile=\"$logdir\/`basename $1`.log\"\r\necho \"$1\" > $logfile\r\nif [ -d $1 ];then\r\n  for d2 in `ls $1`\r\n  do\r\n    $rectool -5 -f $1\/$d2 >> $logfile 2>\/dev\/null\r\n  done\r\nfi<\/div><\/pre>\n<h3>3. \u4ece\u7d22\u5f15\u4e2d\u6062\u590d<\/h3>\n<p>\u5982\u679c\u77e5\u9053\u6570\u636e\u8868\u7684\u7d22\u5f15\u7ed3\u6784\uff0c\u5982\u679c\u6570\u636e\u90e8\u5206\u635f\u574f\uff0c\u4f46\u662f\u7d22\u5f15\u90e8\u5206\u5b8c\u6574\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e2a\u529e\u6cd5\u63d0\u53d6\u51fa\u6765\u66f4\u591a\u7684\u5b57\u6bb5\u4fe1\u606f\u3002<\/p>\n<h3>4. \u7d27\u6025\u60c5\u51b5\u4e0b\u7684\u95ee\u9898\u5904\u7406<\/h3>\n<p>\u8fd9\u6b21\u4e0b\u53a8\u623f\u7684\u6280\u672f\u603b\u7ed3\u4e2d\u63d0\u5230\uff0c&#8221;\u7b2c\u4e00\u65f6\u95f4\u505c\u6b62MySQL\u9632\u6b62\u786c\u76d8\u7ee7\u7eed\u5199\u5165\u8fd9\u4e2a\u5e94\u6025\u63aa\u65bd\u662f\u9519\u8bef\u7684&#8221;\uff0c\u6b63\u5e38\u5982\u679c\u8fdb\u7a0b\u6ca1\u6709\u88ab\u5173\u95ed\uff0c\u8fdb\u7a0b\u6240\u6253\u5f00\u7684\u6587\u4ef6\u662f\u4e0d\u4f1a\u88ab\u8986\u76d6\u7684\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ece\/proc\u6587\u4ef6\u7cfb\u7edf\u62f7\u8d1d\u7684\u65b9\u5f0f\u6062\u590d\u51fa\u5f53\u524d\u4ecd\u7136\u6253\u5f00\u7684\u6587\u4ef6(\u53c2\u8003\uff1a<a href=\"http:\/\/www.hackinglinuxexposed.com\/articles\/20020507.html\">Recovering files from \/Proc<\/a>)\u3002\u5982\u679c\u6570\u636e\u6587\u4ef6\u548c\u65e5\u5fd7\u6587\u4ef6\u90fd\u80fd\u591fcp\u51fa\u6765\uff0c\u90a3\u4e48\u6709\u5e0c\u671b\u8ba9MySQL\u81ea\u5df1\u542f\u52a8\uff0c\u5e76\u6839\u636e\u4e8b\u52a1\u65e5\u5fd7\u6062\u590d\u51fa\u5f53\u524d\u4e00\u81f4\u7684\u6570\u636e\u3002<\/p>\n<h3>5. \u6700\u540e\uff0c\u6ca1\u6709\u6700\u540e\u4e86<\/h3>\n<p>\u5982\u679c\u4f60\u9700\u8981\u6570\u636e\u6062\u590d\uff0c\u53ef\u4ee5\u8054\u7cfb\u6211\uff0c\u63d0\u4f9b\u514d\u8d39\u7684\u54a8\u8be2\uff0c\u548c\u6536\u8d39\u7684\u6062\u590d\u670d\u52a1\u3002\u53e6\u5916\uff0c\u5982\u679c\u9700\u8981\u4e13\u4e1a\u670d\u52a1\u53ef\u4ee5\u8054\u7cfb<a href=\"http:\/\/www.woqutech.com\/\" target=\"_blank\">\u6c83\u8da3\u79d1\u6280<\/a>\uff0c\u4ed6\u4eec\u63d0\u4f9b\u4e13\u4e1a\u7684\u3001\u5b8c\u6574\u7684\u6570\u636e\u5e93\u670d\u52a1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4e0a\u4e0a\u5468\u7ed9\u4e0b\u53a8\u623f\u505a\u8fc7\u4e00\u6b21\u6570\u636e\u6062\u590d(\u6545\u969c\u56de\u987e\uff1a\u6545\u969c\u53d1\u751f\u7684\u6280\u672f\u603b\u7ed3 \u81f4\u6b49\u4fe1)\uff0c\u6062\u590d\u4f7f\u7528\u4e86\u5f00\u6e90\u5de5\u5177Percona Data Recovery Tool for InnoDB(\u540e\u9762\u7b80\u79f0PDRTI)\uff0c\u8fd9\u91cc\u5206\u4eab\u4e00\u4e0b\u671f\u95f4\u7684\u6ce8\u610f\u4e8b\u9879\uff0c\u548c\u9047\u5230MySQL\u6570\u636e\u4e22\u5931\u7684\u4e00\u4e9b\u5e94\u5bf9\u3002 \u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u5728\u4f7f\u7528Percona Data Recovery Tool for InnoDB\u65f6\u5019\u7684\u4e00\u4e9b\u6ce8\u610f\u4e8b\u9879\uff0c\u5e76\u4e0d\u5305\u62ec\u5177\u4f53\u7684step by step\u7684\u4f7f\u7528\u6b65\u9aa4\uff0c\u4f7f\u7528\u6587\u6863\u53ef\u4ee5\u53c2\u8003\uff1aReference Manual and Documentation\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","inline_featured_image":false,"_tocer_settings":[],"footnotes":""},"categories":[6,4],"tags":[120,110,118,109],"class_list":["post-4522","post","type-post","status-publish","format-standard","hentry","category-mysql","category-code-detail","tag-innodb","tag-innodb-data-recovery","tag-mysql","tag-recovery"],"_links":{"self":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/4522","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/comments?post=4522"}],"version-history":[{"count":6,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/4522\/revisions"}],"predecessor-version":[{"id":4528,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/4522\/revisions\/4528"}],"wp:attachment":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/media?parent=4522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/categories?post=4522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/tags?post=4522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}