{"id":1361,"date":"2012-01-15T14:35:54","date_gmt":"2012-01-15T06:35:54","guid":{"rendered":"http:\/\/doophp.sinaapp.com\/?p=1361"},"modified":"2012-01-15T17:08:17","modified_gmt":"2012-01-15T09:08:17","slug":"percona-xtrabackup","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/mysql\/percona-xtrabackup.html","title":{"rendered":"MySQL\u5907\u4efd\u5de5\u5177\uff1aPercona Xtrabackup"},"content":{"rendered":"
<\/a><\/p>\n Percona Xtrabackup<\/a> \u662f\u4e00\u4e2a\u5f00\u6e90\u7684MySQL\u70ed\u5907\u4efd\u5de5\u5177\uff0c\u91c7\u7528GPL\u5f00\u6e90\u534f\u8bae\uff0c\u652f\u6301InnoDB\u3001XtraDB\u5f15\u64ce\u5728\u7ebf\u70ed\u5907\u4efd\u3001Non-blockingd\u5907\u4efd\uff0c\u6d41\u5f0f\u5907\u4efd\uff0c\u538b\u7f29\u5907\u4efd\uff0c\u589e\u91cf\u5907\u4efd\u7b49\u7279\u6027\uff0c\u662f\u5546\u4e1a\u5907\u4efd\u5de5\u5177InnoDB HotBackup\u7684\u4e00\u4e2a\u5f88\u597d\u7684\u66ff\u4ee3\u54c1\u3002\u76ee\u524dPercona Xtrabackup\u652f\u6301InnoDB\u3001XtraDB\u548cMyISAM\uff0c\u539f\u751fMySQL\u4ee5\u53caPercona Server\u4e0a\u7684XtraDB\uff0c\u53ef\u8fd0\u884c\u5728Linux\u548cFreeBSD\u4e0a\uff0cWindows\u5e73\u53f0\u76ee\u524d\u5904\u4e8e\u6d4b\u8bd5\u9636\u6bb5\u3002 \u9996\u5148\uff0c\u5728logfile\u4e2d\u627e\u5230\u5e76\u8bb0\u5f55\u6700\u540e\u4e00\u4e2acheckpoint(\u201clast checkpoint LSN\u201d)\uff0c\u7136\u540e\u5f00\u59cb\u4eceLSN\u7684\u4f4d\u7f6e\u5f00\u59cb\u62f7\u8d1dInnoDB\u7684logfile\u5230xtrabackup_logfile\uff1b\u63a5\u7740\uff0c\u5f00\u59cb\u62f7\u8d1d\u5168\u90e8\u7684\u6570\u636e\u6587\u4ef6.ibd\uff1b\u5728\u62f7\u8d1d\u5168\u90e8\u6570\u636e\u6587\u4ef6\u7ed3\u675f\u4e4b\u540e\uff0c\u624d\u505c\u6b62\u62f7\u8d1dlogfile\u3002<\/p>\n \u56e0\u4e3alogfile\u91cc\u9762\u8bb0\u5f55\u5168\u90e8\u7684\u6570\u636e\u4fee\u6539\u60c5\u51b5\uff0c\u6240\u4ee5\uff0c\u5373\u65f6\u5728\u5907\u4efd\u8fc7\u7a0b\u4e2d\u6570\u636e\u6587\u4ef6\u88ab\u4fee\u6539\u8fc7\u4e86\uff0c\u6062\u590d\u65f6\u4ecd\u7136\u80fd\u591f\u901a\u8fc7\u89e3\u6790xtrabackup_logfile\u4fdd\u6301\u6570\u636e\u7684\u4e00\u81f4\u3002<\/p>\n XtraBackup\u57fa\u4e8eInnoDB\u7684crash-recovery\u529f\u80fd\u3002\u5b83\u4f1a\u590d\u5236innodb\u7684data file\uff0c\u7531\u4e8e\u4e0d\u9501\u8868\uff0c\u590d\u5236\u51fa\u6765\u7684\u6570\u636e\u662f\u4e0d\u4e00\u81f4\u7684\uff0c\u5728\u6062\u590d\u7684\u65f6\u5019\u4f7f\u7528crash-recovery\uff0c\u4f7f\u5f97\u6570\u636e\u6062\u590d\u4e00\u81f4\u3002<\/p>\n InnoDB\u7ef4\u62a4\u4e86\u4e00\u4e2aredo log\uff0c\u53c8\u79f0\u4e3atransaction log\uff0c\u4e8b\u52a1\u65e5\u5fd7\uff0c\u5b83\u5305\u542b\u4e86innodb\u6570\u636e\u7684\u6240\u6709\u6539\u52a8\u60c5\u51b5\u3002\u5f53InnoDB\u542f\u52a8\u7684\u65f6\u5019\uff0c\u5b83\u4f1a\u5148\u53bb\u68c0\u67e5data file\u548ctransaction log\uff0c\u5e76\u4e14\u4f1a\u505a\u4e8c\u6b65\u64cd\u4f5c\uff1a<\/p>\n XtraBackup\u5728\u5907\u4efd\u7684\u65f6\u5019\uff0c \u4e00\u9875\u4e00\u9875\u5730\u590d\u5236innodb\u7684\u6570\u636e\uff0c\u800c\u4e14\u4e0d\u9501\u5b9a\u8868\uff0c\u4e0e\u6b64\u540c\u65f6\uff0cXtraBackup\u8fd8\u6709\u53e6\u5916\u4e00\u4e2a\u7ebf\u7a0b\u76d1\u89c6\u7740transactions log\uff0c\u4e00\u65e6log\u53d1\u751f\u53d8\u5316\uff0c\u5c31\u628a\u53d8\u5316\u8fc7\u7684log pages\u590d\u5236\u8d70\u3002\u4e3a\u4ec0\u4e48\u8981\u6025\u7740\u590d\u5236\u8d70\u5462\uff1f \u56e0\u4e3atransactions log\u6587\u4ef6\u5927\u5c0f\u6709\u9650\uff0c\u5199\u6ee1\u4e4b\u540e\uff0c\u5c31\u4f1a\u4ece\u5934\u518d\u5f00\u59cb\u5199\uff0c\u6240\u4ee5\u65b0\u6570\u636e\u53ef\u80fd\u4f1a\u8986\u76d6\u5230\u65e7\u7684\u6570\u636e\u3002<\/p>\n \u5728prepare\u8fc7\u7a0b\u4e2d\uff0cXtraBackup\u4f7f\u7528\u590d\u5236\u5230\u7684transactions log\u5bf9\u5907\u4efd\u51fa\u6765\u7684innodb data file\u8fdb\u884ccrash recovery\u3002<\/p>\n \u00a0\u5b9e\u73b0\u7ec6\u8282<\/strong><\/p>\n XtraBackup\u4ee5read-write\u6a21\u5f0f\u6253\u5f00innodb\u7684\u6570\u636e\u6587\u4ef6\uff0c\u7136\u540e\u5bf9\u5176\u8fdb\u884c\u590d\u5236\u3002\u5176\u5b9e\u5b83\u4e0d\u4f1a\u4fee\u6539\u6b64\u6587\u4ef6\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u8fd0\u884c XtraBackup\u7684\u7528\u6237\uff0c\u5fc5\u987b\u5bf9innodb\u7684\u6570\u636e\u6587\u4ef6\u5177\u6709\u8bfb\u5199\u6743\u9650\u3002\u4e4b\u6240\u4ee5\u91c7\u7528read-write\u6a21\u5f0f\u662f\u56e0\u4e3aXtraBackup\u91c7\u7528\u4e86\u5176\u5185\u7f6e\u7684 innodb\u5e93\u6765\u6253\u5f00\u6587\u4ef6\uff0c\u800cinnodb\u5e93\u6253\u5f00\u6587\u4ef6\u7684\u65f6\u5019\u5c31\u662frw\u7684\u3002<\/p>\n XtraBackup\u8981\u4ece\u6587\u4ef6\u7cfb\u7edf\u4e2d\u590d\u5236\u5927\u91cf\u7684\u6570\u636e\uff0c\u6240\u4ee5\u5b83\u5c3d\u53ef\u80fd\u5730\u4f7f\u7528posix_fadvise()\uff0c\u6765\u544a\u8bc9OS\u4e0d\u8981\u7f13\u5b58\u8bfb\u53d6\u5230\u7684\u6570\u636e\uff0c\u4ece \u800c\u63d0\u5347\u6027\u80fd\u3002\u56e0\u4e3a\u8fd9\u4e9b\u6570\u636e\u4e0d\u4f1a\u91cd\u7528\u5230\u4e86\uff0cOS\u5374\u6ca1\u6709\u8fd9\u4e48\u806a\u660e\u3002\u5982\u679c\u8981\u7f13\u5b58\u4e00\u4e0b\u7684\u8bdd\uff0c\u51e0\u4e2aG\u7684\u6570\u636e\uff0c\u4f1a\u5bf9OS\u7684\u865a\u62df\u5185\u5b58\u9020\u6210\u5f88\u5927\u7684\u538b\u529b\uff0c\u5176\u5b83\u8fdb\u7a0b\uff0c\u6bd4\u5982 mysqld\u5f88\u6709\u53ef\u80fd\u88abswap\u51fa\u53bb\uff0c\u8fd9\u6837\u7cfb\u7edf\u5c31\u4f1a\u53d7\u5230\u5f88\u5927\u5f71\u54cd\u4e86\u3002<\/p>\n \u5728\u5907\u4efdinnodb page\u7684\u8fc7\u7a0b\u4e2d\uff0cXtraBackup\u6bcf\u6b21\u8bfb\u51991MB\u7684\u6570\u636e\uff0c1MB\/16KB=64\u4e2apage\u3002\u8fd9\u4e2a\u4e0d\u53ef\u914d\u7f6e\u3002\u8bfb1MB\u6570\u636e\u4e4b \u540e\uff0cXtraBackup\u4e00\u9875\u4e00\u9875\u5730\u904d\u5386\u8fd91MB\u6570\u636e\uff0c\u4f7f\u7528innodb\u7684buf_page_is_corrupted()\u51fd\u6570\u68c0\u67e5\u6b64\u9875\u7684\u6570\u636e\u662f\u5426\u6b63\u5e38\uff0c \u5982\u679c\u6570\u636e\u4e0d\u6b63\u5e38\uff0c\u5c31\u91cd\u65b0\u8bfb\u53d6\u8fd9\u4e00\u9875\uff0c\u6700\u591a\u91cd\u65b0\u8bfb\u53d610\u6b21\uff0c\u5982\u679c\u8fd8\u662f\u5931\u8d25\uff0c\u5907\u4efd\u5c31\u5931\u8d25\u4e86\uff0c\u9000\u51fa\u3002\u5728\u590d\u5236transactions log\u7684\u65f6\u5019\uff0c\u6bcf\u6b21\u8bfb\u5199512KB\u7684\u6570\u636e\u3002\u540c\u6837\u4e0d\u53ef\u4ee5\u914d\u7f6e\u3002<\/p>\n<\/div>\n PS:<\/strong><\/p>\n Percona Xtrabackup \u53ea\u5907\u4efd\u6570\u636e\u4e0d\u5907\u4efd\u8868\u7ed3\u6784 Percona Xtrabackup\u63d0\u4f9bRPM\u5305\u4ee5\u53ca\u6e90\u7801\u5b89\u88c5\uff0c\u901a\u8fc7Percona\u63d0\u4f9b\u7684YUM\u6e90<\/a>\u6211\u4eec\u53ef\u4ee5\u65b9\u4fbf\u5730\u901a\u8fc7YUM\u8fdb\u884c\u5b89\u88c5\uff0c\u6211\u4eec\u7b80\u5355\u4ecb\u7ecd\u4e00\u4e0b\u914d\u7f6e\u5b98\u65b9\u63d0\u4f9b\u7684YUM\u6e90\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n \u4fdd\u5b58\u4ee5\u4e0b\u5185\u5bb9\u5230\u6587\u4ef6\u00a0\/etc\/yum.repos.d\/Percona.repo<\/p>\n [percona]<\/p>\n name = CentOS $releasever – Percona<\/p>\n baseurl=http:\/\/repo.percona.com\/centos\/$releasever\/os\/$basearch\/<\/p>\n enabled = 1<\/p>\n gpgkey = file:\/\/\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-percona<\/p>\n gpgcheck = 1<\/p><\/blockquote>\n \u4e0b\u8f7d\u5e76\u4fdd\u5b58Percona GPG key\u6587\u4ef6\u5230\u00a0\/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-percona<\/p>\n wget\u00a0http:\/\/www.percona.com\/downloads\/RPM-GPG-KEY-percona<\/a><\/p><\/blockquote>\n
\n
\nPercona Xtrabackup\u5305\u542b3\u4e2a\u5de5\u5177\uff1a<\/strong>xtrabackup\u3001innobackupex\u3001tar4ibd<\/p>\n\n
\n\u4e3b\u8981\u7279\u6027<\/strong><\/p>\n\n
\n
\n\u589e\u91cf\u5907\u4efd\u53ea\u9002\u5408\u4e8e\u57fa\u4e8eInnoDB\u6216XtraDB\u7684\u8868\uff0c\u8fd9\u548c\u57fa\u4e8eInnoDB\u7684Crash-Recovery\u529f\u80fd\u6709\u5173\uff0c\u53e6\u5916\u5982\u679c\u589e\u91cf\u5907\u4efd\u5931\u8d25\uff0c\u8bf7\u786e\u8ba4my.cnf\u4e2d\u201cdefault_table_type\u201d\u503c\u662f\u5426\u4e3aInnoDB
\nPercona Xtrabackup \u5c5e\u4e8e\u7269\u7406\u5907\u4efd\uff08MySQLDump\u5c5e\u903b\u8f91\u5907\u4efd\uff09\uff0c\u6062\u590d\u901f\u7387\u6bd4MySQLDump\u8981\u5feb\uff0c\u80fd\u7f29\u77ed\u6062\u590d\u65f6\u95f4
\nPercona Xtrabackup NoNBlock\u4e0d\u4f1a\u8c03\u7528Flush\u64cd\u4f5c\uff0c\u56e0\u6b64\u5728\u4efb\u4f55\u60c5\u51b5\u4e0b\u90fd\u4e0d\u4f1a\u5f71\u54cd\u5728\u7ebf\u4e1a\u52a1<\/p><\/blockquote>\n
\n\u5b89\u88c5\u4f7f\u7528<\/strong><\/p>\n