{"id":41,"date":"2001-01-01T10:10:10","date_gmt":"2001-01-01T02:10:10","guid":{"rendered":"http:\/\/www.q25.net\/?p=41"},"modified":"2019-03-28T09:57:50","modified_gmt":"2019-03-28T01:57:50","slug":"mysql5-6%e4%b8%8b%e4%b8%bb%e4%bb%8e%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"http:\/\/www.q25.net\/?p=41","title":{"rendered":"MySQL5.6\u4e0b\u4e3b\u4ece\u914d\u7f6e"},"content":{"rendered":"<p>\u672a\u4e86\u6570\u636e\u5b89\u5168\uff0c\u4e3b\u4ece\u914d\u7f6e\u53cc\u673a\u6700\u597d\u80fd\u5728\u4e00\u4e2a\u72ec\u7acb\u7684lan\u91cc\u9762\uff0c\u5982\u679c\u6ca1\u6709\u72ec\u7acblan\uff0c\u5c31\u505aVPN<br \/>\n\u5173\u4e8eMySQL5.6\u5b89\u88c5\u5c31\u4e0d\u518d\u91cd\u590d\u4e86\uff0c\u76f4\u63a5\u5f00\u59cb\u914d\u7f6e\u90e8\u5206<br \/>\n\u5f00\u59cb\u4e4b\u524d\uff0c\u5fc5\u987b\u4fdd\u6301\u4e24\u53f0\u673a\u5668\u7684\u6570\u636e\u5e93\u5185\u5bb9\u7248\u672c\u4e00\u81f4\uff0c\u540c\u65f6\u6240\u6709bin-log\u65e5\u5fd7\u90fd\u5df2\u7ecf\u6e05\u7a7a\uff0c\u4ee5\u514d\u51fa\u9519<\/p>\n<p>1.\u4fee\u6539\u4e3b\u670d\u52a1\u5668\/etc\/my.cnf \uff0c\u6dfb\u52a0\u4ee5\u4e0b\u90e8\u5206\u5230[mysqld]\u6bb5\u91cc\u9762<\/p>\n<p>bind_address=192.168.1.1<br \/>\nlog-bin=mysql-bin<br \/>\nexpire_logs_days=2<br \/>\nbinlog_format=MIXED<br \/>\nserver-id=1<\/p>\n<p>2.\u542f\u52a8\u4e3b\u670d\u52a1\u5668MySQL\uff0c\u5e76\u4e14\u5efa\u7acb\u8d26\u6237\u6388\u6743\u4ece\u670d\u52a1\u5668\u8fdb\u884c\u8fde\u63a5<br \/>\nmysql -uroot -p password<br \/>\nmysql>GRANT REPLICATION SLAVE ON *.* to &#8220;mysync&#8221;@&#8221;192.168.1.2&#8221; identified by &#8220;YYCCEEDLF&#8221;;<br \/>\n\u8868\u793a\u6388\u6743\u7ed9ip\u4e3a192.168.1.2\u7684\u5ba2\u6237\u7aef\u8fdb\u884c\u8fde\u63a5\uff0c\u7528\u6237\u540d\u4e3amysync\uff0c\u5bc6\u7801\u4e3aYYCCEEDLF<\/p>\n<p>3.\u4fee\u6539\u4ece\u670d\u52a1\u5668\u7684\/etc\/my.cnf\uff0c\u6dfb\u52a0\u4e00\u4e0b\u90e8\u5206\u5230[mysqld]\u6bb5\u91cc\u9762<br \/>\nbinlog_format=MIXED<br \/>\nlog-bin=slave-bin<br \/>\nserver-id=2<br \/>\nexpire_logs_days=2<br \/>\nslave-skip-errors = 1062,1194,1032<\/p>\n<p>4.\u542f\u52a8\u4ece\u670d\u52a1\u5668MySQL\uff0c\u8fde\u63a5\u4e3b\u670d\u52a1\u5668\u8bfb\u53d6log\u8fdb\u884c\u590d\u5236<br \/>\nmysql>change master to master_host=&#8221;192.168.1.1&#8243;,master_user=&#8221;mysync&#8221;,master_password=&#8221;YYCCEEDLF&#8221;;<br \/>\nmysql>start slave;<\/p>\n<p>5.\u68c0\u67e5\u4e00\u4e0b\u590d\u5236\u662f\u5426\u6210\u529f<br \/>\nmysql> show slave status\\G<\/p>\n<p> *************************** 1. row ***************************<\/p>\n<p>              Slave_IO_State: Waiting for master to send event<br \/>\n              Master_Host: 192.168.1.1  \/\/\u4e3b\u670d\u52a1\u5668\u5730\u5740<br \/>\n              Master_User: mysync   \/\/\u6388\u6743\u5e10\u6237\u540d\uff0c\u5c3d\u91cf\u907f\u514d\u4f7f\u7528root<br \/>\n              Master_Port: 3306    \/\/\u6570\u636e\u5e93\u7aef\u53e3\uff0c\u90e8\u5206\u7248\u672c\u6ca1\u6709\u6b64\u884c<br \/>\n              Connect_Retry: 60<br \/>\n              Master_Log_File: mysql-bin.000001<br \/>\n              Read_Master_Log_Pos: 13055363     \/\/#\u540c\u6b65\u8bfb\u53d6\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u4f4d\u7f6e\uff0c\u5927\u4e8e\u7b49\u4e8eExec_Master_Log_Pos<br \/>\n              Relay_Log_File: lc2-relay-bin.000002<br \/>\n              Relay_Log_Pos: 251<br \/>\n              Relay_Master_Log_File: mysql-bin.000001<br \/>\n              Slave_IO_Running: Yes    \/\/\u6b64\u72b6\u6001\u5fc5\u987bYES<br \/>\n              Slave_SQL_Running: Yes     \/\/\u6b64\u72b6\u6001\u5fc5\u987bYES<br \/>\n                    &#8230;&#8230;<\/p>\n<p>\u6ce8\uff1aSlave_IO\u53caSlave_SQL\u8fdb\u7a0b\u5fc5\u987b\u6b63\u5e38\u8fd0\u884c\uff0c\u5373YES\u72b6\u6001\uff0c\u5426\u5219\u90fd\u662f\u9519\u8bef\u7684\u72b6\u6001(\u5982\uff1a\u5176\u4e2d\u4e00\u4e2aNO\u5747\u5c5e\u9519\u8bef)\u3002<\/p>\n<p>\u4ee5\u4e0a\u64cd\u4f5c\u8fc7\u7a0b\uff0c\u4e3b\u4ece\u670d\u52a1\u5668\u914d\u7f6e\u5b8c\u6210\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672a\u4e86\u6570\u636e\u5b89\u5168\uff0c\u4e3b\u4ece\u914d\u7f6e\u53cc\u673a\u6700\u597d\u80fd\u5728\u4e00\u4e2a\u72ec&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.q25.net\/index.php?rest_route=\/wp\/v2\/posts\/41"}],"collection":[{"href":"http:\/\/www.q25.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.q25.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.q25.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.q25.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=41"}],"version-history":[{"count":4,"href":"http:\/\/www.q25.net\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":94,"href":"http:\/\/www.q25.net\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions\/94"}],"wp:attachment":[{"href":"http:\/\/www.q25.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.q25.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.q25.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}