{"id":112432,"date":"2018-07-29T08:00:43","date_gmt":"2018-07-29T00:00:43","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=112432"},"modified":"2018-07-24T13:13:48","modified_gmt":"2018-07-24T05:13:48","slug":"mysql-binlog-delete","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/mysql-binlog-delete.html","title":{"rendered":"\u8be6\u89e3\uff1aMysql binlog \u5b89\u5168\u5220\u9664\u5b9e\u4f8b"},"content":{"rendered":"
\u5982\u679c\u4f60\u7684 Mysql \u642d\u5efa\u4e86\u4e3b\u4ece\u540c\u6b65 , \u6216\u8005\u6570\u636e\u5e93\u5f00\u542f\u4e86 log-bin \u65e5\u5fd7 , \u90a3\u4e48\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb , \u4f60\u7684\u6570\u636e\u5e93 data \u76ee\u5f55\u4e0b\u4f1a\u4ea7\u751f\u5927\u91cf\u7684\u65e5\u5fd7\u6587\u4ef6<\/p>\n
\r\nshell > ll \/usr\/local\/mysql\/data\/ # \u5982\u4e0b \r\n-rw-rw----. 1 mysql mysql 63278 9\u6708 11 02:03 mysql-bin.000001 \r\n-rw-rw----. 1 mysql mysql 1096670 9\u6708 11 02:03 mysql-bin.000002 \r\n-rw-rw----. 1 mysql mysql 133 9\u6708 11 02:04 mysql-bin.000003 \r\n-rw-rw----. 1 mysql mysql 133 9\u6708 12 02:00 mysql-bin.000004 \r\n-rw-rw----. 1 mysql mysql 271 9\u6708 12 18:25 mysql-bin.000005 \r\n-rw-rw----. 1 mysql mysql 133 9\u6708 12 18:55 mysql-bin.000006 \r\n-rw-rw----. 1 mysql mysql 133 9\u6708 12 19:48 mysql-bin.000007 \r\n-rw-rw----. 1 mysql mysql 133 9\u6708 12 21:21 mysql-bin.000008 \r\n-rw-rw----. 1 mysql mysql 321 11\u6708 18 17:30 mysql-bin.000009 \r\n<\/pre>\n\u7531\u4e8e\u6211\u7684\u662f\u6d4b\u8bd5\u73af\u5883 , \u6240\u4ee5\u6587\u4ef6\u8fd8\u5f88\u5c0f , \u751f\u4ea7\u73af\u5883\u4e2d\u8fd9\u4e9b\u6587\u4ef6\u5982\u679c\u4e0d\u505a\u5904\u7406\u7684\u8bdd , \u751a\u81f3\u4f1a\u6491\u7206\u4f60\u7684\u78c1\u76d8<\/p>\n
\u4e0b\u9762\u6765\u4ecb\u7ecd\u51e0\u79cd\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n
\r\n~~> \u5982\u679c\u4f60\u7684\u6570\u636e\u5e93\u6ca1\u6709\u642d\u5efa\u4e3b\u4ece\u540c\u6b65\u8fd9\u6837\u7684\u670d\u52a1 , binlog \u65e5\u5fd7\u4e5f\u4e0d\u7528\u7684\u60c5\u51b5\u4e0b , \u4f60\u53ef\u4ee5\u5c06 \/etc\/my.cnf \u6587\u4ef6\u4e0b\u9762\u884c\u5220\u9664\u6216\u6ce8\u91ca\u6389\r\n\r\nlog-bin=mysql-bin\r\n~~> \u5982\u679c\u4f60\u9700\u8981\u8fd9\u6837\u7684\u6587\u4ef6 , \u90a3\u4e48\u5efa\u8bae\u4f60\u5728\u4e3b\u914d\u7f6e\u6587\u4ef6 \/etc\/my.cnf \u4e2d\u6dfb\u52a0\u5982\u4e0b\u884c , \u6765\u9650\u5236 binlog \u65e5\u5fd7\u6587\u4ef6\u5b58\u5728\u65f6\u95f4 , \u8fc7\u671f\u81ea\u52a8\u5220\u9664\r\n\r\nexpire_logs_days = 7 # \u53ea\u4fdd\u7559 7 \u5929\u7684\u65e5\u5fd7\u6587\u4ef6\r\n~~> \u5982\u679c\u4f60\u76f4\u63a5\u5f97\u5230\u4e00\u53f0\u670d\u52a1\u5668 , \u4e0a\u9762\u7684 binlog \u65e5\u5fd7\u5df2\u7ecf\u5f71\u54cd\u5230\u4e86\u78c1\u76d8\u7a7a\u95f4 , \u90a3\u4e48\u4f60\u5c06\u4f7f\u7528\u4e0b\u9762\u547d\u4ee4\u6e05\u9664\r\n\r\nmysql> reset master; # \u6e05\u7a7a\u6240\u6709 binlog \u6587\u4ef6\r\n\r\n<\/pre>\n\u5982\u679c\u4f60\u7684\u5f97\u5230\u7684\u670d\u52a1\u5668 , mysql \u8fd8\u505a\u4e86\u4e3b\u4ece\u540c\u6b65 , \u90a3\u4e48\u4e0a\u9762\u7684\u547d\u4ee4\u5c31\u4e0d\u9002\u5408\u4f60\u4e86 , \u56e0\u4e3a binlog \u6587\u4ef6\u5220\u9664\u8fc7\u591a\u7684\u8bdd , \u4f1a\u5bfc\u81f4\u6570\u636e\u4e0d\u540c\u6b65<\/p>\n
\r\nmysql> show slave status\\G # \u4f60\u9996\u5148\u8981\u6765 slave \u4e0a\u67e5\u770b\u4ece\u5e93\u8bfb binlog \u5230\u4e86\u54ea\u91cc \r\nMaster_Log_File: mysql-bin.000009 # \u6211\u4eec\u53ef\u4ee5\u770b\u5230\u662f mysql-bin.000009\r\n\r\nmysql> purge master logs to 'mysql-bin.000009'; # \u6211\u4eec\u53ef\u4ee5\u5728 master \u4e2d\u6267\u884c\u8fd9\u6761\u6307\u4ee4 , \u5c06 binlog \u6587\u4ef6\u5220\u9664\u81f3 mysql-bin.000009 \u524d\r\n\r\nmysql> purge master logs before '2014-11-18 00:00:00'; # \u5c06 binlog \u6587\u4ef6\u5220\u9664\u81f3\u6b64\u65e5\u671f\u524d\r\n<\/pre>\n\n\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/www.cnblogs.com\/wangxiaoqiangs\/p\/5336273.html<\/a><\/p>\n