{"id":76,"date":"2021-03-13T12:40:45","date_gmt":"2021-03-13T04:40:45","guid":{"rendered":"http:\/\/daishen.ltd\/?p=76"},"modified":"2021-03-13T12:40:46","modified_gmt":"2021-03-13T04:40:46","slug":"atlas_%e8%af%bb%e5%86%99%e5%88%86%e7%a6%bb","status":"publish","type":"post","link":"https:\/\/www.daishen.ltd\/?p=76","title":{"rendered":"Atlas_\u8bfb\u5199\u5206\u79bb"},"content":{"rendered":"<p><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width initial-scale=1\"><br \/>\n<title>Atlas_\u8bfb\u5199\u5206\u79bb<\/title><\/p>\n<h1>1. Atlas\u4ecb\u7ecd<\/h1>\n<p><img decoding=\"async\" src=\"https:\/\/\/\/upload-images.jianshu.io\/upload_images\/16956686-24b9752549843352.png?imageMogr2\/auto-orient\/strip|imageView2\/2\/w\/567\/format\/webp\" referrerpolicy=\"no-referrer\" alt=\"img\"><\/p>\n<p>image.png<\/p>\n<p>&nbsp;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/\/\/upload-images.jianshu.io\/upload_images\/16956686-dce5742c72a16dac.png?imageMogr2\/auto-orient\/strip|imageView2\/2\/w\/546\/format\/webp\" referrerpolicy=\"no-referrer\" alt=\"img\"><\/p>\n<p>image.png<\/p>\n<p>&nbsp;<\/p>\n<pre><code class=\"language-cpp\" lang=\"cpp\"> Atlas\u662f\u7531 Qihoo 360, Web\u5e73\u53f0\u90e8\u57fa\u7840\u67b6\u6784\u56e2\u961f\u5f00\u53d1\u7ef4\u62a4\u7684\u4e00\u4e2a\u57fa\u4e8eMySQL\u534f\u8bae\u7684\u6570\u636e\u4e2d\u95f4\u5c42\u9879\u76ee\u3002\n\u5b83\u662f\u5728mysql-proxy 0.8.2\u7248\u672c\u7684\u57fa\u7840\u4e0a\uff0c\u5bf9\u5176\u8fdb\u884c\u4e86\u4f18\u5316\uff0c\u589e\u52a0\u4e86\u4e00\u4e9b\u65b0\u7684\u529f\u80fd\u7279\u6027\u3002\n360\u5185\u90e8\u4f7f\u7528Atlas\u8fd0\u884c\u7684mysql\u4e1a\u52a1\uff0c\u6bcf\u5929\u627f\u8f7d\u7684\u8bfb\u5199\u8bf7\u6c42\u6570\u8fbe\u51e0\u5341\u4ebf\u6761\u3002\n\u4e0b\u8f7d\u5730\u5740\nhttps:\/\/github.com\/Qihoo360\/Atlas\/releases\n\u6ce8\u610f\uff1a\n1\u3001Atlas\u53ea\u80fd\u5b89\u88c5\u8fd0\u884c\u572864\u4f4d\u7684\u7cfb\u7edf\u4e0a\n2\u3001Centos 5.X\u5b89\u88c5 Atlas-XX.el5.x86_64.rpm\uff0cCentos 6.X\u5b89\u88c5Atlas-XX.el6.x86_64.rpm\u3002\n3\u3001\u540e\u7aefmysql\u7248\u672c\u5e94\u5927\u4e8e5.1\uff0c\u5efa\u8bae\u4f7f\u7528Mysql 5.6\u4ee5\u4e0a\n<\/code><\/pre>\n<h1>2.\u5b89\u88c5\u914d\u7f6e<\/h1>\n<p>&nbsp;<\/p>\n<pre><code class=\"language-shell\" lang=\"shell\">yum install -y Atlas*\n\ncd \/usr\/local\/mysql-proxy\/conf\n\nmv test.cnf test.cnf.bak\n\nvim test.cnf\n \n[mysql-proxy]\nadmin-username = user\nadmin-password = pwd\nproxy-backend-addresses = 10.0.0.55:3306 #\u5199\u5730\u5740\nproxy-read-only-backend-addresses = 10.0.0.52:3306,10.0.0.53:3306  #\u8bfb\u5730\u5740\npwds = repl:3yb5jEku5h4=,mha:O2jBXONX098=\ndaemon = true   #\u540e\u53f0\u8fd0\u884c\nkeepalive = true\t#\u68c0\u67e5\u5fc3\u8df3\nevent-threads = 8\t#\u5e76\u53d1\u7ebf\u7a0b\nlog-level = message\t#\u65e5\u5fd7\u683c\u5f0f\nlog-path = \/usr\/local\/mysql-proxy\/log\t\u65e5\u5fd7\u8def\u5f84\nsql-log=ON\t#\u8bb0\u5f55\u7ecf\u8fc7Atlas\u5904\u7406\u7684\u8bed\u53e5\nproxy-address = 0.0.0.0:33060\t#\u4ee3\u7406\u7aef\u53e3\nadmin-address = 0.0.0.0:2345\t#Atlas\u7ba1\u7406\u5458\u7aef\u53e3\ncharset=utf8\n\n\u542f\u52a8atlas\n\/usr\/local\/mysql-proxy\/bin\/mysql-proxyd test start\nps -ef |grep proxy\n<\/code><\/pre>\n<h1>3. Atlas\u529f\u80fd\u6d4b\u8bd5<\/h1>\n<p>&nbsp;<\/p>\n<pre><code class=\"language-css\" lang=\"css\">\u6d4b\u8bd5\u8bfb\u64cd\u4f5c\uff1a\nmysql -umha -pmha  -h 10.0.0.53 -P 33060 \ndb03 [(none)]&gt;select @@server_id;\n\u6d4b\u8bd5\u5199\u64cd\u4f5c\uff1a\nmysql&gt; begin;select @@server_id;commit;\n<\/code><\/pre>\n<h1>4. \u751f\u4ea7\u7528\u6237\u8981\u6c42<\/h1>\n<p>&nbsp;<\/p>\n<pre><code class=\"language-csharp\" lang=\"csharp\">\u5f00\u53d1\u4eba\u5458\u7533\u8bf7\u4e00\u4e2a\u5e94\u7528\u7528\u6237 app(  select  update  insert)  \u5bc6\u7801123456,\u8981\u901a\u8fc710\u7f51\u6bb5\u767b\u5f55\n1. \u5728\u4e3b\u5e93\u4e2d,\u521b\u5efa\u7528\u6237\ngrant select ,update,insert on *.* to app@'10.0.0.%' identified by '123456';\n\n2. \u5728atlas\u4e2d\u6dfb\u52a0\u751f\u4ea7\u7528\u6237\n\/usr\/local\/mysql-proxy\/bin\/encrypt  123456      ----&gt;\u5236\u4f5c\u52a0\u5bc6\u5bc6\u7801\n    \nvim test.cnf\npwds = repl:3yb5jEku5h4=,mha:O2jBXONX098=,app:\/iZxz+0GRoA=\n    \n\/usr\/local\/mysql-proxy\/bin\/mysql-proxyd test restart\n[root@db03 conf]# mysql -uapp -p123456  -h 10.0.0.53 -P 33060\n<\/code><\/pre>\n<h1>5. Atlas\u57fa\u672c\u7ba1\u7406<\/h1>\n<h2>\u8fde\u63a5\u7ba1\u7406\u63a5\u53e3<\/h2>\n<p>&nbsp;<\/p>\n<pre><code class=\"language-css\" lang=\"css\">mysql -uuser -ppwd -h127.0.0.1 -P2345\n<\/code><\/pre>\n<h2>\u6253\u5370\u5e2e\u52a9\uff1a<\/h2>\n<p>&nbsp;<\/p>\n<pre><code class=\"language-csharp\" lang=\"csharp\">mysql&gt; select * from help;\n<\/code><\/pre>\n<h2>\u67e5\u8be2\u540e\u7aef\u6240\u6709\u8282\u70b9\u4fe1\u606f\uff1a<\/h2>\n<p>&nbsp;<\/p>\n<pre><code class=\"language-ruby\" lang=\"ruby\">mysql&gt;  SELECT * FROM backends    ;\n+-------------+----------------+-------+------+\n| backend_ndx | address        | state | type |\n+-------------+----------------+-------+------+\n|           1 | 10.0.0.55:3306 | up    | rw   |\n|           2 | 10.0.0.51:3306 | up    | ro   |\n|           3 | 10.0.0.53:3306 | up    | ro   |\n+-------------+----------------+-------+------+\n3 rows in set (0.00 sec)\n<\/code><\/pre>\n<h2>\u4e0a\u7ebf\u8282\u70b9<\/h2>\n<pre><code>SET ONLINE 2\uff1b\n<\/code><\/pre>\n<h2>\u4e0b\u7ebf\u8282\u70b9<\/h2>\n<pre><code>SET OFFLINE 2\uff1b\n<\/code><\/pre>\n<h2>\u52a8\u6001\u5220\u9664\u8282\u70b9<\/h2>\n<pre><code class=\"language-undefined\" lang=\"undefined\">REMOVE BACKEND 3;\n<\/code><\/pre>\n<h2>\u52a8\u6001\u6dfb\u52a0\u8282\u70b9<\/h2>\n<pre><code class=\"language-css\" lang=\"css\">ADD SLAVE 10.0.0.53:3306;\n<\/code><\/pre>\n<h2>\u5728\u7ebf\u6dfb\u52a0\u7528\u6237<\/h2>\n<pre><code>ADD PWD cuoni:123456\n<\/code><\/pre>\n<h2>\u4fdd\u5b58\u914d\u7f6e\u5230\u914d\u7f6e\u6587\u4ef6<\/h2>\n<pre><code class=\"language-undefined\" lang=\"undefined\">SAVE CONFIG;\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h1>6. \u81ea\u52a8\u5206\u8868<\/h1>\n<h2>\u4ecb\u7ecd<\/h2>\n<p>&nbsp;<\/p>\n<pre><code class=\"language-css\" lang=\"css\">\u4f7f\u7528Atlas\u7684\u5206\u8868\u529f\u80fd\u65f6\uff0c\u9996\u5148\u9700\u8981\u5728\u914d\u7f6e\u6587\u4ef6test.cnf\u8bbe\u7f6etables\u53c2\u6570\u3002\ntables\u53c2\u6570\u8bbe\u7f6e\u683c\u5f0f\uff1a\u6570\u636e\u5e93\u540d.\u8868\u540d.\u5206\u8868\u5b57\u6bb5.\u5b50\u8868\u6570\u91cf\uff0c\n\u6bd4\u5982\uff1a\n\u4f60\u7684\u6570\u636e\u5e93\u540d\u53ebschool\uff0c\u8868\u540d\u53ebstu\uff0c\u5206\u8868\u5b57\u6bb5\u53ebid\uff0c\u603b\u5171\u5206\u4e3a2\u5f20\u8868\uff0c\u90a3\u4e48\u5c31\u5199\u4e3aschool.stu.id.2\uff0c\u5982\u679c\u8fd8\u6709\u5176\u4ed6\u7684\u5206\u8868\uff0c\u4ee5\u9017\u53f7\u5206\u9694\u5373\u53ef\u3002\n<\/code><\/pre>\n<h1>7. \u5173\u4e8e\u8bfb\u5199\u5206\u79bb\u5efa\u8bae<\/h1>\n<p>&nbsp;<\/p>\n<pre><code class=\"language-rust\" lang=\"rust\">MySQL-Router    ---&gt; MySQL\u5b98\u65b9\nProxySQL         ---&gt;Percona\nMaxscale         ---&gt; MariaDB\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Atlas_\u8bfb\u5199\u5206\u79bb 1. Atlas\u4ecb\u7ecd image.png &nbsp; image.png &nbsp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76"}],"version-history":[{"count":1,"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":77,"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions\/77"}],"wp:attachment":[{"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.daishen.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}