{"id":43016,"date":"2024-10-04T13:22:30","date_gmt":"2024-10-04T05:22:30","guid":{"rendered":"https:\/\/server.hk\/cnblog\/43016\/"},"modified":"2024-10-04T13:22:31","modified_gmt":"2024-10-04T05:22:31","slug":"centos-7-4-%e4%b8%8b-mysql-amoeba-%e5%81%9a%e4%b8%bb%e5%be%9e%e5%90%8c%e6%ad%a5%e8%ae%80%e5%af%ab%e5%88%86%e9%9b%a2%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/43016\/","title":{"rendered":"CentOS 7.4 \u4e0b MySQL + Amoeba \u505a\u4e3b\u5f9e\u540c\u6b65\u8b80\u5beb\u5206\u96e2\u64cd\u4f5c"},"content":{"rendered":"<h1 id=\"centos-7-4-%e4%b8%8b-mysql-amoeba-%e5%81%9a%e4%b8%bb%e5%be%9e%e5%90%8c%e6%ad%a5%e8%ae%80%e5%af%ab%e5%88%86%e9%9b%a2%e6%93%8d%e4%bd%9c-HYaggffLhN\">CentOS 7.4 \u4e0b MySQL + Amoeba \u505a\u4e3b\u5f9e\u540c\u6b65\u8b80\u5beb\u5206\u96e2\u64cd\u4f5c<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u9a45\u52d5\u4e16\u754c\u4e2d\uff0c\u6578\u64da\u5eab\u7684\u6027\u80fd\u548c\u53ef\u7528\u6027\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\u61c9\u7528\u7a0b\u5e8f\u4e2d\u3002\u70ba\u4e86\u63d0\u9ad8\u6027\u80fd\uff0c\u8a31\u591a\u4f01\u696d\u9078\u64c7\u4f7f\u7528\u4e3b\u5f9e\u540c\u6b65\u548c\u8b80\u5beb\u5206\u96e2\u7684\u67b6\u69cb\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 7.4 \u74b0\u5883\u4e0b\uff0c\u4f7f\u7528 MySQL \u548c Amoeba \u9032\u884c\u4e3b\u5f9e\u540c\u6b65\u548c\u8b80\u5beb\u5206\u96e2\u64cd\u4f5c\u3002<\/p>\n<h2 id=\"1-%e7%92%b0%e5%a2%83%e6%ba%96%e5%82%99-HYaggffLhN\">1. \u74b0\u5883\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u6e96\u5099\u4ee5\u4e0b\u74b0\u5883\uff1a<\/p>\n<ul>\n<li>\u4e00\u53f0 CentOS 7.4 \u4f3a\u670d\u5668<\/li>\n<li>\u5b89\u88dd MySQL 5.7 \u6216\u66f4\u9ad8\u7248\u672c<\/li>\n<li>Amoeba \u8edf\u4ef6\u5305<\/li>\n<\/ul>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd MySQL\uff1a<\/p>\n<pre><code>sudo yum install mysql-server<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u555f\u52d5 MySQL \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start mysqld<\/code><\/pre>\n<h2 id=\"2-%e9%85%8d%e7%bd%ae-mysql-%e4%b8%bb%e5%be%9e%e5%90%8c%e6%ad%a5-HYaggffLhN\">2. \u914d\u7f6e MySQL \u4e3b\u5f9e\u540c\u6b65<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728\u4e3b\u4f3a\u670d\u5668\u4e0a\u9032\u884c\u914d\u7f6e\u3002\u7de8\u8f2f MySQL \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/my.cnf<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre><code>[mysqld]\nserver-id=1\nlog-bin=mysql-bin\nbinlog-do-db=your_database_name\n<\/code><\/pre>\n<p>\u4fdd\u5b58\u4e26\u9000\u51fa\u5f8c\uff0c\u91cd\u555f MySQL \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl restart mysqld<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5275\u5efa\u4e00\u500b\u7528\u65bc\u5f9e\u4f3a\u670d\u5668\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;\nSHOW MASTER STATUS;\n<\/code><\/pre>\n<p>\u8a18\u4e0b\u986f\u793a\u7684\u6587\u4ef6\u540d\u548c\u4f4d\u7f6e\uff0c\u9019\u5c07\u5728\u5f9e\u4f3a\u670d\u5668\u7684\u914d\u7f6e\u4e2d\u4f7f\u7528\u3002<\/p>\n<h2 id=\"3-%e9%85%8d%e7%bd%ae%e5%be%9e%e4%bc%ba%e6%9c%8d%e5%99%a8-HYaggffLhN\">3. \u914d\u7f6e\u5f9e\u4f3a\u670d\u5668<\/h2>\n<p>\u5728\u5f9e\u4f3a\u670d\u5668\u4e0a\uff0c\u7de8\u8f2f MySQL \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/my.cnf<\/code><\/pre>\n<p>\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre><code>[mysqld]\nserver-id=2\n<\/code><\/pre>\n<p>\u4fdd\u5b58\u4e26\u9000\u51fa\u5f8c\uff0c\u91cd\u555f MySQL \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl restart mysqld<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u9023\u63a5\u5230 MySQL \u4e26\u8a2d\u7f6e\u4e3b\u4f3a\u670d\u5668\u7684\u4fe1\u606f\uff1a<\/p>\n<pre><code>mysql -u root -p\nCHANGE MASTER TO\nMASTER_HOST='\u4e3b\u4f3a\u670d\u5668IP',\nMASTER_USER='replica',\nMASTER_PASSWORD='password',\nMASTER_LOG_FILE='mysql-bin.000001',  -- \u4f7f\u7528\u4e3b\u4f3a\u670d\u5668\u7684\u6587\u4ef6\u540d\nMASTER_LOG_POS=\u4f4d\u7f6e;  -- \u4f7f\u7528\u4e3b\u4f3a\u670d\u5668\u7684\u4f4d\u7f6e\u4fe1\u606f\nSTART SLAVE;\n<\/code><\/pre>\n<h2 id=\"4-%e4%bd%bf%e7%94%a8-amoeba-%e9%80%b2%e8%a1%8c%e8%ae%80%e5%af%ab%e5%88%86%e9%9b%a2-HYaggffLhN\">4. \u4f7f\u7528 Amoeba \u9032\u884c\u8b80\u5beb\u5206\u96e2<\/h2>\n<p>Amoeba \u662f\u4e00\u500b\u8f15\u91cf\u7d1a\u7684\u8b80\u5beb\u5206\u96e2\u5de5\u5177\uff0c\u53ef\u4ee5\u5e6b\u52a9\u60a8\u5728\u61c9\u7528\u7a0b\u5e8f\u4e2d\u5be6\u73fe\u8b80\u5beb\u5206\u96e2\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88dd Amoeba\uff1a<\/p>\n<pre><code>sudo yum install amoeba<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u914d\u7f6e Amoeba\u3002\u7de8\u8f2f Amoeba \u7684\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/amoeba.conf<\/code><\/pre>\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4e3b\u4f3a\u670d\u5668\u548c\u5f9e\u4f3a\u670d\u5668\u7684\u4fe1\u606f\uff1a<\/p>\n<pre><code>[mysql]\nmaster = \u4e3b\u4f3a\u670d\u5668IP\nslave = \u5f9e\u4f3a\u670d\u5668IP\n<\/code><\/pre>\n<p>\u4fdd\u5b58\u4e26\u9000\u51fa\u5f8c\uff0c\u555f\u52d5 Amoeba\uff1a<\/p>\n<pre><code>sudo systemctl start amoeba<\/code><\/pre>\n<h2 id=\"5-%e6%b8%ac%e8%a9%a6%e9%85%8d%e7%bd%ae-HYaggffLhN\">5. \u6e2c\u8a66\u914d\u7f6e<\/h2>\n<p>\u60a8\u53ef\u4ee5\u901a\u904e\u57f7\u884c\u4e00\u4e9b\u67e5\u8a62\u4f86\u6e2c\u8a66\u914d\u7f6e\u662f\u5426\u6210\u529f\u3002\u9996\u5148\uff0c\u9023\u63a5\u5230 Amoeba\uff0c\u7136\u5f8c\u57f7\u884c\u4e00\u4e9b\u5beb\u5165\u64cd\u4f5c\uff0c\u63a5\u8457\u57f7\u884c\u8b80\u53d6\u64cd\u4f5c\u4ee5\u78ba\u8a8d\u8b80\u5beb\u5206\u96e2\u662f\u5426\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<pre><code>mysql -u user -p -h amoeba_ip\nINSERT INTO your_table (column1) VALUES ('value1');\nSELECT * FROM your_table;\n<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-HYaggffLhN\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u5728 CentOS 7.4 \u74b0\u5883\u4e0b\u6210\u529f\u914d\u7f6e MySQL \u548c Amoeba \u9032\u884c\u4e3b\u5f9e\u540c\u6b65\u548c\u8b80\u5beb\u5206\u96e2\u64cd\u4f5c\u3002\u9019\u7a2e\u67b6\u69cb\u4e0d\u50c5\u63d0\u9ad8\u4e86\u6578\u64da\u5eab\u7684\u6027\u80fd\uff0c\u9084\u589e\u5f37\u4e86\u7cfb\u7d71\u7684\u53ef\u7528\u6027\u3002\u82e5\u60a8\u9700\u8981\u9032\u4e00\u6b65\u7684\u652f\u6301\u6216\u5c0b\u627e\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4ee5\u7372\u53d6\u66f4\u591a\u4fe1\u606f\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-43016","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43016","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=43016"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43016\/revisions"}],"predecessor-version":[{"id":43017,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/43016\/revisions\/43017"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=43016"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=43016"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=43016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}