{"id":1991,"date":"2020-07-29T22:12:18","date_gmt":"2020-07-29T14:12:18","guid":{"rendered":"http:\/\/39.97.231.10\/?p=1991"},"modified":"2020-07-29T22:12:18","modified_gmt":"2020-07-29T14:12:18","slug":"mysql-8-0-%e6%90%ad%e5%bb%ba%e7%bb%84%e5%a4%8d%e5%88%b6mgr%e5%8d%95%e4%b8%bb%e6%a8%a1%e5%bc%8f%e5%a4%9a%e4%b8%bb%e6%a8%a1%e5%bc%8f","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=1991","title":{"rendered":"MySQL 8.0 \u642d\u5efa\u7ec4\u590d\u5236MGR(\u5355\u4e3b\u6a21\u5f0f&amp;\u591a\u4e3b\u6a21\u5f0f)"},"content":{"rendered":"<div>\n<div>\nMySQL Group Replication\uff08MGR\uff09\u662fMySQL\u5b98\u65b9\u57285.7.17\u7248\u672c\u5f15\u8fdb\u7684\u4e00\u4e2a\u6570\u636e\u5e93\u9ad8\u53ef\u7528\u4e0e\u9ad8\u6269\u5c55\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u4ee5\u63d2\u4ef6\u5f62\u5f0f\u63d0\u4f9b\uff0c\u5177\u6709\u9ad8\u4e00\u81f4\u6027\uff0c\u9ad8\u5bb9\u9519\u6027\uff0c\u9ad8\u6269\u5c55\u6027\u548c\u9ad8\u7075\u6d3b\u6027\u7b49\u7279\u70b9\u3002MGR\u53ef\u4ee5\u8bbe\u7f6e\u5355\u4e3b\u6a21\u5f0f\u548c\u591a\u4e3b\u6a21\u5f0f\uff0c\u5355\u4e3b\u6a21\u5f0f\u53ea\u6709\u4e00\u4e2a\u4e3b\u8282\u70b9\u53ef\u5199\uff0c\u5176\u4ed6\u8282\u70b9\u53ea\u8bfb\uff0c\u591a\u4e3b\u6a21\u5f0f\u6240\u6709\u8282\u70b9\u90fd\u53ef\u5199\u5165\u3002\u672c\u6587\u5c06\u57fa\u4e8e8.0.19\u7248\u672c\uff0c\u4ecb\u7ecdMGR\u96c6\u7fa4\u7684\u642d\u5efa\u8fc7\u7a0b\u3002\n<\/div>\n<\/div>\n<div>\n<div>\n<div><\/div>\n<div>1\u3001\u73af\u5883<\/div>\n<div><\/div>\n<div>3\u53f0\u670d\u52a1\u5668\u642d\u5efa3\u8282\u70b9MGR\u96c6\u7fa4\uff0cMySQL\u7248\u672c8.0.19\u3002<\/div>\n<ul>\n<li>\n<div>192.168.56.101<\/div>\n<\/li>\n<li>\n<div>192.168.56.102<\/div>\n<\/li>\n<li>\n<div>192.168.56.103<\/div>\n<\/li>\n<\/ul>\n<div><\/div>\n<div><\/div>\n<div>2\u3001\u914d\u7f6emy.cnf<\/div>\n<div><\/div>\n<div>\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6 my.cnf\uff0c\u5b8c\u6574\u8def\u5f84 \/home\/mysql\/etc\/my.cnf_8.0.19\uff0c3\u4e2a\u8282\u70b9\u9664\u4e86\u4ee5\u4e0b\u4e09\u4e2a\u53c2\u6570\u4e0d\u4e00\u6837\u5916\uff0c\u5176\u4ed6\u4fdd\u6301\u4e00\u81f4\u3002<\/div>\n<ul>\n<li>\n<div>server_id<\/div>\n<\/li>\n<li>\n<div>loose-group_replication_local_address<\/div>\n<\/li>\n<li>\n<div>report_host<\/div>\n<\/li>\n<\/ul>\n<div>\n<div>[mysqld]<\/div>\n<div>port=3306<\/div>\n<div>basedir=\/usr\/local\/mysql8<\/div>\n<div>datadir=\/mysql\/data8\/<\/div>\n<div>socket=\/mysql\/data8\/mysql.sock<\/div>\n<div>pid_file=\/mysql\/data8\/mysql.pid<\/div>\n<div><\/div>\n<div>log_bin=binlog<\/div>\n<div>log_slave_updates=ON<\/div>\n<div>binlog_format=ROW<\/div>\n<div>binlog_checksum=NONE<\/div>\n<div>master_info_repository=TABLE<\/div>\n<div>relay_log_info_repository=TABLE<\/div>\n<div><\/div>\n<div>gtid_mode=ON<\/div>\n<div>enforce_gtid_consistency=ON<\/div>\n<div><\/div>\n<div>transaction_write_set_extraction=XXHASH64<\/div>\n<div>loose-group_replication_group_name=\\&#8221;aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa\\&#8221;<\/div>\n<div>loose-group_replication_start_on_boot=OFF<\/div>\n<div>loose-group_replication_local_address=\\&#8221;192.168.56.101:33061\\&#8221;<\/div>\n<div>loose-group_replication_group_seeds=\\&#8221;192.168.56.101:33061,192.168.56.102:33061,192.168.56.103:33061\\&#8221;<\/div>\n<div>loose-group_replication_bootstrap_group=OFF<\/div>\n<div><\/div>\n<div>server_id=1<\/div>\n<div>report_host=192.168.56.101<\/div>\n<div>report_port=3306<\/div>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div>3\u3001\u521d\u59cb\u5316\u6570\u636e\u5e93<\/div>\n<div><\/div>\n<div>\u4e09\u4e2a\u8282\u70b9\u90fd\u8981\u6267\u884c\u3002<\/div>\n<div>\n<div>useradd mysql<\/div>\n<div>mkdir -p \/mysql\/data8<\/div>\n<div>sudo chown -R mysql:mysql \/mysql\/data8<\/div>\n<div>sudo chown -R mysql.mysql \/home\/mysql\/etc\/<\/div>\n<div><\/div>\n<div>\/usr\/local\/mysql8\/bin\/mysqld &#8211;defaults-file=\/home\/mysql\/etc\/my.cnf_8.0.19 &#8211;initialize-insecure<\/div>\n<\/div>\n<div><\/div>\n<div>4\u3001\u542f\u52a8MySQL\uff0c\u5b89\u88c5MGR\u63d2\u4ef6\uff0c\u6dfb\u52a0\u590d\u5236\u8d26\u53f7<\/div>\n<div><\/div>\n<div>\u4e09\u4e2a\u8282\u70b9\u90fd\u8981\u6267\u884c\u3002<\/div>\n<div>\n<div>#\u00a0\u542f\u52a8MySQL<\/div>\n<div>\/usr\/local\/mysql8\/bin\/mysqld_safe\u00a0\u00a0&#8211;defaults-file=\/home\/mysql\/etc\/my.cnf_8.0.19 &amp;<\/div>\n<div><\/div>\n<div>#\u00a0\u767b\u5f55MySQL<\/div>\n<div>\/usr\/local\/mysql8\/bin\/mysql -S \/mysql\/data8\/mysql.sock<\/div>\n<div><\/div>\n<div># \u5b89\u88c5MGR\u63d2\u4ef6<\/div>\n<div>mysql&gt;INSTALL PLUGIN group_replication SONAME \\&#8217;group_replication.so\\&#8217;;<\/div>\n<div><\/div>\n<div># \u8bbe\u7f6e\u590d\u5236\u8d26\u53f7<\/div>\n<div>mysql&gt; SET SQL_LOG_BIN=0;<\/div>\n<div>mysql&gt; CREATE USER repl@\\&#8217;%\\&#8217; IDENTIFIED WITH mysql_native_password BY \\&#8217;123456\\&#8217;;<\/div>\n<div>mysql&gt; GRANT REPLICATION SLAVE ON *.* TO repl@\\&#8217;%\\&#8217;;<\/div>\n<div>mysql&gt; SET SQL_LOG_BIN=1;<\/div>\n<div>mysql&gt; CHANGE MASTER TO MASTER_USER=\\&#8217;repl\\&#8217;, MASTER_PASSWORD=\\&#8217;123456\\&#8217; FOR CHANNEL \\&#8217;group_replication_recovery\\&#8217;;<\/div>\n<\/div>\n<div><\/div>\n<div>5\u3001\u542f\u52a8MGR\u5355\u4e3b\u6a21\u5f0f<\/div>\n<div><\/div>\n<div>\u5728\u4e3b\u8282\u70b9192.168.56.101\u4e0a\u6267\u884c\u3002<\/div>\n<div><\/div>\n<div>\n<div># \u542f\u52a8MGR\uff0c\u5728\u4e3b\u5e93(192.168.56.101)\u4e0a\u6267\u884c<\/div>\n<div>mysql&gt; SET GLOBAL group_replication_bootstrap_group=ON;<\/div>\n<div>mysql&gt; START GROUP_REPLICATION;<\/div>\n<div>mysql&gt; SET GLOBAL group_replication_bootstrap_group=OFF;<\/div>\n<div><\/div>\n<div># \u5176\u4ed6\u8282\u70b9\u52a0\u5165MGR\uff0c\u5728\u4ece\u5e93\uff08192.168.56.102\uff0c192.168.56.103\uff09\u4e0a\u6267\u884c<\/div>\n<div>mysql&gt; START GROUP_REPLICATION;<\/div>\n<div><\/div>\n<div># \u67e5\u770bMGR\u7ec4\u4fe1\u606f<\/div>\n<div>mysql&gt; SELECT * FROM performance_schema.replication_group_members;<\/div>\n<\/div>\n<div><\/div>\n<div>\u6267\u884c\u6210\u529f\u540e\uff0c\u53ef\u4ee5\u770b\u5230\uff0c3\u4e2a\u8282\u70b9\u72b6\u6001\u4e3aONLINE\uff0c\u5e76\u4e14\u4e3b\u8282\u70b9\u4e3a192.168.56.101\uff0c\u53ea\u6709\u4e3b\u8282\u70b9\u53ef\u4ee5\u5199\u5165\uff0c\u5176\u4ed6\u8282\u70b9\u53ea\u8bfb\uff0cMGR\u5355\u4e3b\u6a21\u5f0f\u642d\u5efa\u6210\u529f\u3002<\/div>\n<div><\/div>\n<div><\/div>\n<div>6\u3001MGR\u5355\u4e3b\u6a21\u5f0f\u5207\u6362\u6210\u591a\u4e3b\u6a21\u5f0f<\/div>\n<div><\/div>\n<div>MGR\u5207\u6362\u6a21\u5f0f\u9700\u8981\u91cd\u65b0\u542f\u52a8\u7ec4\u590d\u5236\uff0c\u56e0\u4e9b\u9700\u8981\u5728\u6240\u6709\u8282\u70b9\u4e0a\u5148\u5173\u95ed\u7ec4\u590d\u5236\uff0c\u8bbe\u7f6e group_replication_single_primary_mode=OFF \u7b49\u53c2\u6570\uff0c\u518d\u542f\u52a8\u7ec4\u590d\u5236\u3002<\/div>\n<div><\/div>\n<div>\n<div># \u505c\u6b62\u7ec4\u590d\u5236(\u6240\u6709\u8282\u70b9\u6267\u884c)\uff1a<\/div>\n<div>mysql&gt; stop group_replication;<\/div>\n<div>mysql&gt; set global group_replication_single_primary_mode=OFF;<\/div>\n<div>mysql&gt; set global group_replication_enforce_update_everywhere_checks=ON;<\/div>\n<div><\/div>\n<div><\/div>\n<div># \u968f\u4fbf\u9009\u62e9\u67d0\u4e2a\u8282\u70b9\u6267\u884c<\/div>\n<div>mysql&gt; SET GLOBAL group_replication_bootstrap_group=ON;<\/div>\n<div>mysql&gt; START GROUP_REPLICATION;<\/div>\n<div>mysql&gt; SET GLOBAL group_replication_bootstrap_group=OFF;<\/div>\n<div><\/div>\n<div><\/div>\n<div># \u5176\u4ed6\u8282\u70b9\u6267\u884c<\/div>\n<div>mysql&gt; START GROUP_REPLICATION;<\/div>\n<div><\/div>\n<div><\/div>\n<div># \u67e5\u770b\u7ec4\u4fe1\u606f\uff0c\u6240\u6709\u8282\u70b9\u7684 MEMBER_ROLE \u90fd\u4e3a PRIMARY<\/div>\n<div>mysql&gt; SELECT * FROM performance_schema.replication_group_members;<\/div>\n<\/div>\n<div><\/div>\n<div>\u53ef\u4ee5\u770b\u5230\u6240\u6709\u8282\u70b9\u72b6\u6001\u90fd\u662fONLINE\uff0c\u89d2\u8272\u90fd\u662fPRIMARY\uff0cMGR\u591a\u4e3b\u6a21\u5f0f\u642d\u5efa\u6210\u529f\u3002<\/div>\n<div><\/div>\n<div>7\u3001MGR\u591a\u4e3b\u6a21\u5f0f\u5207\u56de\u5355\u4e3b\u6a21\u5f0f<\/div>\n<div><\/div>\n<div>\n<div># \u6240\u6709\u8282\u70b9\u6267\u884c<\/div>\n<div>mysql&gt; stop group_replication;<\/div>\n<div>mysql&gt; set global group_replication_enforce_update_everywhere_checks=OFF;<\/div>\n<div>mysql&gt; set global group_replication_single_primary_mode=ON;<\/div>\n<div><\/div>\n<div># \u4e3b\u8282\u70b9\uff08192.168.56.101\uff09\u6267\u884c<\/div>\n<div>mysql&gt; SET GLOBAL group_replication_bootstrap_group=ON;<\/div>\n<div>mysql&gt; START GROUP_REPLICATION;<\/div>\n<div>mysql&gt; SET GLOBAL group_replication_bootstrap_group=OFF;<\/div>\n<div><\/div>\n<div># \u4ece\u8282\u70b9\uff08192.168.56.102\u3001192.168.56.103\uff09\u6267\u884c<\/div>\n<div>mysql&gt; START GROUP_REPLICATION;<\/div>\n<div><\/div>\n<div># \u67e5\u770bMGR\u7ec4\u4fe1\u606f<\/div>\n<div>mysql&gt; SELECT * FROM performance_schema.replication_group_members;<\/div>\n<\/div>\n<div><\/div>\n<div>8\u3001\u9047\u5230\u7684\u95ee\u9898<\/div>\n<div><\/div>\n<div>\u8282\u70b9\u72b6\u6001\u4e00\u76f4\u662f RECOVERING\uff0c\u67e5\u770b\u9519\u8bef\u65e5\u5fd7\uff0c\u53d1\u73b0\u662frepl\u8d26\u53f7\u8ba4\u8bc1\u65b9\u5f0fcaching_sha2_password\u5bfc\u81f4\u7684\uff0c\u5728\u521b\u5efarepl\u590d\u5236\u8d26\u53f7\u65f6\u52a0\u4e0a with mysql_native_password \u5373\u53ef\u3002<\/div>\n<div><\/div>\n<div>\n<div>Authentication plugin \\&#8217;caching_sha2_password\\&#8217;\u00a0\u00a0reported error: Authentication requires secure\u00a0\u00a0connection. Error_code: MY-002061<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>MySQL Group Replication\uff08MGR\uff09\u662fMySQL\u5b98\u65b9\u57285.7.17\u7248\u672c\u5f15\u8fdb\u7684\u4e00\u4e2a\u6570\u636e\u5e93\u9ad8\u53ef &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=1991\"> <span class=\"screen-reader-text\">MySQL 8.0 \u642d\u5efa\u7ec4\u590d\u5236MGR(\u5355\u4e3b\u6a21\u5f0f&amp;\u591a\u4e3b\u6a21\u5f0f)<\/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 Group Replication\uff08MGR\uff09\u662fMySQL\u5b98\u65b9\u57285.7.17\u7248\u672c\u5f15\u8fdb\u7684\u4e00\u4e2a\u6570\u636e\u5e93\u9ad8\u53ef&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1991"}],"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=1991"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1991\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1991"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}