{"id":1903,"date":"2010-05-08T14:27:15","date_gmt":"2010-05-08T06:27:15","guid":{"rendered":"http:\/\/www.orczhou.com\/?p=1903"},"modified":"2010-05-08T14:27:15","modified_gmt":"2010-05-08T06:27:15","slug":"innodb-corruption","status":"publish","type":"post","link":"https:\/\/www.orczhou.com\/index.php\/2010\/05\/innodb-corruption\/","title":{"rendered":"InnoDB Corruption"},"content":{"rendered":"<p>\u4ee5\u524d\u6ca1\u6709\u9047\u5230InnoDB\u6587\u4ef6\u635f\u574f\u7684\u60c5\u51b5\uff0c\u7279\u6b64\u8bb0\u5f55\u3002\u4ece\u65e5\u5fd7\u6765\u770b\uff0c\u635f\u574f\u7684\u5e94\u8be5\u662f\u4e00\u4e2a\u7d22\u5f15\u9875\uff0c\u5bfc\u81f4\u5bf9\u5e94\u7684\u6570\u636e\u8868\u65e0\u6cd5\u8bbf\u95ee\uff0c\u4e5f\u65e0\u6cd5\u83b7\u53d6\u5bf9\u5e94\u6570\u636e\u8868\u4e2d\u7684\u6570\u636e\uff0c\u5c1d\u8bd5check optimize\u4e5f\u65e0\u6cd5\u4fee\u590d\u3002\u6700\u540e\u8bbe\u7f6einnodb_force_recovery=1\u540e\u542f\u52a8\u6570\u636e\u5e93\u540e\uff0c\u80fd\u591f\u5bfc\u51fa\u5168\u90e8\u6570\u636e\u3002<\/p>\n<p><font color=\"red\">1. \u6545\u969c<\/font><\/p>\n<p>\u6700\u8fd1\uff0c\u5728\u4ece\u4e00\u4e2aXtrabackup\u7684\u5907\u4efd\u4e2d\u6062\u590d\u6570\u636e\u540e\uff0c\u53d1\u73b0MySQL\u6570\u636e\u5e93\u80fd\u6b63\u5e38\u542f\u52a8\uff0c\u4f46\u662f\u53d1\u73b0use dbname\u4e00\u4e0bMySQL\u5c31\u4f1a\u5d29\u6e83\uff0c\u770b\u65e5\u5fd7\uff1a<!--more--><\/p>\n<div class=\"mycode\">InnoDB: Database page corruption on disk or a failed<br \/>\nInnoDB: file read of page 4.<br \/>\nInnoDB: You may have to recover from a backup.<br \/>\n100505 10:19:07  InnoDB: Page dump in ascii and hex (16384 bytes):<br \/>\n len 16384; hex 89ecae1d00000004ffffffffffffffff0000014bf7119c4545<br \/>\n&#8230;&#8230;<br \/>\n&#8230;&#8230;<br \/>\n100505 10:19:07  InnoDB: Page checksum 2313989661, prior-to-4.0.14-form checksum 3285785245<br \/>\nInnoDB: stored checksum 2313989661, prior-to-4.0.14-form stored checksum 1519970954<br \/>\nInnoDB: Page lsn 331 4145126469, low 4 bytes of lsn at page end 1983060<br \/>\nInnoDB: Page number (if stored to page already) 4,<br \/>\nInnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 884<br \/>\nInnoDB: Page may be an index page where index id is 0 1929<br \/>\nInnoDB: (index &#8220;IDX_fa_login_userid&#8221; of table &#8220;fa&#8221;.&#8221;login_history_0015&#8243;)<br \/>\nInnoDB: Database page corruption on disk or a failed<br \/>\nInnoDB: file read of page 4.\n<\/div>\n<p><!--more--><\/p>\n<p>\u4ece\u4e0a\u9762\u7684\u4fe1\u606f\u6211\u4eec\u770b\u5230\uff0c\u53ef\u80fd\u662f\u8868&#8221;fa&#8221;.&#8221;login_history_0015&#8243;\u7684\u7d22\u5f15\u9875\u6709\u635f\u574f\u3002\u867d\u7136\u8fd9\u4e2a\u8868\u6545\u969c\u4e86\uff0c\u4e0d\u8fc7MySQL\u8fd8\u662f\u80fd\u591f\u6b63\u5e38\u542f\u52a8\uff0c\u800c\u4e14\u5bf9\u5176\u4ed6\u8868\u4e5f\u662f\u80fd\u591f\u6b63\u5e38\u64cd\u4f5c\u7684\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u7528mysql client\u8fde\u63a5\u8fdb\u53bb\u65f6\u9700\u8981\u4f7f\u7528\u53c2\u6570-A\uff0c\u5426\u5219use dbname\u7684\u65f6\u5019\u53ef\u80fd\u4f1a\u6709\u95ee\u9898\u3002<\/p>\n<div class=\"mycode\">$mysql -uroot -A -p<\/div>\n<p><font color=\"red\">2. check\u4fee\u590d<\/font><\/p>\n<p>\u6839\u636eEerror Log\u4e2d\u7684\u63d0\u793a\u4f7f\u7528CHECK TABLE\u4fee\u590d\uff1a<\/p>\n<div class=\"mycode\">root@fa 10:28:14>check table login_history_0015;<br \/>\nERROR 2013 (HY000): Lost connection to MySQL server during query<br \/>\nroot@fa 10:28:49>100505 10:28:49 mysqld_safe Number of processes running now: 0<br \/>\n100505 10:28:49 mysqld_safe mysqld restarted\n<\/div>\n<p>\u672a\u679c\uff01<\/p>\n<p><font color=\"red\">2. OPTIMIZE\u4fee\u590d<\/font><\/p>\n<p>\u5c1d\u8bd5OPTIMIZE TABLE<\/p>\n<div class=\"mycode\">root@fa 10:35:30> OPTIMIZE TABLE login_history_0015;<br \/>\nERROR 2013 (HY000): Lost connection to MySQL server during query<\/div>\n<p>\u672a\u679c<\/p>\n<p><font color=\"red\">3. \u5c1d\u8bd5innodb_force_recovery<del datetime=\"2010-05-08T06:22:05+00:00\">\u4e86<\/del><\/font><\/p>\n<p>\u5728my.cnf\u4e2d\u8bbe\u7f6einnodb_force_recovery=1\uff0c\u8be5\u53c2\u6570\u4f7f\u5f97InnoDB\u5373\u4f7f\u68c0\u6d4b\u5230corrupt page\u4ecd\u7136\u542f\u52a8MySQL\uff0c\u5e76\u5c06InnoDB\u7f6e\u4e8e\u53ea\u8bfb\u72b6\u6001\uff1a<\/p>\n<div class=\"mycode\">InnoDB: innodb_force_recovery is on: we do not allow<br \/>\nInnoDB: database modifications by the user. Shut down<\/div>\n<p>OK\uff0c\u53d1\u73b0\u8fd9\u6837\u53ef\u4ee5\u8bbf\u95ee\u6570\u636e\u8868\uff0c\u867d\u7136\u65e0\u6cd5\u4fee\u6539\u6570\u636e\u8868\u3002\u4f46\u662f\u8fd9\u5c31\u8db3\u591f\u4e86\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u7528msyqldump\u5bfc\u51fa\u5168\u90e8\u7684\u6570\u636e\u4e86\u3002<\/p>\n<p><font color=\"red\">4. \u6545\u969c\u539f\u56e0<\/font><\/p>\n<p>\u56e0\u4e3a\u662f\u6570\u636e\u662f\u4ece\u5907\u5e93\u4e2d\u6062\u590d\u8fc7\u6765\u7684\uff0c\u5148\u6000\u7591\u662f\u4e0d\u662f\u8fd9\u53f0\u4e3b\u673a\u6709\u95ee\u9898\uff08\u6062\u590d\u7684\u65f6\u5019\u78c1\u76d8\u51fa\u73b0\u67d0\u4e2a\u83ab\u540d\u7684\u6545\u969c\uff09\uff0c\u6362\u4e86\u4e00\u53f0\u4e3b\u673a\u6062\u590d\uff0c\u6545\u969c\u4f9d\u65e7\u3002\u8fd9\u8bf4\u660e\u662f\u8fd9\u4e2a\u5907\u4efd\u6587\u4ef6\u662f\u6709\u95ee\u9898\u7684\u3002<\/p>\n<p>\u4e8e\u662f\u4ece\u540c\u4e00\u53f0\u4e3b\u673a\u4e0a\u524d\u4e00\u5929\u7684Xtrabackup\u4e2d\u6062\u590d\uff0c\u6ca1\u6709\u9047\u5230\u6545\u969c\uff1b\u540e\u6765\u7b2c\u4e8c\u5929\uff0c\u6211\u53c8\u5728\u4e3b\u673a\u4e0a\u505a\u4e86\u4e00\u4e2aXtrabackup\u5907\u4efd\uff0c\u518d\u6062\u590d\uff0c\u95ee\u9898\u6ca1\u6709\u91cd\u73b0\u3002\u8fd9\u8bf4\u660e\u53ea\u6709\u90a3\u4e00\u5929\u7684Xtrabackup\u6709\u6545\u969c\u3002<\/p>\n<p>\u65e0\u6cd5\u5b9a\u4f4d\u539f\u56e0\u3002<\/p>\n<p>\u56e0\u4e3a\u662f\u4ece\u5907\u4efd\u4e2d\u6062\u590d\u7684\u6570\u636e\uff0c\u68c0\u67e5\u4e86\u4e00\u4e0b\u4e3b\u5e93\u4e0a\u8fd9\u4e2a\u8868\u662f\u6b63\u5e38\uff0c\u6240\u4ee5\u8ba4\u4e3a\u662f\u5907\u4efd\u7684\u65f6\u5019\u51fa\u73b0\u7684\u6545\u969c\uff0c\u731c\u6d4b\uff1a\u5907\u4efd\u662f\u7528Xtrabackup\u505a\u7684\uff0c\u6709\u53ef\u80fd\u662fXtrabackup\u7684Bug\uff08\u7528\u524d\u4e00\u5929Xtrabackup\u518d\u505a\u4e86\u4e00\u6b21\u6062\u590d\uff0c\u5e76\u6ca1\u6709\u51fa\u73b0\u7c7b\u4f3c\u7684\u95ee\u9898\uff09\uff0c\u4e5f\u53ef\u80fd\u662f\u5907\u4efd\u7684\u65f6\u5019\u60f3NAS\u5199\u7684\u65f6\u5019\u51fa\u73b0\u201c\u610f\u5916\u201d&#8230;&#8230;<\/p>\n<p>\u8c01\u77e5\u9053\u5462<\/p>\n<p>\u53c2\u8003\u6587\u732e\uff1a<br \/>\n[1]. <a href=\"http:\/\/www.mysqlperformanceblog.com\/2008\/07\/04\/recovering-innodb-table-corruption\/\">Recovering Innodb table Corruption<\/a><br \/>\n[2]. <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.1\/en\/forcing-recovery.html\">Forcing InnoDB Recovery<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u524d\u6ca1\u6709\u9047\u5230InnoDB\u6587\u4ef6\u635f\u574f\u7684\u60c5\u51b5\uff0c\u7279\u6b64\u8bb0\u5f55\u3002\u4ece\u65e5\u5fd7\u6765\u770b\uff0c\u635f\u574f\u7684\u5e94\u8be5\u662f\u4e00\u4e2a\u7d22\u5f15\u9875\uff0c\u5bfc\u81f4\u5bf9\u5e94\u7684\u6570\u636e\u8868\u65e0\u6cd5\u8bbf\u95ee\uff0c\u4e5f\u65e0\u6cd5\u83b7\u53d6\u5bf9\u5e94\u6570\u636e\u8868\u4e2d\u7684\u6570\u636e\uff0c\u5c1d\u8bd5check optimize\u4e5f\u65e0\u6cd5\u4fee\u590d\u3002\u6700\u540e\u8bbe\u7f6einnodb_force_recovery=1\u540e\u542f\u52a8\u6570\u636e\u5e93\u540e\uff0c\u80fd\u591f\u5bfc\u51fa\u5168\u90e8\u6570\u636e\u3002 1. \u6545\u969c \u6700\u8fd1\uff0c\u5728\u4ece\u4e00\u4e2aXtrabackup\u7684\u5907\u4efd\u4e2d\u6062\u590d\u6570\u636e\u540e\uff0c\u53d1\u73b0MySQL\u6570\u636e\u5e93\u80fd\u6b63\u5e38\u542f\u52a8\uff0c\u4f46\u662f\u53d1\u73b0use dbname\u4e00\u4e0bMySQL\u5c31\u4f1a\u5d29\u6e83\uff0c\u770b\u65e5\u5fd7\uff1a<\/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],"tags":[120],"class_list":["post-1903","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-innodb"],"_links":{"self":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/1903","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=1903"}],"version-history":[{"count":15,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/1903\/revisions"}],"predecessor-version":[{"id":1973,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/1903\/revisions\/1973"}],"wp:attachment":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/media?parent=1903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/categories?post=1903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/tags?post=1903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}