{"id":1069,"date":"2020-05-01T12:25:18","date_gmt":"2020-05-01T04:25:18","guid":{"rendered":"https:\/\/www.wjxy.net.cn\/?p=1069"},"modified":"2023-10-04T06:32:51","modified_gmt":"2023-10-03T22:32:51","slug":"%e5%ae%9d%e5%a1%94lnmp-mysql%e4%b8%bb%e4%bb%8e%e5%90%8c%e6%ad%a5%e8%af%a6%e7%bb%86%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.wjxy.net.cn\/?p=1069","title":{"rendered":"\u5b9d\u5854LNMP mysql\u4e3b\u4ece\u540c\u6b65\u8be6\u7ec6\u6559\u7a0b"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p> \u4e3b\uff1a  <br> \/etc\/my.cnf <br>server_id = 1                #\u552f\u4e00\u6807\u8bc6\uff0c\u4e3b\u5e93\u4ece\u5e93\u4e0d\u80fd\u91cd\u590d<br> log_bin = mysql-bin          #\u5f00\u542f\u65e5\u5fd7<br> binlog_format=MIXED      \u3000\u3000 #\u65e5\u5fd7\u8bb0\u5f55\u7684\u683c\u5f0f<br> max_binlog_size = 512M  \u3000\u3000\u3000#\u5355\u4e2a\u65e5\u5fd7\u6587\u4ef6\u6700\u5927<br> expire_logs_day = 3          #\u65e5\u5fd7\u6709\u6548\u671f\uff08\u5929\uff09<br> binlog_do_db = test1,test2    #\u65e5\u5fd7\u8bb0\u5f55\u90a3\u4e9b\u6570\u636e\u5e93<br> binlog_ignore_db = mysql,performance_schema,information_schema #\u65e5\u5fd7\u8bb0\u5f55\u5ffd\u7565\u90a3\u4e9b\u6570\u636e\u5e93\u7684 <br>service mysql restart<br>mysql -p\u5bc6\u7801<br> <code><strong>grant replication slave on <\/strong><\/code><em><code><strong>.<\/strong><\/code><\/em><code><strong> to 'wjxy_net'@'%';<\/strong><\/code> <br><code>flush tables with read lock;<\/code><br><code>mysqldump -uroot -p wjxy_net&gt;\/root\/wjxy_net.sql;<\/code><br> show master status;                          \u8bb0\u4e0b Position \u548c File \u7684\u503c <\/p>\n\n\n\n<p><code>\u4ece\u5e93\u914d\u7f6e\/etc\/my.cnf\uff1a<\/code><br> server_id = 2<br> log_bin = mysql-bin        #\u5f00\u542f\u65e5\u5fd7<br> binlog_format=MIXED        #\u65e5\u5fd7\u8bb0\u5f55\u7684\u683c\u5f0f<br> max_binlog_size = 512M  \u3000\u3000 #\u5355\u4e2a\u65e5\u5fd7\u6587\u4ef6\u6700\u5927<br> expire_logs_day = 3    \u3000\u3000 #\u65e5\u5fd7\u6709\u6548\u671f\uff08\u5929\uff09<br> replicate_do_db = test1,test2 #\u662f\u5728slave\u4e0a\u914d\u7f6e\uff0c\u6307\u5b9aslave\u8981\u590d\u5236\u54ea\u4e2a\u5e93<br> replicate-ignore-db=mysql,performance_schema,information_schema #\u662f\u5728slave\u4e0a\u914d\u7f6e\uff0c\u6307\u5b9aslave\u8981\u5ffd\u7565\u54ea\u4e2a\u5e93<br> relay_log_recovery = 1  \u3000\u3000 #\u4ece\u5e93\u5efa\u8bae\u5f00\u542f\uff0c\u6709\u5229\u4e8e\u6570\u636e\u4e00\u81f4\u6027<br> log_slave_updates = 1   \u3000\u3000 #\u5982\u679c\u4ece\u5e93\u8fd8\u4f1a\u7528\u505a\u4e3b\u5e93\uff0c\u5efa\u8bae\u5f00\u542f <br> service mysql restart <br>scp root@\u4e3b\u5e93IP:\/root\/wjxy_net.sql \/root\/wjxy_net.sql<br> mysql -p\u5bc6\u7801 <br> stop slave; <br><code>mysql -uroot -p wjxy_net&lt;\/root\/wjxy_net.sql;<\/code><br>  change master to master_host=&#8217;wjxy.net.cn&#8217;, master_user=&#8217;wjxy_net&#8217;, master_password=&#8217;xxxxxx&#8217;, master_port=3306, master_log_file=&#8217;mysql-bin.000023&#8242;,  master_log_pos=2720;            \u6ce8\u610f\u4fee\u6539\u6700\u540e\u4e24\u9879<br> slave start; <br> \u4ece\u5e93\u6267\u884c\uff1a show slave status \u6216\u8005show slave statusG; \u67e5\u770b\u662f\u5426\u6b63\u5e38 <br> Slave_IO_Running: Yes<br> Slave_SQL_Running: Yes<br> Master_Log_File: mysql-bin.000023<br> Relay_Master_Log_File: mysql-bin.000023<br> Read_Master_Log_Pos: 2720<br> Exec_master_log_pos: 2720 <br>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br> \u6700\u540e\u56de\u5230\u4e3b\u5e93\u8f93\u5165  unlock tables; <br> show master status;                          \u8bb0\u4e0b \u73b0\u5728\u7684Position \u548c File \u7684\u503c <br>\u4ece\u5e93\u6267\u884c show slave statusG; \u6bd4\u5bf9\u540c\u6b65\u60c5\u51b5<\/p>\n\n\n\n<p><code><strong> set global read_only=1; \u4ece\u6570\u636e\u5e93\u8bbe\u7f6e\u53ea\u8bfb #1\u662f\u53ea\u8bfb\uff0c0\u662f\u8bfb\u5199<\/strong><\/code>\uff08\u5177\u4f53\u53c2\u8003\u8fd9\u7bc7\u6587\u7ae0\uff1a\u8bbe\u7f6emysql\u6570\u636e\u5e93\u4e3a\u53ea\u8bfb\uff09<\/p>\n\n\n\n<p><code><strong>show global variables like \"%read_only%\";<\/strong><\/code><strong>\u67e5\u8be2\u53ea\u8bfb\u8bbe\u7f6e\u662f\u5426\u5931\u6548<\/strong><\/p>\n\n\n\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-\u5206\u5272\u7ebf&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1\u3001\u5b89\u88c5\u597d\u4e3b\u6570\u636e\u5e93\u548c\u4ece\u6570\u636e\u5e93\uff0c\u8fd9\u4e2a\u5927\u5bb6\u80af\u5b9a\u90fd\u4f1a\uff0c\u5982\u679c\u4e0d\u662f\u5f88\u660e\u767d\uff0c\u53ef\u4ee5\u53c2\u8003\u6211\u524d\u9762\u7684\u5b89\u88c5\u6559\u7a0b\u3002<\/h2>\n\n\n\n<p>\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<p>\u3000\u3000\u5047\u5982\u6211\u9700\u8981\u540c\u6b65test1\u3001test2\u6570\u636e\u5e93&nbsp;<\/p>\n\n\n\n<p>\u3000\u3000\u7cfb\u7edf\uff1acentos7<\/p>\n\n\n\n<p>\u3000\u3000\u4e3b\u5e93\u4e3b\u673a\uff1a192.168.1.252&nbsp;<\/p>\n\n\n\n<p>\u3000\u3000\u4ece\u5e93\u4e3b\u673a\uff1a192.168.1.251&nbsp; &nbsp;<\/p>\n\n\n\n<p>\u3000\u3000\u7aef\u53e3\u90fd\u662f\uff1a3306<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2\u3001\u4e3b\u6570\u636e\u5e93\u57fa\u672c\u914d\u7f6e<\/h2>\n\n\n\n<p>\u3000\u3000(1)\u3001\u6253\u5f00\u4e3b\u6570\u636e\u7684\u914d\u7f6e\u6587\u4ef6\/etc\/my.cnf\uff0c\u6dfb\u52a0\u4fee\u6539\u8fd9\u51e0\u9879<\/p>\n\n\n\n<p class=\"has-text-color has-vivid-red-color\"><code>server_id = 1                #\u552f\u4e00\u6807\u8bc6\uff0c\u4e3b\u5e93\u4ece\u5e93\u4e0d\u80fd\u91cd\u590d<br> log_bin = mysql-bin          #\u5f00\u542f\u65e5\u5fd7<br> binlog_format=MIXED      \u3000\u3000 #\u65e5\u5fd7\u8bb0\u5f55\u7684\u683c\u5f0f<br> max_binlog_size = 512M  \u3000\u3000\u3000#\u5355\u4e2a\u65e5\u5fd7\u6587\u4ef6\u6700\u5927<br> expire_logs_day = 3          #\u65e5\u5fd7\u6709\u6548\u671f\uff08\u5929\uff09<br> binlog_do_db = test1,test2    #\u65e5\u5fd7\u8bb0\u5f55\u90a3\u4e9b\u6570\u636e\u5e93<br> binlog_ignore_db = mysql,performance_schema,information_schema #\u65e5\u5fd7\u8bb0\u5f55\u5ffd\u7565\u90a3\u4e9b\u6570\u636e\u5e93\u7684<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\uff082\uff09\u3001\u91cd\u542fmysql \uff08service mysql restart\uff09\n\uff083\uff09\u3001\u5728\u4e3b\u5e93\u521b\u5efa\u4e00\u4e2a\u7528\u4e8e\u540c\u6b65\u7684\u7528\u6237\uff08\u5f53\u7136\u4e5f\u53ef\u4ee5\u4e0d\u521b\u5efa\uff0c\u76f4\u63a5\u7528\u5df2\u6709\u7684\uff0c\u4e0d\u8fc7\u4e3a\u4e86\u5b89\u5168\u5efa\u8bae\u8fd8\u662f\u521b\u5efa\u4e00\u4e2a\uff09<strong>\uff08\u8fd9\u4e00\u6b65\u53ef\u4ee5\u5ffd\u7565\uff0c\u76f4\u63a5\u4f7f\u7528\u5b9d\u5854\u9762\u677f\u4e0a\u7684\u7528\u6237\u540d\u5bc6\u7801\uff09<\/strong>\n<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"252\" height=\"85\" src=\"https:\/\/www.wjxy.net.cn\/wp-content\/uploads\/2020\/05\/image.png\" alt=\"\" class=\"wp-image-1070\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\"><code> grant replication slave on *.* to 'slave'@'192.168.1.253' identified by '123456';<\/code>\n \u3000\u3000\u8fd9\u4e2aslave\u7528\u6237\u5bc6\u7801\u4e3a123456\uff0c\u4f46\u6709\u540c\u6b65\u7684\u6743\u9650\uff0c\u4e14\u53ea\u80fd\u5728192.168.1.253\u4e0a\u8fde\u63a5\u3002<\/pre>\n\n\n\n<p class=\"has-text-color has-vivid-red-color\"><code><strong>grant replication slave on <\/strong><\/code><em><code><strong>.<\/strong><\/code><\/em><code><strong> to 'wjxy_net'@'%';   \u8fd9\u91cc\u6211\u7528\u7684\u662f\u8fd9\u4e2a\u547d\u4ee4<\/strong><\/code><\/p>\n\n\n\n<p class=\"has-text-color has-vivid-red-color\">\u3000\u3000\u5982\u679c\u4e3b\u5e93\u91cc\u5df2\u7ecf\u6570\u636e\u5e93\u6570\u636e\u4e86\uff0c\u90a3\u8fd8\u5f97\u8fdb\u884c\u4ee5\u4e0b\u64cd\u4f5c<strong>\uff08root\u5bc6\u7801\u5e76\u975e\u7cfb\u7edfroot\u5bc6\u7801\uff0c\u800c\u662f\u5728\u5b9d\u5854\u91cc\u9762\u6570\u636e\u5e93\u83dc\u5355\u4e0b\u83b7\u53d6)<\/strong>\uff1a<\/p>\n\n\n\n<p><code>mysql -u root -p  \u6216\u8005 mysql -u root -p\u5bc6\u7801            \/\/p\u548c\u5bc6\u7801\u4e4b\u95f4\u4e0d\u53ef\u4ee5\u6709\u7a7a\u683c<\/code><\/p>\n\n\n\n<p>\n\n\u3000\u5237\u65b0\u8868\u7136\u540e\u9501\u8868\uff08\u53ea\u5141\u8bb8\u67e5\u6570\u636e\u4e0d\u5141\u8bb8\u5199\u6570\u636e\uff09\uff1a\n\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>flush tables with read lock;<\/code><\/pre>\n\n\n\n<p>\u3000\u3000\u3000\u3000\u7136\u540e\u5907\u4efd\u8981\u540c\u6b65\u7684\u6570\u636e\u5e93\u7684\u6570\u636e\uff0c\u7136\u540e\u62f7\u8d1d\u5230\u4ece\u5e93\u91cc\u9762<br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mysqldump -uroot -p test1&gt;test1.sql;\nmysqldump -uroot -p test2&gt;test2.sql;\n#\u4ece\u5e93\u8981\u5148\u521b\u5efa\u6570\u636e\u5e93test1\u548ctest2,\u7136\u540e\u5bfc\u5165\u6570\u636e\nmysql -uroot -p test1&lt;test1.sql;\nmysql -uroot -p test1&lt;test2.sql;<\/code><\/pre>\n\n\n\n<p>\u4e3b\u5e93\u6267\u884c\uff1ashow master status; \u8bb0\u4e0b Position \u548c File \u7684\u503c\uff0c\u7b49\u4e0b\u8fdb\u884c\u4ece\u5e93\u914d\u7f6e\u8981\u7528\u5230\u3002<\/p>\n\n\n\n<p>\u3000\u3000+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br>\u3000\u3000| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |<br>\u3000\u3000+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br>\u3000\u3000| mysql-bin.000023 | 2720 | test1,test2 | mysql&nbsp;<br>\u3000\u3000+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3\u3001\u4ece\u5e93\u914d\u7f6e\u4fe1\u606f<\/h2>\n\n\n\n<p>\u3000\u3000\uff081\uff09\u3001\u4fee\u6539\u914d\u7f6e\u6587\u4ef6my.cnf&#8217;<\/p>\n\n\n\n<p><code>server_id = 2<br> log_bin = mysql-bin        #\u5f00\u542f\u65e5\u5fd7<br> binlog_format=MIXED        #\u65e5\u5fd7\u8bb0\u5f55\u7684\u683c\u5f0f<br> max_binlog_size = 512M  \u3000\u3000 #\u5355\u4e2a\u65e5\u5fd7\u6587\u4ef6\u6700\u5927<br> expire_logs_day = 3    \u3000\u3000 #\u65e5\u5fd7\u6709\u6548\u671f\uff08\u5929\uff09<br> replicate_do_db = test1,test2 #\u662f\u5728slave\u4e0a\u914d\u7f6e\uff0c\u6307\u5b9aslave\u8981\u590d\u5236\u54ea\u4e2a\u5e93<br> replicate-ignore-db=mysql,performance_schema,information_schema #\u662f\u5728slave\u4e0a\u914d\u7f6e\uff0c\u6307\u5b9aslave\u8981\u5ffd\u7565\u54ea\u4e2a\u5e93<br> relay_log_recovery = 1  \u3000\u3000 #\u4ece\u5e93\u5efa\u8bae\u5f00\u542f\uff0c\u6709\u5229\u4e8e\u6570\u636e\u4e00\u81f4\u6027<br> log_slave_updates = 1   \u3000\u3000 #\u5982\u679c\u4ece\u5e93\u8fd8\u4f1a\u7528\u505a\u4e3b\u5e93\uff0c\u5efa\u8bae\u5f00\u542f<\/code><\/p>\n\n\n\n<p>\u3000\u3000(2)\u3001\u91cd\u542f\u4ece\u5e93\uff0c\u6267\u884c\u5982\u4e0b\u547d\u4ee4(\u5148\u505c\u6b62\u540c\u6b65\uff0c\u7136\u540e\u8bbe\u7f6e\u540c\u6b65\u4fe1\u606f\uff0cmaster_log_file \u548c master_log_pos\u5c31\u662f\u6211\u4eec\u4e3b\u5e93\u4e0a\u9762\u7684)<\/p>\n\n\n\n<p>stop slave;<br> change master to<br> master_host=&#8217;192.168.1.252&#8242;,<br> master_user=&#8217;slave&#8217;,<br> master_password=&#8217;123456&#8242;,<br> master_port=3306,<br> master_log_file=&#8217;mysql-bin.000023&#8242;, <br> master_log_pos=2720;<br> slave start;<\/p>\n\n\n\n<p>\u3000\u3000\uff083\uff09\u3001\u4ece\u5e93\u6267\u884c\uff1ashow slave statusG; \u67e5\u770b\u662f\u5426\u6b63\u5e38, \u4e3b\u8981\u770b\u8fd9\u51e0\u9879: <\/p>\n\n\n\n<p> Slave_IO_Running: Yes<br> Slave_SQL_Running: Yes<br> Master_Log_File: mysql-bin.000023<br> Relay_Master_Log_File: mysql-bin.000023<br> Read_Master_Log_Pos: 2720<br> Exec_master_log_pos: 2720<\/p>\n\n\n\n<p>4\u3001\u6700\u540e\u56de\u5230\u4e3b\u5e93\u89e3\u9501\u8868\u3000<\/p>\n\n\n\n<p><code>unlock tables;<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5\u3001\u4e3b\u4ece\u4e0d\u540c\u6b65\u4e86\u89e3\u51b3\u529e\u6cd5<\/h2>\n\n\n\n<p>\u65b9\u6cd5\u4e00\uff1a\u5ffd\u7565\u9519\u8bef\u540e\uff0c\u7ee7\u7eed\u540c\u6b65<br>\u3000\u3000\u8be5\u65b9\u6cd5\u9002\u7528\u4e8e\u4e3b\u4ece\u5e93\u6570\u636e\u76f8\u5dee\u4e0d\u5927\uff0c\u6216\u8005\u8981\u6c42\u6570\u636e\u53ef\u4ee5\u4e0d\u5b8c\u5168\u7edf\u4e00\u7684\u60c5\u51b5\uff0c\u6570\u636e\u8981\u6c42\u4e0d\u4e25\u683c\u7684\u60c5\u51b5<br>\u3000\u3000\u89e3\u51b3\uff1a<br>\u3000\u3000\u3000<code>\u3000stop slave; #\u8868\u793a\u8df3\u8fc7\u4e00\u6b65\u9519\u8bef\uff0c\u540e\u9762\u7684\u6570\u5b57\u53ef\u53d8<br>\u3000\u3000\u3000\u3000set global sql_slave_skip_counter =1;<br>\u3000\u3000\u3000\u3000start slave;<br>\u3000\u3000\u4e4b\u540e\u518d\u7528mysql&gt; show slave statusG \u67e5\u770b\uff1a<br>\u3000\u3000Slave_IO_Running: Yes<br>\u3000\u3000Slave_SQL_Running: Yes<\/code><\/p>\n\n\n\n<p>\u65b9\u5f0f\u4e8c\uff1a\u91cd\u65b0\u505a\u4e3b\u4ece\uff0c\u5b8c\u5168\u540c\u6b65<br>\u3000\u3000\u8be5\u65b9\u6cd5\u9002\u7528\u4e8e\u4e3b\u4ece\u5e93\u6570\u636e\u76f8\u5dee\u8f83\u5927\uff0c\u6216\u8005\u8981\u6c42\u6570\u636e\u5b8c\u5168\u7edf\u4e00\u7684\u60c5\u51b5<br>\u3000\u3000\u89e3\u51b3\u6b65\u9aa4\u5982\u4e0b\uff1a<br>\u3000\u3000\u3000\u30001.\u5148\u8fdb\u5165\u4e3b\u5e93\uff0c\u8fdb\u884c\u9501\u8868\uff0c\u9632\u6b62\u6570\u636e\u5199\u5165<br>\u3000\u3000\u3000\u3000\u4f7f\u7528\u547d\u4ee4\uff1a<br>\u3000\u3000\u3000\u3000<code>mysql&gt; flush tables with read lock;<\/code><br>\u3000\u3000\u3000\u3000\u6ce8\u610f\uff1a\u8be5\u5904\u662f\u9501\u5b9a\u4e3a\u53ea\u8bfb\u72b6\u6001\uff0c\u8bed\u53e5\u4e0d\u533a\u5206\u5927\u5c0f\u5199<br>\u3000\u3000\u3000\u30002.\u8fdb\u884c\u6570\u636e\u5907\u4efd<br>\u3000\u3000\u3000\u3000\u3000\u3000#\u628a\u6570\u636e\u5907\u4efd\u5230mysql.bak.sql\u6587\u4ef6<br>\u3000\u3000\u3000\u3000\u3000\u3000<code>mysqldump -uroot -p -hlocalhost &gt; mysql.bak.sql<\/code><br>\u3000\u3000\u3000\u3000\u3000\u3000\u8fd9\u91cc\u6ce8\u610f\u4e00\u70b9\uff1a\u6570\u636e\u5e93\u5907\u4efd\u4e00\u5b9a\u8981\u5b9a\u671f\u8fdb\u884c\uff0c\u53ef\u4ee5\u7528shell\u811a\u672c\u6216\u8005python\u811a\u672c\uff0c\u90fd\u6bd4\u8f83\u65b9\u4fbf\uff0c\u786e\u4fdd\u6570\u636e\u4e07\u65e0\u4e00\u5931<br>\u3000\u3000\u3000\u30003.\u67e5\u770bmaster \u72b6\u6001<br>\u3000\u3000\u3000\u3000\u3000\u3000<code>mysql&gt; show master status;<\/code><br>\u3000\u3000\u3000\u3000\u3000\u3000+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br>\u3000\u3000\u3000\u3000\u3000\u3000| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |<br>\u3000\u3000\u3000\u3000\u3000\u3000+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br>\u3000\u3000\u3000\u3000\u3000\u3000| mysqld-bin.000001 | 3260 | | mysql,test,information_schema |<br>\u3000\u3000\u3000\u3000\u3000\u3000+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br><br>\u3000\u3000\u3000\u30004.\u628amysql\u5907\u4efd\u6587\u4ef6\u4f20\u5230\u4ece\u5e93\u673a\u5668\uff0c\u8fdb\u884c\u6570\u636e\u6062\u590d<br>\u3000\u3000\u3000\u3000\u3000\u3000#\u4f7f\u7528scp\u547d\u4ee4<br>\u3000\u3000\u3000\u3000\u3000<code>\u3000[root@server01 mysql]# scp mysql.bak.sql root@192.168.128.101:\/tmp\/<\/code><br>\u3000\u3000\u3000\u30005.\u505c\u6b62\u4ece\u5e93\u7684\u72b6\u6001<br>\u3000\u3000\u3000\u3000\u3000<code>\u3000mysql&gt; stop slave;<\/code><br>\u3000\u3000\u3000\u30006.\u7136\u540e\u5230\u4ece\u5e93\u6267\u884cmysql\u547d\u4ee4\uff0c\u5bfc\u5165\u6570\u636e\u5907\u4efd<br>\u3000\u3000\u3000\u3000\u3000\u3000<code>mysql&gt; source \/tmp\/mysql.bak.sql<\/code><br>\u3000\u3000\u3000\u30007.\u8bbe\u7f6e\u4ece\u5e93\u540c\u6b65\uff0c\u6ce8\u610f\u8be5\u5904\u7684\u540c\u6b65\u70b9\uff0c\u5c31\u662f\u4e3b\u5e93show master status\u4fe1\u606f\u91cc\u7684| File| Position\u4e24\u9879<br>\u3000\u3000\u3000\u3000\u3000\u3000<code>change master to master_host = '192.168.128.100', master_user = 'rsync', master_port=3306, master_password='', master_log_file = 'mysqld-bin.000001', master_log_pos=3260;<\/code><br>\u3000\u3000\u3000\u30008.\u91cd\u65b0\u5f00\u542f\u4ece\u540c\u6b65<br>\u3000\u3000\u3000\u3000\u3000\u3000<code>mysql&gt; start slave;<\/code><br>\u3000\u3000\u3000\u30009.\u67e5\u770b\u540c\u6b65\u72b6\u6001<br>\u3000\u3000\u3000\u3000\u3000\u3000<code>mysql&gt; show slave statusG \u67e5\u770b\uff1a<br>\u3000\u3000\u3000\u3000\u3000\u3000Slave_IO_Running: Yes<br>\u3000\u3000\u3000\u3000\u3000\u3000Slave_SQL_Running: Yes<\/code><\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10.\u4e3b\u5e93\u89e3\u9501<\/p>\n\n\n\n<p>\u3000\u3000\u3000<code>\u3000mysql&gt;&nbsp;unlock tables;<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6\u3001pt-table-checksum \u548c pt-table-sync<\/h2>\n\n\n\n<p>\u3000\u3000\u8fd9\u4e2a\u4e24\u4e2a\u8f6f\u4ef6\u4e5f\u662f\u5f88\u65b9\u4fbf\uff0c\u5927\u5bb6\u53ef\u4ee5\u53bb\u4e86\u89e3\u4e00\u4e0b<\/p>\n\n\n\n<p>\u3000\u3000pt-table-checksum\uff1a\u5728\u4e3b\uff08master\uff09\u4e0a\u901a\u8fc7\u6267\u884c\u6821\u9a8c\u7684\u67e5\u8be2\u5bf9\u590d\u5236\u7684\u4e00\u81f4\u6027\u8fdb\u884c\u68c0\u67e5\uff0c\u5bf9\u6bd4\u4e3b\u4ece\u7684\u6821\u9a8c\u503c\uff0c\u4ece\u800c\u4ea7\u751f\u7ed3\u679c\u3002DSN\u6307\u5411\u7684\u662f\u4e3b\u7684\u5730\u5740\uff0c\u8be5\u5de5\u5177\u7684\u9000\u51fa\u72b6\u6001\u4e0d\u4e3a\u96f6\uff0c\u5982\u679c\u53d1\u73b0\u6709\u4efb\u4f55\u5dee\u522b\uff0c\u6216\u8005\u5982\u679c\u51fa\u73b0\u4efb\u4f55\u8b66\u544a\u6216\u9519\u8bef\uff0c\u66f4\u591a\u4fe1\u606f\u8bf7\u67e5\u770b\u5b98\u65b9\u8d44\u6599\u3002<br>\u3000\u3000pt-table-sync: \u9ad8\u6548\u7684\u540c\u6b65MySQL\u8868\u4e4b\u95f4\u7684\u6570\u636e\uff0c\u4ed6\u53ef\u4ee5\u505a\u5355\u5411\u548c\u53cc\u5411\u540c\u6b65\u7684\u8868\u6570\u636e\u3002\u4ed6\u53ef\u4ee5\u540c\u6b65\u5355\u4e2a\u8868\uff0c\u4e5f\u53ef\u4ee5\u540c\u6b65\u6574\u4e2a\u5e93\u3002\u5b83\u4e0d\u540c\u6b65\u8868\u7ed3\u6784\u3001\u7d22\u5f15\u3001\u6216\u4efb\u4f55\u5176\u4ed6\u6a21\u5f0f\u5bf9\u8c61\u3002\u6240\u4ee5\u5728\u4fee\u590d\u4e00\u81f4\u6027\u4e4b\u524d\u9700\u8981\u4fdd\u8bc1\u4ed6\u4eec\u8868\u5b58\u5728\u3002<\/p>\n\n\n\n<p><br><\/p>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3b\uff1a \/etc\/my.cnf server_id = 1 #\u552f\u4e00\u6807\u8bc6\uff0c\u4e3b\u5e93\u4ece\u5e93\u4e0d\u80fd\u91cd\u590d log_bin = m [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/1069"}],"collection":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1069"}],"version-history":[{"count":7,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/1069\/revisions"}],"predecessor-version":[{"id":2878,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/1069\/revisions\/2878"}],"wp:attachment":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}