{"id":16061,"date":"2024-11-18T08:03:02","date_gmt":"2024-11-18T00:03:02","guid":{"rendered":"https:\/\/fwq.ai\/blog\/16061\/"},"modified":"2024-11-18T08:03:02","modified_gmt":"2024-11-18T00:03:02","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8linux%e4%b8%8a%e9%85%8d%e7%bd%ae%e9%ab%98%e5%8f%af%e7%94%a8%e6%95%b0%e6%8d%ae%e5%ba%93%e9%9b%86%e7%be%a4","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/16061\/","title":{"rendered":"\u5982\u4f55\u5728Linux\u4e0a\u914d\u7f6e\u9ad8\u53ef\u7528\u6570\u636e\u5e93\u96c6\u7fa4"},"content":{"rendered":"<p>\u5982\u4f55\u5728linux\u4e0a\u914d\u7f6e\u9ad8\u53ef\u7528\u6570\u636e\u5e93\u96c6\u7fa4<\/p>\n<p>\u4e00\u3001\u5f15\u8a00<br \/>\u968f\u7740\u4f01\u4e1a\u6570\u636e\u7684\u4e0d\u65ad\u589e\u957f\uff0c\u6570\u636e\u5e93\u7684\u9ad8\u53ef\u7528\u6027\u53d8\u5f97\u8d8a\u6765\u8d8a\u91cd\u8981\u3002\u9ad8\u53ef\u7528\u6570\u636e\u5e93\u96c6\u7fa4\u80fd\u591f\u63d0\u4f9b\u6301\u7eed\u53ef\u9760\u7684\u6570\u636e\u8bbf\u95ee\uff0c\u786e\u4fdd\u4e1a\u52a1\u7684\u8fde\u7eed\u8fd0\u884c\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728Linux\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u914d\u7f6e\u9ad8\u53ef\u7528\u6570\u636e\u5e93\u96c6\u7fa4\uff0c\u5e76\u63d0\u4f9b\u76f8\u5e94\u7684\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<p>\u4e8c\u3001\u51c6\u5907\u5de5\u4f5c<br \/>\u5728\u5f00\u59cb\u914d\u7f6e\u9ad8\u53ef\u7528\u6570\u636e\u5e93\u96c6\u7fa4\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u51c6\u5907\u5de5\u4f5c\u3002<\/p>\n<ol>\n<li>\u5b89\u88c5\u64cd\u4f5c\u7cfb\u7edf\uff1a\u9009\u62e9\u4e00\u79cd\u7a33\u5b9a\u53ef\u9760\u7684Linux\u53d1\u884c\u7248\uff0c\u4f8b\u5982CentOS\u3001Ubuntu\u7b49\uff0c\u5e76\u6309\u7167\u5b98\u65b9\u6587\u6863\u8fdb\u884c\u5b89\u88c5\u3002<\/li>\n<li>\u5b89\u88c5\u6570\u636e\u5e93\u8f6f\u4ef6\uff1a\u9009\u62e9\u4e00\u79cd\u6210\u719f\u7a33\u5b9a\u7684\u6570\u636e\u5e93\u8f6f\u4ef6\uff0c\u4f8b\u5982MySQL\u3001PostgreSQL\u7b49\uff0c\u5e76\u6309\u7167\u5b98\u65b9\u6587\u6863\u8fdb\u884c\u5b89\u88c5\u3002<\/li>\n<li>\u914d\u7f6e\u7f51\u7edc\uff1a\u786e\u4fdd\u96c6\u7fa4\u4e2d\u7684\u5404\u4e2a\u8282\u70b9\u53ef\u4ee5\u76f8\u4e92\u901a\u4fe1\uff0c\u5efa\u8bae\u4f7f\u7528\u9759\u6001IP\u6765\u907f\u514dIP\u5730\u5740\u7684\u53d8\u52a8\u3002<\/li>\n<li>\u521b\u5efa\u6570\u636e\u5e93\u7528\u6237\uff1a\u521b\u5efa\u4e00\u4e2a\u4e13\u95e8\u7528\u4e8e\u96c6\u7fa4\u6570\u636e\u540c\u6b65\u7684\u6570\u636e\u5e93\u7528\u6237\uff0c\u5e76\u4e3a\u5176\u8bbe\u7f6e\u5408\u9002\u7684\u6743\u9650\u3002<\/li>\n<\/ol>\n<p>\u4e09\u3001\u914d\u7f6e\u6570\u636e\u5e93\u96c6\u7fa4<br \/>\u4ee5\u4e0b\u4ecb\u7ecd\u4e00\u79cd\u5e38\u89c1\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u67b6\u6784\u2014\u2014\u4e3b\u5907\u590d\u5236\u6a21\u5f0f\uff0c\u5176\u4e2d\u4e00\u4e2a\u8282\u70b9\u4e3a\u4e3b\u8282\u70b9\uff0c\u8d1f\u8d23\u5904\u7406\u8bfb\u5199\u8bf7\u6c42\uff0c\u5176\u4ed6\u8282\u70b9\u4e3a\u5907\u8282\u70b9\uff0c\u7528\u4e8e\u6570\u636e\u5907\u4efd\u548c\u6545\u969c\u5207\u6362\u3002<\/p>\n<ol>\n<li>\u521b\u5efa\u4e3b\u8282\u70b9<br \/>\u9996\u5148\uff0c\u5728\u4e3b\u8282\u70b9\u4e0a\u8fdb\u884c\u914d\u7f6e\u3002<\/li>\n<\/ol>\n<p>\u7f16\u8f91\u6570\u636e\u5e93\u914d\u7f6e\u6587\u4ef6my.cnf\uff0c\u627e\u5230\u4ee5\u4e0b\u90e8\u5206\uff1a<\/p>\n<pre>[mysqld]\nserver-id=1\nlog-bin=mysql-bin<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8bbe\u7f6eserver-id\u4e3a\u4e00\u4e2a\u552f\u4e00\u7684\u503c\uff0c\u4ee5\u6807\u8bc6\u4e3b\u8282\u70b9\u3002<\/p>\n<p>\u91cd\u542f\u6570\u636e\u5e93\u670d\u52a1\uff1a<\/p>\n<pre>service mysql restart<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    \u767b\u5f55\u540e\u590d\u5236    \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u521b\u5efa\u5907\u8282\u70b9<br \/>\u63a5\u4e0b\u6765\uff0c\u5728\u5907\u8282\u70b9\u4e0a\u8fdb\u884c\u914d\u7f6e\u3002<\/li>\n<\/ol>\n<p>\u7f16\u8f91\u6570\u636e\u5e93\u914d\u7f6e\u6587\u4ef6my.cnf\uff0c\u627e\u5230\u4ee5\u4e0b\u90e8\u5206\uff1a<\/p>\n<pre>[mysqld]\nserver-id=2\nlog-bin=mysql-bin<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8bbe\u7f6eserver-id\u4e3a\u4e00\u4e2a\u552f\u4e00\u7684\u503c\uff0c\u4ee5\u6807\u8bc6\u5907\u8282\u70b9\u3002<\/p>\n<p>\u91cd\u542f\u6570\u636e\u5e93\u670d\u52a1\uff1a<\/p>\n<pre>service mysql restart<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    \u767b\u5f55\u540e\u590d\u5236    \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<ol>\n<li>\u914d\u7f6e\u4e3b\u5907\u540c\u6b65<br \/>\u5728\u4e3b\u8282\u70b9\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<\/ol>\n<pre>GRANT REPLICATION SLAVE ON *.* TO 'replication_user'@'\u5907\u8282\u70b9IP' IDENTIFIED BY '\u5bc6\u7801';\nFLUSH PRIVILEGES;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5c06replication_user\u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u6570\u636e\u5e93\u7528\u6237\u540d\uff0c\u5c06\u5907\u8282\u70b9IP\u66ff\u6362\u4e3a\u5907\u8282\u70b9\u7684\u5b9e\u9645IP\u5730\u5740\uff0c\u5e76\u8bbe\u7f6e\u5bc6\u7801\u3002<\/p>\n<p>\u5728\u5907\u8282\u70b9\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>CHANGE MASTER TO MASTER_HOST='\u4e3b\u8282\u70b9IP', MASTER_USER='replication_user', MASTER_PASSWORD='\u5bc6\u7801', MASTER_LOG_FILE='\u4e3b\u8282\u70b9\u7684binlog\u6587\u4ef6\u540d', MASTER_LOG_POS=\u4e3b\u8282\u70b9\u7684binlog\u6587\u4ef6\u4f4d\u7f6e;\nSTART SLAVE;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5c06\u4e3b\u8282\u70b9IP\u66ff\u6362\u4e3a\u4e3b\u8282\u70b9\u7684\u5b9e\u9645IP\u5730\u5740\uff0c\u5c06replication_user\u548c\u5bc6\u7801\u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u6570\u636e\u5e93\u7528\u6237\u540d\u548c\u5bc6\u7801\uff0c\u5c06\u4e3b\u8282\u70b9\u7684binlog\u6587\u4ef6\u540d\u548c\u4f4d\u7f6e\u66ff\u6362\u4e3a\u5b9e\u9645\u503c\u3002<\/p>\n<ol>\n<li>\u6545\u969c\u5207\u6362<br \/>\u5728\u4e3b\u8282\u70b9\u53d1\u751f\u6545\u969c\u65f6\uff0c\u9700\u8981\u624b\u52a8\u5207\u6362\u81f3\u5907\u8282\u70b9\u3002<\/li>\n<\/ol>\n<p>\u5728\u5907\u8282\u70b9\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>STOP SLAVE;\nRESET MASTER;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u5907\u8282\u70b9\u4e0a\u7f16\u8f91\u6570\u636e\u5e93\u914d\u7f6e\u6587\u4ef6my.cnf\uff0c\u5c06\u4ee5\u4e0b\u884c\u6ce8\u91ca\u6389\uff1a<\/p>\n<pre># server-id=2\n# log-bin=mysql-bin<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7136\u540e\u91cd\u542f\u6570\u636e\u5e93\u670d\u52a1\uff1a<\/p>\n<pre>service mysql restart<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    \u767b\u5f55\u540e\u590d\u5236    \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u73b0\u5728\u5907\u8282\u70b9\u5c06\u6210\u4e3a\u65b0\u7684\u4e3b\u8282\u70b9\uff0c\u5176\u4ed6\u5907\u8282\u70b9\u53ef\u4ee5\u6309\u7167\u76f8\u540c\u7684\u6b65\u9aa4\u914d\u7f6e\u4e3a\u65b0\u7684\u5907\u8282\u70b9\u3002<\/p>\n<p>\u56db\u3001\u603b\u7ed3<br \/>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u6210\u529f\u914d\u7f6e\u4e86\u4e00\u4e2a\u57fa\u4e8e\u4e3b\u5907\u590d\u5236\u6a21\u5f0f\u7684\u9ad8\u53ef\u7528\u6570\u636e\u5e93\u96c6\u7fa4\uff0c\u786e\u4fdd\u4e86\u6570\u636e\u7684\u6301\u7eed\u53ef\u9760\u8bbf\u95ee\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5bf9\u8bfb\u8005\u5728Linux\u4e0a\u914d\u7f6e\u9ad8\u53ef\u7528\u6570\u636e\u5e93\u96c6\u7fa4\u63d0\u4f9b\u4e00\u4e9b\u5e2e\u52a9\u3002\u5982\u6709\u7591\u95ee\uff0c\u8bf7\u53c2\u8003\u76f8\u5173\u5b98\u65b9\u6587\u6863\u6216\u8005\u54a8\u8be2\u4e13\u4e1a\u4eba\u58eb\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5728Linux\u4e0a\u914d\u7f6e\u9ad8\u53ef\u7528\u6570\u636e\u5e93\u96c6\u7fa4\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5728linux\u4e0a\u914d\u7f6e\u9ad8\u53ef\u7528\u6570\u636e\u5e93\u96c6\u7fa4 \u4e00\u3001\u5f15\u8a00\u968f\u7740\u4f01\u4e1a\u6570\u636e\u7684\u4e0d\u65ad\u589e\u957f\uff0c\u6570\u636e\u5e93\u7684\u9ad8\u53ef\u7528\u6027\u53d8\u5f97\u8d8a\u6765\u8d8a\u91cd\u8981\u3002\u9ad8\u53ef\u7528\u6570\u636e\u5e93\u96c6\u7fa4\u80fd\u591f\u63d0\u4f9b\u6301\u7eed\u53ef\u9760\u7684\u6570\u636e\u8bbf\u95ee\uff0c\u786e\u4fdd\u4e1a\u52a1\u7684\u8fde\u7eed\u8fd0\u884c\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728Linux\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u914d\u7f6e\u9ad8\u53ef\u7528\u6570\u636e\u5e93\u96c6\u7fa4\uff0c\u5e76\u63d0\u4f9b\u76f8\u5e94\u7684\u4ee3\u7801\u793a\u4f8b\u3002 \u4e8c\u3001\u51c6\u5907\u5de5\u4f5c\u5728\u5f00\u59cb\u914d\u7f6e\u9ad8\u53ef\u7528\u6570\u636e\u5e93\u96c6\u7fa4\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u51c6\u5907\u5de5\u4f5c\u3002 \u5b89\u88c5\u64cd\u4f5c\u7cfb\u7edf\uff1a\u9009\u62e9\u4e00\u79cd\u7a33\u5b9a\u53ef\u9760\u7684Linux\u53d1\u884c\u7248\uff0c\u4f8b\u5982CentOS\u3001Ubuntu\u7b49\uff0c\u5e76\u6309\u7167\u5b98\u65b9\u6587\u6863\u8fdb\u884c\u5b89\u88c5\u3002 \u5b89\u88c5\u6570\u636e\u5e93\u8f6f\u4ef6\uff1a\u9009\u62e9\u4e00\u79cd\u6210\u719f\u7a33\u5b9a\u7684\u6570\u636e\u5e93\u8f6f\u4ef6\uff0c\u4f8b\u5982MySQL\u3001PostgreSQL\u7b49\uff0c\u5e76\u6309\u7167\u5b98\u65b9\u6587\u6863\u8fdb\u884c\u5b89\u88c5\u3002 \u914d\u7f6e\u7f51\u7edc\uff1a\u786e\u4fdd\u96c6\u7fa4\u4e2d\u7684\u5404\u4e2a\u8282\u70b9\u53ef\u4ee5\u76f8\u4e92\u901a\u4fe1\uff0c\u5efa\u8bae\u4f7f\u7528\u9759\u6001IP\u6765\u907f\u514dIP\u5730\u5740\u7684\u53d8\u52a8\u3002 \u521b\u5efa\u6570\u636e\u5e93\u7528\u6237\uff1a\u521b\u5efa\u4e00\u4e2a\u4e13\u95e8\u7528\u4e8e\u96c6\u7fa4\u6570\u636e\u540c\u6b65\u7684\u6570\u636e\u5e93\u7528\u6237\uff0c\u5e76\u4e3a\u5176\u8bbe\u7f6e\u5408\u9002\u7684\u6743\u9650\u3002 \u4e09\u3001\u914d\u7f6e\u6570\u636e\u5e93\u96c6\u7fa4\u4ee5\u4e0b\u4ecb\u7ecd\u4e00\u79cd\u5e38\u89c1\u7684\u6570\u636e\u5e93\u96c6\u7fa4\u67b6\u6784\u2014\u2014\u4e3b\u5907\u590d\u5236\u6a21\u5f0f\uff0c\u5176\u4e2d\u4e00\u4e2a\u8282\u70b9\u4e3a\u4e3b\u8282\u70b9\uff0c\u8d1f\u8d23\u5904\u7406\u8bfb\u5199\u8bf7\u6c42\uff0c\u5176\u4ed6\u8282\u70b9\u4e3a\u5907\u8282\u70b9\uff0c\u7528\u4e8e\u6570\u636e\u5907\u4efd\u548c\u6545\u969c\u5207\u6362\u3002 \u521b\u5efa\u4e3b\u8282\u70b9\u9996\u5148\uff0c\u5728\u4e3b\u8282\u70b9\u4e0a\u8fdb\u884c\u914d\u7f6e\u3002 \u7f16\u8f91\u6570\u636e\u5e93\u914d\u7f6e\u6587\u4ef6my.cnf\uff0c\u627e\u5230\u4ee5\u4e0b\u90e8\u5206\uff1a [mysqld] server-id=1 log-bin=mysql-bin \u767b\u5f55\u540e\u590d\u5236 \u8bbe\u7f6eserver-id\u4e3a\u4e00\u4e2a\u552f\u4e00\u7684\u503c\uff0c\u4ee5\u6807\u8bc6\u4e3b\u8282\u70b9\u3002 \u91cd\u542f\u6570\u636e\u5e93\u670d\u52a1\uff1a service mysql restart \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u521b\u5efa\u5907\u8282\u70b9\u63a5\u4e0b\u6765\uff0c\u5728\u5907\u8282\u70b9\u4e0a\u8fdb\u884c\u914d\u7f6e\u3002 \u7f16\u8f91\u6570\u636e\u5e93\u914d\u7f6e\u6587\u4ef6my.cnf\uff0c\u627e\u5230\u4ee5\u4e0b\u90e8\u5206\uff1a [mysqld] server-id=2 log-bin=mysql-bin \u767b\u5f55\u540e\u590d\u5236 \u8bbe\u7f6eserver-id\u4e3a\u4e00\u4e2a\u552f\u4e00\u7684\u503c\uff0c\u4ee5\u6807\u8bc6\u5907\u8282\u70b9\u3002 \u91cd\u542f\u6570\u636e\u5e93\u670d\u52a1\uff1a service mysql restart \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u914d\u7f6e\u4e3b\u5907\u540c\u6b65\u5728\u4e3b\u8282\u70b9\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a GRANT REPLICATION SLAVE ON *.* TO &#8216;replication_user&#8217;@&#8217;\u5907\u8282\u70b9IP&#8217; IDENTIFIED BY &#8216;\u5bc6\u7801&#8217;; FLUSH PRIVILEGES; \u767b\u5f55\u540e\u590d\u5236 \u5c06replication_user\u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u6570\u636e\u5e93\u7528\u6237\u540d\uff0c\u5c06\u5907\u8282\u70b9IP\u66ff\u6362\u4e3a\u5907\u8282\u70b9\u7684\u5b9e\u9645IP\u5730\u5740\uff0c\u5e76\u8bbe\u7f6e\u5bc6\u7801\u3002 \u5728\u5907\u8282\u70b9\u4e0a\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a CHANGE MASTER TO [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-16061","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/16061","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=16061"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/16061\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=16061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=16061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=16061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}