{"id":5399,"date":"2020-07-30T00:19:40","date_gmt":"2020-07-29T16:19:40","guid":{"rendered":"http:\/\/39.97.231.10\/?p=5399"},"modified":"2020-07-30T00:19:40","modified_gmt":"2020-07-29T16:19:40","slug":"mysql%e9%ab%98%e5%8f%af%e7%94%a8%e4%b8%bb%e4%bb%8e%e5%88%87%e6%8d%a2%e5%b7%a5%e5%85%b7replication-manager-2","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=5399","title":{"rendered":"MySQL\u9ad8\u53ef\u7528\u4e3b\u4ece\u5207\u6362\u5de5\u5177replication-manager"},"content":{"rendered":"<div>\n<div>\n<div>\nMySQL\u9ad8\u53ef\u7528\u5de5\u5177\uff0c\u4e00\u76f4\u4ee5\u6765MHA\u4f7f\u7528\u7684\u6bd4\u8f83\u591a\uff0c\u81ea\u4eceMySQL \u5f15\u5165GTID\u4e4b\u540e\uff0c\u53c8\u51fa\u73b0\u4e86Orchestrator\u4ee5\u53careplication-manager\u8fd9\u7c7b\u65b0\u7684\u9ad8\u53ef\u7528\u5de5\u5177\uff0c\u672c\u6587\u5c06\u4e3b\u8981\u4ecb\u7ecdreplication-manager\u7684\u4f7f\u7528\u65b9\u6cd5\u3002<\/p>\n<h4>\u4e00\u3001replication-manager\u7b80\u4ecb<\/h4>\n<p>replication-manager\u662fsignal18\u5f00\u6e90\u7684\u4e00\u6b3e\u6570\u636e\u5e93\u9ad8\u53ef\u7528\u5de5\u5177\uff0c\u91c7\u7528go\u8bed\u8a00\u5f00\u53d1\uff0c\u6e90\u4ee3\u7801\u6258\u7ba1\u5728github\u4e0a\u3002<br \/>\n\u652f\u6301\u7684MySQL\u7684\u7248\u672c\uff1a<\/p>\n<ul>\n<li>MariaDB 10.x<\/li>\n<li>MySQL &amp; Percona Server 5.7 GTID<\/li>\n<\/ul>\n<p>\u529f\u80fd\u7279\u6027\uff1a<\/p>\n<ul>\n<li>\u590d\u5236\u5173\u7cfb\u76d1\u63a7\u4e0e\u62d3\u6251\u68c0\u6d4b<\/li>\n<li>\u5728\u7ebf\u5207\u6362(switchover)<\/li>\n<li>\u6545\u969c\u5207\u6362(failover)<\/li>\n<li>\u591a\u96c6\u7fa4\u7ba1\u7406<\/li>\n<li>\u652f\u6301\u4ee3\u7406\uff08 ProxySQL, MaxScale, HAProxy, Spider\uff09<\/li>\n<li>\u5927\u591a\u6570\u573a\u666f\u6570\u636e\u96f6\u4e22\u5931<\/li>\n<\/ul>\n<h4>\u4e8c\u3001\u4e0b\u8f7d\u53ca\u5b89\u88c5<\/h4>\n<p>\u5728github\u4e0a\u641c\u7d22replication-manager\uff0c\u4e0b\u8f7d\u6e90\u7801(v2.0)<br \/>\n\u7f16\u8bd1\uff08\u9700\u8981\u8054\u7f51\uff09\uff1a<\/p>\n<ul>\n<li>\u521b\u5efa\u76ee\u5f55\uff1amkdir -p \/data\/go<\/li>\n<li>\u52a0\u5165\u73af\u5883\u53d8\u91cf\uff1a export GOPATH=\/data\/go<\/li>\n<li>clone\u6e90\u7801\uff1a go get github.com\/signal18\/replication-manager<\/li>\n<li>\u7f16\u8bd1\u5b89\u88c5\uff1a go install github.com\/signal18\/replication-manager<\/li>\n<li>\u52a0\u5165PATH\u73af\u5883\u53d8\u91cf\uff1a export PATH=$PATH:\/data\/go\/bin<\/li>\n<li>\u7f16\u8bd1\u5b8c\u6210\u4e4b\u540e\uff0c\u4f1a\u5728\/data\/go\/bin\u76ee\u5f55\u4e0b\uff0c\u751f\u6210\u4e00\u4e2areplication-manager\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<p>\u7f16\u8bd1\u5b8c\u6574\u4e8c\u8fdb\u5236\u7248\u672c\uff1a<br \/>\ncd \/data\/go\/src\/github.com\/signal18\/replication-manager<br \/>\n.\/build_linux_amd64.sh<br \/>\n\u5728\u6e90\u7801\u76ee\u5f55\u4e2d\uff0c\u751f\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff1a<\/p>\n<ul>\n<li>replication-manager<\/li>\n<li>replication-manager-arb<\/li>\n<li>replication-manager-cli<\/li>\n<li>replication-manager-min<\/li>\n<li>replication-manager-min-basedir<\/li>\n<li>replication-manager-osc<\/li>\n<li>replication-manager-osc-basedir<\/li>\n<li>replication-manager-pro<\/li>\n<li>replication-manager-pro-basedir<\/li>\n<li>replication-manager-tst<\/li>\n<li>replication-manager-tst-basedir<\/li>\n<\/ul>\n<p>\u4e0b\u9762\u6f14\u793a\u6848\u4f8b\uff0c\u53ea\u4f7f\u7528 replication-manager-osc \u548c replication-manager-cli\u3002<br \/>\nreplication-manager-osc \u4e3a\u540e\u53f0\u96c6\u7fa4\u76d1\u89c6\u7a0b\u5e8f\uff0c\u8d1f\u8d23MySQL\u72b6\u6001\u7684\u83b7\u53d6\u548c\u76d1\u63a7\uff0c\u4ee5\u53ca\u5207\u6362\u7684\u6267\u884c\u7b49\u7b49\u3002<br \/>\nreplication-manager-cli \u4e3a\u5ba2\u6237\u7aef\u7a0b\u5e8f\uff0c\u8d1f\u8d23\u7ba1\u7406\u547d\u4ee4\u7684\u53d1\u9001\u3002<\/p>\n<h4>\u4e09\u3001\u4f7f\u7528\u6848\u4f8b<\/h4>\n<p>\u914d\u7f6e\u6587\u4ef6 config.toml\uff1a<\/p>\n<pre>[Default]\ntitle = \\\"ClusterTest\\\"\ndb-servers-hosts = \u00a0\\\"192.168.56.110:3306,192.168.56.111:3306,192.168.56.112:3306\\\"\ndb-servers-credential = \\\"admin:123456\\\"\nreplication-credential = \\\"repl:123456\\\"\nfailover-mode = \\\"automatic\\\"\narbitrator-bind-address = \\\"0.0.0.0:10005\\\"\narbitrator-driver = \\\"sqlite\\\"\n<\/pre>\n<p>mkdir -p \/usr\/share\/replication-manager<br \/>\ncp -r \/data\/git\/replication-manager\/dashboard\/ \/usr\/share\/replication-manager\/<br \/>\n\u76d1\u89c6\u96c6\u7fa4\uff1a<br \/>\n.\/replication-manager-osc &#8211;config=.\/config.toml monitor<br \/>\n\u624b\u52a8\u6267\u884c\u4e3b\u4ece\u5207\u6362\uff1a<br \/>\n.\/replication-manager-cli &#8211;config=.\/config.toml\u00a0switchover<br \/>\n\u624b\u52a8\u6267\u884c\u6545\u969c\u5207\u6362\uff1a<br \/>\n\u5148\u628a\u4e3b\u5e93\u5173\u6389<br \/>\n\u6267\u884c.\/replication-manager-cli &#8211;config=.\/config.toml failover<br \/>\n\u81ea\u52a8\u6267\u884c\u6545\u969c\u5207\u6362\uff1a<br \/>\n\u53ea\u8981\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u628afailover-mode \u7531 \\&#8221;manual\\&#8221; \u4fee\u6539\u4e3a \\&#8221;automatic\\&#8221;\uff0c\u91cd\u65b0\u76d1\u89c6\u96c6\u7fa4\u5373\u53ef\u3002\u8fd9\u6837\u4e3b\u5e93\u5b95\u673a\u7684\u60c5\u51b5\u4e0b\uff0c\u4f1a\u81ea\u52a8\u6267\u884c\u6545\u969c\u5207\u6362\u3002<br \/>\n\u5b95\u673a\u7684\u65e7\u4e3b\u5982\u679c\u6062\u590d\u540e\uff0c\u4f1a\u81ea\u52a8\u53d8\u6210\u65b0\u4e3b\u7684\u4e00\u4e2a\u4ece\u5e93\uff0c\u5e76\u4e14\u5904\u4e8e\u7ef4\u62a4\u6a21\u5f0f\u3002<br \/>\n\u901a\u8fc7 replication-manager-cli \u7684 topology\u547d\u4ee4\u53ef\u4ee5\u83b7\u53d6\u96c6\u7fa4\u5404\u4e2a\u8282\u70b9\u7684id\uff0c\u518d\u901a\u8fc7server\u547d\u4ee4\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u6216\u8005\u89e3\u9664\u7ef4\u62a4\u6a21\u5f0f\uff0c\u5982\u4e0b\uff1a<br \/>\n.\/replication-manager-cli topology<br \/>\n.\/replication-manager-cli server &#8211;id=5789112859919251853 &#8211;maintenance<br \/>\n\u547d\u4ee4\u884c\u6a21\u5f0f\uff1a<br \/>\n.\/replication-manager-cli console<br \/>\n\u8fdb\u5165\u547d\u4ee4\u884c\u4ea4\u4e92\u6a21\u5f0f\uff0c\u5728\u8be5\u6a21\u5f0f\u4e0b\uff0c\u53ef\u67e5\u770b\u5f53\u524d\u96c6\u7fa4\u7684\u590d\u5236\u62d3\u6251\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5feb\u6377\u952e\u6267\u884c\u4e00\u4e9b\u547d\u4ee4\uff0c\u6bd4\u5982ctrl+s \u6267\u884cswitchover\uff0cctrl+f \u6267\u884cfailover\uff0cctrl+m\u8bbe\u7f6e\u6216\u8005\u89e3\u9664\u7ef4\u62a4\u6a21\u5f0f\u7b49\u7b49\u3002<\/p>\n<h4>\u603b\u7ed3\uff1a<\/h4>\n<p>\u672c\u6587\u7b80\u5355\u4ecb\u7ecd\u4e86replication-manager\u7684\u529f\u80fd\u7279\u6027\u3001\u7f16\u8bd1\u5b89\u88c5\u548c\u4f7f\u7528\u6848\u4f8b\uff0c\u603b\u4f53\u6765\u770b\uff0c\u4e0a\u624b\u6bd4\u8f83\u5bb9\u6613\uff0c\u7f16\u8bd1\u914d\u7f6e\u7b80\u5355\uff0c\u529f\u80fd\u6bd4\u8f83\u5f3a\u5927\uff0c\u6587\u6863\u4e5f\u6bd4\u8f83\u4e30\u5bcc\u3002\n<\/p><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>MySQL\u9ad8\u53ef\u7528\u5de5\u5177\uff0c\u4e00\u76f4\u4ee5\u6765MHA\u4f7f\u7528\u7684\u6bd4\u8f83\u591a\uff0c\u81ea\u4eceMySQL \u5f15\u5165GTID\u4e4b\u540e\uff0c\u53c8\u51fa\u73b0\u4e86Orchestra &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=5399\"> <span class=\"screen-reader-text\">MySQL\u9ad8\u53ef\u7528\u4e3b\u4ece\u5207\u6362\u5de5\u5177replication-manager<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[90,88],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"MySQL\u9ad8\u53ef\u7528\u5de5\u5177\uff0c\u4e00\u76f4\u4ee5\u6765MHA\u4f7f\u7528\u7684\u6bd4\u8f83\u591a\uff0c\u81ea\u4eceMySQL \u5f15\u5165GTID\u4e4b\u540e\uff0c\u53c8\u51fa\u73b0\u4e86Orchestra&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/5399"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5399"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/5399\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5399"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}