{"id":6154,"date":"2014-02-26T13:57:46","date_gmt":"2014-02-26T05:57:46","guid":{"rendered":"http:\/\/jpuyy.com\/?p=6154"},"modified":"2014-02-26T13:58:42","modified_gmt":"2014-02-26T05:58:42","slug":"mysql-binlog-parameters","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=6154","title":{"rendered":"mysql binlog\u53c2\u6570\u8bbe\u5b9a"},"content":{"rendered":"<p>mysql\u4f7f\u7528binlog\u7684\u597d\u5904\u5c31\u662f\u5f88\u7075\u6d3b\u7684\u8fdb\u884c\u6570\u636e\u6062\u590d<\/p>\n<p>binlog\u8bbe\u5b9a\u4e0d\u5bf9\u4f1a\u4f7f\u78c1\u76d8\u7528\u6ee1\u62a5\u9519\uff0c\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\u9996\u5148\u5c06\u6570\u636e\u5e93\u91cc\u7684binlog\u6e05\u7406<\/p>\n<p>\u6839\u636ebinlog\u540d\u8fdb\u884c\u4e4b\u524d\u7684\u5220\u9664<\/p>\n<pre>PURGE {MASTER | BINARY} LOGS TO 'log_name';<\/pre>\n<p>\u4f8b\uff1a\u5220\u9664mysql-bin.000123\u4e4b\u524d\u7684binlog<\/p>\n<pre>PURGE MASTER LOGS TO 'mysql-bin.000123';<\/pre>\n<p>\u6839\u636ebinlog\u4fdd\u7559\u7684\u65f6\u95f4\u8fdb\u884c\u5220\u9664<\/p>\n<pre>PURGE {MASTER | BINARY} LOGS BEFORE 'date';<\/pre>\n<p>\u4f8b\u5220\u96642014-02-19 22:46:26\u4e4b\u524d\u7684binlog<\/p>\n<pre>PURGE MASTER LOGS BEFORE '2014-02-19 22:46:26';<\/pre>\n<p>\u5220\u96647\u5929\u524d\u7684binlog<\/p>\n<pre>PURGE MASTER LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 7 DAY);<\/pre>\n<p>\u6545\u969c\u5904\u7406\u5b8c\u4e86\uff0c\u73b0\u5728\u8981\u5bf9mysql\u7684binlog\u4fdd\u7559\u65f6\u95f4\u8fdb\u884c\u8c03\u6574<\/p>\n<p>\u53ef\u5728my.cnf\u4e2d\u8bbe\u5b9a\u53c2\u6570\uff0c\u91cd\u542fmysql<\/p>\n<pre>expire_logs_days = 7<\/pre>\n<p>\u4e0d\u80fd\u91cd\u542fmysql\uff0c\u5219\u9700\u8981\u5728mysql\u547d\u4ee4\u884c\u4e2d\u8bbe\u7f6e\uff0c\u9700\u8981flush logs\uff0c\u5426\u5219\u53c2\u6570\u4e0d\u751f\u6548\u8fc7\u4e9b\u5929\u53c8\u4f1a\u7528\u6ee1<\/p>\n<pre>mysql&gt; set global expire_logs_days = 7;\r\nmysql&gt; flush logs;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>mysql\u4f7f\u7528binlog\u7684\u597d\u5904\u5c31\u662f\u5f88\u7075\u6d3b\u7684\u8fdb\u884c\u6570\u636e\u6062\u590d binlog\u8bbe\u5b9a\u4e0d\u5bf9\u4f1a\u4f7f\u78c1\u76d8\u7528\u6ee1\u62a5\u9519\uff0c\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\u9996\u5148\u5c06\u6570\u636e\u5e93\u91cc\u7684binlog\u6e05\u7406 \u6839\u636ebinlog\u540d\u8fdb\u884c\u4e4b\u524d\u7684\u5220\u9664 PURGE {MASTER | BINARY} LOGS TO &#8216;log_name&#8217;; \u4f8b\uff1a\u5220\u9664mysql-bin.000123\u4e4b\u524d\u7684binlog PURGE MASTER LOGS TO &#8216;mysql-bin.000123&#8217;; \u6839\u636ebinlog\u4fdd\u7559\u7684\u65f6\u95f4\u8fdb\u884c\u5220\u9664 PURGE {MASTER | BINARY} LOGS BEFORE &#8216;date&#8217;; \u4f8b\u5220\u96642014-02-19 22:46:26\u4e4b\u524d\u7684binlog PURGE MASTER LOGS BEFORE &#8216;2014-02-19 22:46:26&#8217;; \u5220\u96647\u5929\u524d\u7684binlog PURGE MASTER LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 7 DAY); \u6545\u969c\u5904\u7406\u5b8c\u4e86\uff0c\u73b0\u5728\u8981\u5bf9mysql\u7684binlog\u4fdd\u7559\u65f6\u95f4\u8fdb\u884c\u8c03\u6574 \u53ef\u5728my.cnf\u4e2d\u8bbe\u5b9a\u53c2\u6570\uff0c\u91cd\u542fmysql expire_logs_days = 7 \u4e0d\u80fd\u91cd\u542fmysql\uff0c\u5219\u9700\u8981\u5728mysql\u547d\u4ee4\u884c\u4e2d\u8bbe\u7f6e\uff0c\u9700\u8981flush logs\uff0c\u5426\u5219\u53c2\u6570\u4e0d\u751f\u6548\u8fc7\u4e9b\u5929\u53c8\u4f1a\u7528\u6ee1 mysql&gt; set global expire_logs_days = [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[65],"tags":[],"class_list":["post-6154","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/6154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6154"}],"version-history":[{"count":2,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/6154\/revisions"}],"predecessor-version":[{"id":6156,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/6154\/revisions\/6156"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}