{"id":43014,"date":"2024-10-04T13:16:29","date_gmt":"2024-10-04T05:16:29","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43014\/"},"modified":"2024-10-04T13:16:30","modified_gmt":"2024-10-04T05:16:30","slug":"centos-7-4-%e4%b8%8b-mysql-amoeba-%e5%af%a6%e7%8f%be%e4%b8%bb%e5%be%9e%e5%90%8c%e6%ad%a5%e8%ae%80%e5%af%ab%e5%88%86%e9%9b%a2","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43014\/","title":{"rendered":"CentOS 7.4 \u4e0b MySQL + Amoeba \u5be6\u73fe\u4e3b\u5f9e\u540c\u6b65\u8b80\u5beb\u5206\u96e2"},"content":{"rendered":"<h1 id=\"centos-7-4-%e4%b8%8b-mysql-amoeba-%e5%af%a6%e7%8f%be%e4%b8%bb%e5%be%9e%e5%90%8c%e6%ad%a5%e8%ae%80%e5%af%ab%e5%88%86%e9%9b%a2-BAncbXgqcD\">CentOS 7.4 \u4e0b MySQL + Amoeba \u5be6\u73fe\u4e3b\u5f9e\u540c\u6b65\u8b80\u5beb\u5206\u96e2<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u9a45\u52d5\u6642\u4ee3\uff0c\u6578\u64da\u5eab\u7684\u6027\u80fd\u548c\u53ef\u7528\u6027\u5c0d\u65bc\u61c9\u7528\u7a0b\u5e8f\u7684\u6210\u529f\u81f3\u95dc\u91cd\u8981\u3002MySQL \u4f5c\u70ba\u4e00\u500b\u6d41\u884c\u7684\u958b\u6e90\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u696d\u52d9\u4e2d\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5982\u4f55\u5728 CentOS 7.4 \u74b0\u5883\u4e0b\uff0c\u5229\u7528 MySQL \u548c Amoeba \u5be6\u73fe\u4e3b\u5f9e\u540c\u6b65\u8b80\u5beb\u5206\u96e2\uff0c\u4ee5\u63d0\u9ad8\u6578\u64da\u5eab\u7684\u6027\u80fd\u548c\u53ef\u64f4\u5c55\u6027\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af%e4%b8%bb%e5%be%9e%e5%90%8c%e6%ad%a5%e8%ae%80%e5%af%ab%e5%88%86%e9%9b%a2%ef%bc%9f-BAncbXgqcD\">\u4ec0\u9ebc\u662f\u4e3b\u5f9e\u540c\u6b65\u8b80\u5beb\u5206\u96e2\uff1f<\/h2>\n<p>\u4e3b\u5f9e\u540c\u6b65\u8b80\u5beb\u5206\u96e2\u662f\u4e00\u7a2e\u6578\u64da\u5eab\u67b6\u69cb\uff0c\u5176\u4e2d\u4e3b\u6578\u64da\u5eab\u8ca0\u8cac\u5beb\u5165\u64cd\u4f5c\uff0c\u800c\u5f9e\u6578\u64da\u5eab\u5247\u8655\u7406\u8b80\u53d6\u8acb\u6c42\u3002\u9019\u7a2e\u67b6\u69cb\u7684\u4e3b\u8981\u512a\u52e2\u5728\u65bc\u53ef\u4ee5\u6e1b\u5c11\u4e3b\u6578\u64da\u5eab\u7684\u8ca0\u64d4\uff0c\u63d0\u9ad8\u6574\u9ad4\u6027\u80fd\u3002\u7576\u61c9\u7528\u7a0b\u5e8f\u9700\u8981\u9032\u884c\u5927\u91cf\u8b80\u53d6\u64cd\u4f5c\u6642\uff0c\u5c07\u9019\u4e9b\u64cd\u4f5c\u5206\u914d\u7d66\u5f9e\u6578\u64da\u5eab\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u97ff\u61c9\u901f\u5ea6\u3002<\/p>\n<h2 id=\"%e7%92%b0%e5%a2%83%e6%ba%96%e5%82%99-BAncbXgqcD\">\u74b0\u5883\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u78ba\u4fdd\u60a8\u7684 CentOS 7.4 \u7cfb\u7d71\u5df2\u5b89\u88dd MySQL \u548c Amoeba\u3002\u4ee5\u4e0b\u662f\u5b89\u88dd\u7684\u57fa\u672c\u6b65\u9a5f\uff1a<\/p>\n<pre><code>sudo yum install mysql-server\nsudo systemctl start mysqld\nsudo systemctl enable mysqld\n<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5b89\u88dd Amoeba\u3002Amoeba \u662f\u4e00\u500b\u7528\u65bc MySQL \u7684\u8b80\u5beb\u5206\u96e2\u4ee3\u7406\uff0c\u80fd\u5920\u81ea\u52d5\u5c07\u8b80\u53d6\u8acb\u6c42\u8f49\u767c\u5230\u5f9e\u6578\u64da\u5eab\u3002<\/p>\n<pre><code>sudo yum install amoeba\n<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-mysql-%e4%b8%bb%e5%be%9e%e5%90%8c%e6%ad%a5-BAncbXgqcD\">\u914d\u7f6e MySQL \u4e3b\u5f9e\u540c\u6b65<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u914d\u7f6e MySQL \u7684\u4e3b\u5f9e\u540c\u6b65\u3002\u4ee5\u4e0b\u662f\u914d\u7f6e\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e9%85%8d%e7%bd%ae%e4%b8%bb%e6%95%b8%e6%93%9a%e5%ba%ab-BAncbXgqcD\">1. \u914d\u7f6e\u4e3b\u6578\u64da\u5eab<\/h3>\n<p>\u7de8\u8f2f MySQL \u914d\u7f6e\u6587\u4ef6 \/etc\/my.cnf\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>[mysqld]\nserver-id=1\nlog-bin=mysql-bin\n<\/code><\/pre>\n<p>\u91cd\u555f MySQL \u670d\u52d9\u4ee5\u61c9\u7528\u66f4\u6539\uff1a<\/p>\n<pre><code>sudo systemctl restart mysqld\n<\/code><\/pre>\n<h3 id=\"2-%e5%89%b5%e5%bb%ba%e8%a4%87%e8%a3%bd%e7%94%a8%e6%88%b6-BAncbXgqcD\">2. \u5275\u5efa\u8907\u88fd\u7528\u6236<\/h3>\n<p>\u5728\u4e3b\u6578\u64da\u5eab\u4e2d\u5275\u5efa\u4e00\u500b\u7528\u65bc\u8907\u88fd\u7684\u7528\u6236\uff1a<\/p>\n<pre><code>mysql -u root -p\nCREATE USER 'replica'@'%' IDENTIFIED BY 'password';\nGRANT REPLICATION SLAVE ON *.* TO 'replica'@'%';\nFLUSH PRIVILEGES;\n<\/code><\/pre>\n<h3 id=\"3-%e9%85%8d%e7%bd%ae%e5%be%9e%e6%95%b8%e6%93%9a%e5%ba%ab-BAncbXgqcD\">3. \u914d\u7f6e\u5f9e\u6578\u64da\u5eab<\/h3>\n<p>\u5728\u5f9e\u6578\u64da\u5eab\u7684 \/etc\/my.cnf \u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>[mysqld]\nserver-id=2\n<\/code><\/pre>\n<p>\u91cd\u555f\u5f9e\u6578\u64da\u5eab\u7684 MySQL \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl restart mysqld\n<\/code><\/pre>\n<h3 id=\"4-%e9%96%8b%e5%a7%8b%e8%a4%87%e8%a3%bd-BAncbXgqcD\">4. \u958b\u59cb\u8907\u88fd<\/h3>\n<p>\u5728\u5f9e\u6578\u64da\u5eab\u4e2d\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u958b\u59cb\u8907\u88fd\uff1a<\/p>\n<pre><code>mysql -u root -p\nCHANGE MASTER TO\nMASTER_HOST='\u4e3b\u6578\u64da\u5eabIP',\nMASTER_USER='replica',\nMASTER_PASSWORD='password',\nMASTER_LOG_FILE='mysql-bin.000001',\nMASTER_LOG_POS=0;\nSTART SLAVE;\n<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-amoeba-%e9%80%b2%e8%a1%8c%e8%ae%80%e5%af%ab%e5%88%86%e9%9b%a2-BAncbXgqcD\">\u914d\u7f6e Amoeba \u9032\u884c\u8b80\u5beb\u5206\u96e2<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u914d\u7f6e Amoeba \u4ee5\u5be6\u73fe\u8b80\u5beb\u5206\u96e2\u3002\u5728 \/etc\/amoeba.conf \u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre><code>[mysql]\nmaster = \u4e3b\u6578\u64da\u5eabIP:3306\nslave = \u5f9e\u6578\u64da\u5eabIP:3306\n<\/code><\/pre>\n<p>\u91cd\u555f Amoeba \u670d\u52d9\u4ee5\u61c9\u7528\u66f4\u6539\uff1a<\/p>\n<pre><code>sudo systemctl restart amoeba\n<\/code><\/pre>\n<h2 id=\"%e6%b8%ac%e8%a9%a6%e9%85%8d%e7%bd%ae-BAncbXgqcD\">\u6e2c\u8a66\u914d\u7f6e<\/h2>\n<p>\u5b8c\u6210\u914d\u7f6e\u5f8c\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u57f7\u884c\u4e00\u4e9b\u67e5\u8a62\u4f86\u6e2c\u8a66\u4e3b\u5f9e\u540c\u6b65\u548c\u8b80\u5beb\u5206\u96e2\u7684\u6548\u679c\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5\u5f9e\u6578\u64da\u5eab\u7684\u72c0\u614b\uff1a<\/p>\n<pre><code>mysql -u root -p\nSHOW SLAVE STATUSG\n<\/code><\/pre>\n<p>\u78ba\u4fdd\u6240\u6709\u7684\u72c0\u614b\u4fe1\u606f\u90fd\u986f\u793a\u70ba\u6b63\u5e38\uff0c\u9019\u6a23\u5c31\u8868\u793a\u4e3b\u5f9e\u540c\u6b65\u5df2\u6210\u529f\u914d\u7f6e\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-BAncbXgqcD\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u5728 CentOS 7.4 \u74b0\u5883\u4e0b\u914d\u7f6e MySQL \u548c Amoeba\uff0c\u60a8\u53ef\u4ee5\u5be6\u73fe\u4e3b\u5f9e\u540c\u6b65\u8b80\u5beb\u5206\u96e2\uff0c\u5f9e\u800c\u63d0\u9ad8\u6578\u64da\u5eab\u7684\u6027\u80fd\u548c\u53ef\u64f4\u5c55\u6027\u3002\u9019\u7a2e\u67b6\u69cb\u4e0d\u50c5\u80fd\u5920\u6e1b\u5c11\u4e3b\u6578\u64da\u5eab\u7684\u8ca0\u64d4\uff0c\u9084\u80fd\u63d0\u9ad8\u61c9\u7528\u7a0b\u5e8f\u7684\u97ff\u61c9\u901f\u5ea6\u3002\u5c0d\u65bc\u9700\u8981\u9ad8\u53ef\u7528\u6027\u548c\u9ad8\u6027\u80fd\u7684\u61c9\u7528\u4f86\u8aaa\uff0c\u9019\u662f\u4e00\u500b\u7406\u60f3\u7684\u89e3\u6c7a\u65b9\u6848\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u53ef\u9760\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\u4ee5\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002\u7121\u8ad6\u662f\u6578\u64da\u5eab\u7ba1\u7406\u9084\u662f\u5176\u4ed6\u61c9\u7528\uff0c\u9078\u64c7\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u5c07\u6709\u52a9\u65bc\u63d0\u5347\u60a8\u7684\u696d\u52d9\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to set up MySQL with Amoeba for master-slave synchronization and read-write separation on CentOS 7.4 for optimized database performance.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-43014","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=43014"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43014\/revisions"}],"predecessor-version":[{"id":43015,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43014\/revisions\/43015"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}