{"id":915,"date":"2020-12-16T14:42:08","date_gmt":"2020-12-16T06:42:08","guid":{"rendered":"https:\/\/www.linuxdevops.cn\/?p=915"},"modified":"2020-12-17T14:55:53","modified_gmt":"2020-12-17T06:55:53","slug":"setup-of-group-replication-mode-configuration-for","status":"publish","type":"post","link":"https:\/\/www.linuxdevops.cn\/2020\/12\/setup-of-group-replication-mode-configuration-for\/","title":{"rendered":"Keepalived + Mysql MGR \u7ec4\u590d\u5236\u6a21\u5f0f\u6545\u969c\u81ea\u52a8\u5207\u6362\uff08\u4e00\uff09"},"content":{"rendered":"
\u4e3b\u4ece\u590d\u5236\uff0c\u4e00\u4e3b\u591a\u4ece\uff0c\u4e3b\u5e93\u63d0\u4f9b\u8bfb\u5199\u529f\u80fd\uff0c\u4ece\u5e93\u63d0\u4f9b\u53ea\u8bfb\u529f\u80fd\u3002\u5f53\u4e00\u4e2a\u4e8b\u52a1\u5728master \u63d0\u4ea4\u6210\u529f\u65f6\uff0c\u4f1a\u628abinlog\u6587\u4ef6\u540c\u6b65\u5230\u4ece\u5e93\u670d\u52a1\u5668\u4e0a\u843d\u5730\u4e3arelay log\u7ed9slave\u7aef\u6267\u884c\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u4e3b\u5e93\u662f\u4e0d\u8003\u8651\u4ece\u5e93\u662f\u5426\u6709\u63a5\u6536\u5230binlog\u6587\u4ef6\uff0c\u6709\u53ef\u80fd\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\uff0c\u5f53\u4e3b\u5e93commit\u4e00\u4e2a\u4e8b\u52a1\u540e\uff0c\u6570\u636e\u5e93\u53d1\u751f\u5b95\u673a\uff0c\u521a\u597d\u5b83\u7684binlog\u8fd8\u6ca1\u6765\u5f97\u53ca\u4f20\u9001\u5230slave\u7aef\uff0c\u8fd9\u4e2a\u65f6\u5019\u9009\u4efb\u4f55\u4e00\u4e2aslave\u7aef\u90fd\u4f1a\u4e22\u5931\u8fd9\u4e2a\u4e8b\u52a1\uff0c\u9020\u6210\u6570\u636e\u4e0d\u4e00\u81f4\u60c5\u51b5\u3002 \u4e3a\u4e86\u907f\u514d\u51fa\u73b0\u4e3b\u4ece\u6570\u636e\u4e0d\u4e00\u81f4\u7684\u60c5\u51b5\uff0cMySQL\u5f15\u5165\u4e86\u534a\u540c\u6b65\u590d\u5236\uff0c\u6dfb\u52a0\u591a\u4e86\u4e00\u4e2a\u4ece\u5e93\u53cd\u9988\u673a\u5236\uff0c\u5373\u534a\u540c\u6b65\u590d\u5236\u3002\u8fd9\u4e2a\u6709\u4e24\u79cd\u65b9\u5f0f\u8bbe\u7f6e\uff1a<\/p>\n
\n\n
- \u4e3b\u5e93\u6267\u884c\u5b8c\u4e8b\u52a1\u540e\uff0c\u540c\u6b65binlog\u7ed9\u4ece\u5e93\uff0c\u4ece\u5e93ack\u53cd\u9988\u63a5\u6536\u5230binlog\uff0c\u4e3b\u5e93\u63d0\u4ea4commit\uff0c\u53cd\u9988\u7ed9\u5ba2\u6237\u7aef\uff0c\u91ca\u653e\u4f1a\u8bdd\uff1b<\/li>\n
- \u4e3b\u5e93\u6267\u884c\u5b8c\u4e8b\u52a1\u540e\uff0c\u4e3b\u5e93\u63d0\u4ea4commit \uff0c\u540c\u6b65binlog\u7ed9\u4ece\u5e93\uff0c\u4ece\u5e93ack\u53cd\u9988\u63a5\u6536\u5230binlog\uff0c\u53cd\u9988\u7ed9\u5ba2\u6237\u7aef\uff0c\u91ca\u653e\u4f1a\u8bdd\uff1b <\/li>\n<\/ul>\n<\/blockquote>\n
\u4f46\u662f\uff0c\u867d\u7136\u6ee1\u8db3\u4e86\u4e00\u4e3b\u591a\u4ece\uff0c\u8bfb\u5199\u5206\u6790\uff0c\u6570\u636e\u4e00\u81f4\uff0c\u4f46\u662f\uff0c\u4f9d\u65e7\u6709\u4e24\u4e2a\u5f0a\u7aef\uff1a<\/p>\n
\n\n
- \u5199\u64cd\u4f5c\u53ea\u80fd\u5728master\u4e0a\uff1b<\/li>\n
- \u5982\u679cmaster\u5b95\u673a\uff0c\u9700\u8981\u4eba\u4e3a\u9009\u62e9\u65b0\u4e3b\u5e76\u91cd\u65b0\u7ed9\u5176\u4ed6\u7684slave\u7aef\u6267\u884cchange master\uff1b<\/li>\n<\/ul>\n
<\/p>\n<\/blockquote>\n
\u4e3a\u4e86\u89e3\u51b3\u4e00\u7cfb\u5217\u95ee\u9898\uff0c\u5b98\u65b9\u63a8\u51fa\u4e86MySQL Group Replication\uff0c\u4ecegroup replication\u53d1\u5e03\u4ee5\u540e\uff0c\u5c31\u67093\u79cd\u65b9\u6cd5\u6765\u5b9e\u73b0MySQL\u7684\u9ad8\u53ef\u7528\u96c6\u7fa4\uff1a<\/p>\n
\n\n
- \u5f02\u6b65\u590d\u5236<\/li>\n
- \u534a\u540c\u6b65\u590d\u5236<\/li>\n
- group replication<\/li>\n<\/ul>\n<\/blockquote>\n
\n2\u3001Group Replication\u539f\u7406<\/h3>\n
MySQL Group Replication\u6709\u4e24\u79cd\u6a21\u5f0f\uff0c\u5355\u4e3b\u6a21\u5f0fsingle-primary mode\u548c\u591a\u4e3b\u6a21\u5f0fmulti-primary mode\uff0c\u5728\u540c\u4e00\u4e2agroup\u5185\uff0c\u4e0d\u5141\u8bb8\u4e24\u79cd\u6a21\u5f0f\u540c\u65f6\u5b58\u5728\uff0c\u5e76\u4e14\u82e5\u8981\u5207\u6362\u5230\u4e0d\u540c\u6a21\u5f0f\uff0c\u5fc5\u987b\u4fee\u6539\u914d\u7f6e\u540e\u91cd\u65b0\u542f\u52a8\u96c6\u7fa4\u3002<\/p>\n
1\u3001\u5355\u4e3b\u6a21\u5f0f<\/h4>\n
\u5728\u5355\u4e3b\u6a21\u5f0f\u4e0b\uff0c\u53ea\u6709\u4e00\u4e2a\u8282\u70b9\u53ef\u4ee5\u8bfb\u5199\uff0c\u5176\u4ed6\u8282\u70b9\u63d0\u4f9b\u53ea\u8bfb\u670d\u52a1\u3002\u5355\u4e3b\u6a21\u5f0f\u4e0b\uff0c\u8be5\u53c2\u6570 _ \u5fc5\u987b\u88ab\u8bbe\u7f6e\u4e3a FALSE \uff0c\u5f53\u4e3b\u8282\u70b9\u5b95\u6389\uff0c\u81ea\u52a8\u4f1a\u6839\u636e\u670d\u52a1\u5668\u7684server_uuid\u53d8\u91cf\u548cgroup_replication_member_weight\u53d8\u91cf\u503c\uff0c\u9009\u62e9\u4e0b\u4e00\u4e2aslave\u8c01\u4f5c\u4e3a\u4e3b\u8282\u70b9\uff0cgroup_replication_member_weight\u7684\u503c\u6700\u9ad8\u7684\u6210\u5458\u88ab\u9009\u4e3a\u65b0\u7684\u4e3b\u8282\u70b9\uff0c\u8be5\u53c2\u6570\u9ed8\u8ba4\u4e3a50\uff0c\u5efa\u8bae\u53ef\u4ee5\u5728\u8282\u70b9\u4e0a\u8bbe\u7f6e\u4e0d\u540c\u503c\uff1b\u5728group_replication_member_weight\u503c\u76f8\u540c\u7684\u60c5\u51b5\u4e0b\uff0cgroup\u6839\u636e\u6570\u636e\u5b57\u5178\u4e2d server_uuid\u6392\u5e8f\uff0c\u6392\u5e8f\u5728\u6700\u524d\u7684\u88ab\u9009\u62e9\u4e3a\u4e3b\u8282\u70b9\u3002<\/p>\n
\n\n
- \u5355\u4e3b\u6a21\u5f0f\u4e2d\u53d1\u73b0\u5f53\u524d\u7684\u4e3b\u670d\u52a1\u5668\uff0c\u8be5\u503cVARIABLE_VALUE\u4e3a\u5b9e\u4f8b\u8282\u70b9\u7684server_uuid\uff1a<\/li>\n<\/ul>\n<\/blockquote>\n
select * from performance_schema.global_status WHERE VARIABLE_NAME like '%group_replication%';\n<\/code><\/pre>\n
2\u3001\u591a\u4e3b\u6a21\u5f0f<\/h4>\n
\u5728mysql\u591a\u4e3b\u6a21\u5f0f\u4e0b,\u5728\u7ec4\u590d\u5236\u4e2d\u901a\u8fc7Group Replication Protocol\u534f\u8bae\u53caPaxos\u534f\u8bae\uff0c\u5f62\u6210\u7684\u6574\u4f53\u9ad8\u53ef\u7528\u89e3\u51b3\u65b9\u6848 \u540c\u65f6\u589e\u52a0\u4e86certify\u7684\u6982\u5ff5\uff0c\u8d1f\u8d23\u68c0\u67e5\u4e8b\u52a1\u662f\u5426\u5141\u8bb8\u63d0\u4ea4\uff0c\u662f\u5426\u4e0e\u5176\u5b83\u4e8b\u52a1\u5b58\u5728\u51b2\u7a81,Group Replication\u662f\u7531\u591a\u4e2a\u8282\u70b9\u5171\u540c\u7ec4\u6210\u4e00\u4e2a\u6570\u636e\u5e93\u96c6\u7fa4\uff0c\u6bcf\u4e2a\u8282\u70b9\u90fd\u53ef\u4ee5\u5355\u72ec\u6267\u884c\u4e8b\u52a1\uff0c\u4f46\u662fread-write\uff08rw\uff09\u7684\u64cd\u4f5c\u53ea\u6709\u5728\u7ec4\u5185\u9a8c\u8bc1\u540e\u624d\u53ef\u4ee5commit\uff0cRead-only (RO)\u4e8b\u52a1\u662f\u4e0d\u9700\u8981\u9a8c\u8bc1\u53ef\u4ee5\u7acb\u5373\u6267\u884c\uff0c\u5f53\u4e00\u4e2a\u4e8b\u52a1\u5728\u4e00\u4e2a\u8282\u70b9\u4e0a\u63d0\u4ea4\u4e4b\u524d\uff0c\u4f1a\u5728\u7ec4\u5185\u81ea\u52a8\u8fdb\u884c\u539f\u5b50\u6027\u7684\u5e7f\u64ad\uff0c\u544a\u77e5\u5176\u4ed6\u8282\u70b9\u53d8\u66f4\u4e86\u4ec0\u4e48\u5185\u5bb9\/\u6267\u884c\u4e86\u4ec0\u4e48\u4e8b\u52a1\uff0c\u7136\u540e\u4e3a\u8be5\u4e8b\u7269\u5efa\u7acb\u4e00\u4e2a\u5168\u5c40\u7684\u6392\u5e8f\uff0c\u6700\u7ec8\uff0c\u8fd9\u610f\u5473\u7740\u6240\u6709\u7684\u670d\u52a1\u5668\u90fd\u4ee5\u76f8\u540c\u7684\u987a\u5e8f\u63a5\u6536\u76f8\u540c\u7684\u4e8b\u52a1\u96c6\u3002\u56e0\u6b64\uff0c\u6240\u6709\u670d\u52a1\u5668\u90fd\u6309\u7167\u76f8\u540c\u7684\u987a\u5e8f\u5e94\u7528\u76f8\u540c\u7684\u53d8\u66f4\u96c6\uff0c\u56e0\u6b64\u5b83\u4eec\u5728\u7ec4\u4e2d\u4fdd\u6301\u4e00\u81f4\u3002 \u5728\u591a\u4e3b\u6a21\u5f0f\u4e0b\uff0c\u8be5\u7ec4\u7684\u6240\u6709\u6210\u5458\u90fd\u8bbe\u7f6e\u4e3a\u8bfb\u5199\u6a21\u5f0f\uff0c\u5728\u591a\u4e3b\u6a21\u5f0f\u4e0b\uff0c\u4e0d\u652f\u6301SERIALIZABLE\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\uff0c\u4e14\u4e0d\u80fd\u5b8c\u5168\u652f\u6301\u7ea7\u8054\u5916\u952e\u7ea6\u675f\u3002 <\/p>\n
<\/p>\n
3\u3001MGR\u7279\u70b9<\/h4>\n
MySQL 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\u5b9e\u73b0\u4e86\u5206\u5e03\u5f0f\u4e0b\u6570\u636e\u7684\u6700\u7ec8\u4e00\u81f4\u6027\uff0c\u603b\u7ed3MGR\u7279\u70b9\u5982\u4e0b\uff1a<\/p>\n
\n
- \u9ad8\u4e00\u81f4\u6027\uff1a\u57fa\u4e8e\u5206\u5e03\u5f0fpaxos\u534f\u8bae\u5b9e\u73b0\u7ec4\u590d\u5236\uff0c\u4fdd\u8bc1\u6570\u636e\u4e00\u81f4\u6027\uff1b<\/li>\n
- \u9ad8\u5bb9\u9519\u6027\uff1a\u81ea\u52a8\u68c0\u6d4b\u673a\u5236\uff0c\u53ea\u8981\u4e0d\u662f\u5927\u591a\u6570\u8282\u70b9\u90fd\u5b95\u673a\u5c31\u53ef\u4ee5\u7ee7\u7eed\u5de5\u4f5c\uff0c\u5185\u7f6e\u9632\u8111\u88c2\u4fdd\u62a4\u673a\u5236\uff1b<\/li>\n
- \u9ad8\u6269\u5c55\u6027\uff1a\u8282\u70b9\u7684\u589e\u52a0\u4e0e\u79fb\u9664\u4f1a\u81ea\u52a8\u66f4\u65b0\u7ec4\u6210\u5458\u4fe1\u606f\uff0c\u65b0\u8282\u70b9\u52a0\u5165\u540e\uff0c\u81ea\u52a8\u4ece\u5176\u4ed6\u8282\u70b9\u540c\u6b65\u589e\u91cf\u6570\u636e\uff0c\u76f4\u5230\u4e0e\u5176\u4ed6\u8282\u70b9\u6570\u636e\u4e00\u81f4\uff1b<\/li>\n
- \u9ad8\u7075\u6d3b\u6027\uff1a\u63d0\u4f9b\u5355\u4e3b\u6a21\u5f0f\u548c\u591a\u4e3b\u6a21\u5f0f\uff0c\u5355\u4e3b\u6a21\u5f0f\u5728\u4e3b\u5e93\u5b95\u673a\u540e\u80fd\u591f\u81ea\u52a8\u9009\u4e3b\uff0c\u6240\u6709\u5199\u5165\u90fd\u5728\u4e3b\u8282\u70b9\u8fdb\u884c\uff0c\u591a\u4e3b\u6a21\u5f0f\u652f\u6301\u591a\u8282\u70b9\u5199\u5165\u3002<\/li>\n<\/ul>\n
4.\u7ec4\u590d\u5236\u7684\u9650\u5236<\/strong><\/h3>\n
\n
- \u5b58\u50a8\u5f15\u64ce\u5fc5\u987b\u4e3aInnodb\uff0c\u5373\u4ec5\u652f\u6301InnoDB\u8868\uff0c\u5e76\u4e14\u6bcf\u5f20\u8868\u4e00\u5b9a\u8981\u6709\u4e00\u4e2a\u4e3b\u952e\uff0c\u7528\u4e8e\u505awrite set\u7684\u51b2\u7a81\u68c0\u6d4b;<\/li>\n
- \u6bcf\u4e2a\u8868\u5fc5\u987b\u63d0\u4f9b\u4e3b\u952e;<\/li>\n
- \u53ea\u652f\u6301ipv4\uff0c\u7f51\u7edc\u9700\u6c42\u8f83\u9ad8;<\/li>\n
- \u5fc5\u987b\u6253\u5f00GTID\u7279\u6027\uff0c\u4e8c\u8fdb\u5236\u65e5\u5fd7\u683c\u5f0f\u5fc5\u987b\u8bbe\u7f6e\u4e3aROW\uff0c\u7528\u4e8e\u9009\u4e3b\u4e0ewrite set;<\/li>\n
- COMMIT\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5931\u8d25\uff0c\u7c7b\u4f3c\u4e8e\u5feb\u7167\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b\u7684\u5931\u8d25\u573a\u666f;<\/li>\n
- \u76ee\u524d\u4e00\u4e2aMGR\u96c6\u7fa4\u7ec4\u6700\u591a\u652f\u63019\u4e2a\u8282\u70b9;<\/li>\n
- \u4e0d\u652f\u6301\u5916\u952e\u4e8esave point\u7279\u6027\uff0c\u65e0\u6cd5\u505a\u5168\u5c40\u95f4\u7684\u7ea6\u675f\u68c0\u6d4b\u4e0e\u90e8\u5206\u90e8\u5206\u56de\u6eda;<\/li>\n
- \u4e8c\u8fdb\u5236\u65e5\u5fd7binlog\u4e0d\u652f\u6301Replication event checksums;<\/li>\n
- \u591a\u4e3b\u6a21\u5f0f(\u4e5f\u5c31\u662f\u591a\u5199\u6a21\u5f0f) \u4e0d\u652f\u6301SERIALIZABLE\u4e8b\u52a1\u9694\u79bb\u7ea7\u522b;<\/li>\n
- \u591a\u4e3b\u6a21\u5f0f\u4e0d\u80fd\u5b8c\u5168\u652f\u6301\u7ea7\u8054\u5916\u952e\u7ea6\u675f;<\/li>\n
- \u591a\u4e3b\u6a21\u5f0f\u4e0d\u652f\u6301\u5728\u4e0d\u540c\u8282\u70b9\u4e0a\u5bf9\u540c\u4e00\u4e2a\u6570\u636e\u5e93\u5bf9\u8c61\u5e76\u53d1\u6267\u884cDDL(\u5728\u4e0d\u540c\u8282\u70b9\u4e0a\u5bf9\u540c\u4e00\u884c\u5e76\u53d1\u8fdb\u884cRW\u4e8b\u52a1\uff0c\u540e\u53d1\u8d77\u7684\u4e8b\u52a1\u4f1a\u5931\u8d25);<\/li>\n<\/ul>\n
4\u3001\u642d\u5efaMGR\u7ec4\u590d\u5236<\/h3>\n
1\u3001\u73af\u5883\u51c6\u5907<\/h4>\n
\n\n\n
\n \nIP<\/th>\n \u8282\u70b9<\/th>\n \u5c5e\u6027<\/th>\n hostname<\/th>\n<\/tr>\n<\/thead>\n \n 64.115.5.33\/24<\/td>\n master<\/td>\n keepalived+mysql5.7<\/td>\n CentOS76<\/td>\n<\/tr>\n \n 64.115.5.100\/24<\/td>\n slave1<\/td>\n keepalived+mysql5.7<\/td>\n k8s-node1<\/td>\n<\/tr>\n \n 64.115.5.200\/24<\/td>\n slave2<\/td>\n keepalived+mysql5.7<\/td>\n k8s-node2<\/td>\n<\/tr>\n \n 64.115.5.111\/24<\/td>\n VIP<\/td>\n \u865a\u62dfIP<\/td>\n <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n #\u5173\u95ed\u9632\u706b\u5899\nsystemctl stop firewalld && systemctl disable firewalld\n#\u5173\u95ed SELINUX\nswapoff -a && sed -i '\/ swap \/ s\/^\\(.*\\)$\/#\\1\/g' \/etc\/fstab && setenforce 0 && sed -i 's\/^SELINUX=enforcing\/SELINUX=disabled\/' \/etc\/selinux\/config\n#\u914d\u7f6e\u57df\u540d\u89e3\u6790\nvim \/etc\/hosts\n64.115.5.100 k8s-node1\n64.115.5.200 k8s-node2\n64.115.5.33 CentOS76\n<\/code><\/pre>\n
2\u3001\u5b89\u88c5\u914d\u7f6eMYSQL<\/p>\n
\n
- \u5b89\u88c5MYSQL<\/li>\n<\/ul>\n
#\u4e0b\u8f7d\u5e76\u5b89\u88c5MySQL\u5b98\u65b9\u7684 Yum Repository\n1\u3001 wget -i -c http:\/\/dev.mysql.com\/get\/mysql57-community-release-el7-10.noarch.rpm\n2\u3001 yum -y install mysql57-community-release-el7-10.noarch.rpm\n#\u5b89\u88c5mysql\u6570\u636e\u5e93\n3\u3001 yum -y install mysql-community-server\n<\/code><\/pre>\n
\n
- \u914d\u7f6e\u7ec4\u590d\u5236<\/li>\n<\/ul>\n
[mysqld]\n#\u57fa\u672c\u8bbe\u7f6e\ndatadir=\/var\/lib\/mysql\nsocket=\/var\/lib\/mysql\/mysql.sock\n\n# Disabling symbolic-links is recommended to prevent assorted security risks\nsymbolic-links=0\n\nlog-error=\/var\/log\/mysqld.log\npid-file=\/var\/run\/mysqld\/mysqld.pid\n\n#\u590d\u5236\u6846\u67b6\uff0c\u6839\u636eMysql\u7ec4\u590d\u5236\u8981\u6c42\u914d\u7f6e\u590d\u5236\nserver_id=1 #\u552f\u4e00\u6807\u8bc6\u53f71 (\u6bcf\u53f0\u4e3b\u673a\u4e0d\u540c)\ngtid_mode=ON #\u7ec4\u590d\u5236\u4f7f\u7528\u5168\u5c40\u4e8b\u52a1\u6807\u8bc6\u7b26\uff0c\u6765\u7cbe\u786e\u8ffd\u8e2a\u54ea\u4e9b\u4e8b\u52a1\u5df2\u5728\u6240\u6709server\u5b9e\u4f8b\u4e0a\u63d0\u4ea4\uff0c\u4ece\u800c\u80fd\u5224\u65ad\u54ea\u4e9bserver\u6267\u884c\u4e86\u4e0e\u5df2\u63d0\u4ea4\u4e8b\u52a1\u51b2\u7a81\u7684\u4e8b\u52a1\nenforce_gtid_consistency=ON #\u5f3a\u5236GTID\u7684\u4e00\u81f4\u6027\nmaster_info_repository=TABLE #\u5c06master.info\u5143\u6570\u636e\u4fdd\u5b58\u5728\u7cfb\u7edf\u8868\u4e2d\nrelay_log_info_repository=TABLE #\u5c06relay.info\u5143\u6570\u636e\u4fdd\u5b58\u5728\u7cfb\u7edf\u8868\u4e2d\nbinlog_checksum=NONE #\u7981\u7528\u4e8c\u8fdb\u5236\u65e5\u5fd7\u4e8b\u4ef6\u6821\u9a8c\nlog_slave_updates=ON #server\u9700\u8bb0\u5f55applier\u5e94\u7528\u7684\u4e8c\u8fdb\u5236\u65e5\u5fd7\nlog_bin=binlog #MySQL\u7ec4\u590d\u5236\u4f1a\u590d\u5236\u4e8c\u8fdb\u5236\u65e5\u5fd7\u7684\u5185\u5bb9\uff0c\u56e0\u6b64\u9700\u6253\u5f00\u4e8c\u8fdb\u5236\u65e5\u5fd7\nbinlog_format=ROW #\u7ec4\u590d\u5236\u4f9d\u8d56\u4e8e\u884c\u7684\u590d\u5236\u683c\u5f0f\n\n#\u7ec4\u590d\u5236\u8bbe\u7f6e\n transaction_write_set_extraction=XXHASH64 ##\u6307\u793aserver\u5fc5\u987b\u4e3a\u6bcf\u4e2a\u4e8b\u52a1\u6536\u96c6\u5199\u96c6\u5408\uff0c\u5e76\u4f7f\u7528XXHASH64\u54c8\u5e0c\u7b97\u6cd5\u5c06\u5176\u7f16\u7801\u4e3a\u6563\u5217\n loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"\n loose-group_replication_start_on_boot=off ##\u6307\u793a\u63d2\u4ef6\u5728server\u542f\u52a8\u65f6\u4e0d\u81ea\u52a8\u542f\u52a8\u7ec4\u590d\u5236\n loose-group_replication_local_address= "64.115.5.33:33061" #\u6bcf\u4e2a\u8282\u70b9\u6b64\u5904\u4e3a\u672c\u673a\u7684IP\u53ca\u7aef\u53e3\n loose-group_replication_group_seeds= "64.115.5.100:33061,64.115.5.200:33061" #MGR\u7ec4\u7684\u6240\u6709IP\u53ca\u7aef\u53e3\n loose-group_replication_bootstrap_group=off ##\u914d\u7f6e\u662f\u5426\u81ea\u52a8\u5f15\u5bfc\u7ec4\n loose-group_replication_ip_whitelist="127.0.0.1,64.115.5.0\/24" ##\u7528\u6237\u767d\u540d\u5355\n loose-group_replication_enforce_update_everywhere_checks=ON ##\u591a\u4e3b\u6a21\u5f0f\u4e0b\u4e3a\u591a\u4e3b\u66f4\u65b0\u542f\u7528\u6216\u7981\u7528\u4e25\u683c\u4e00\u81f4\u6027\u68c0\u67e5\n loose-group_replication_single_primary_mode=OFF ##\u8bbe\u7f6e\u7ec4\u81ea\u52a8\u9009\u62e9\u4e00\u4e2aserver\u6765\u5904\u7406\u8bfb\/\u5199\u5de5\u4f5c\n ##group_replication_member_weight=100 #\u6743\u91cd\uff0c\u5982\u679c\u591a\u4e2a\u670d\u52a1\u5668\u6743\u91cd\u76f8\u540c\u4f1a\u6839\u636eserver_uuid\u6309\u5b57\u5178\u987a\u5e8f\u548c\u9009\u62e9\u7b2c\u4e00\u4e2a\u3002\n loose-group_replication_enforce_update_everywhere_checks=OFF ##\u5355\u4e3b\u6a21\u5f0f\u4e0b\u4e00\u81f4\u6027\u68c0\u67e5\u53ef\u4ee5\u5173\u95ed\n loose-group_replication_single_primary_mode=ON ##\u5355\u4e3b\u6a21\u5f0f\n<\/code><\/pre>\n
\n
- \u542f\u52a8\u4fee\u6539\u5bc6\u7801<\/li>\n<\/ul>\n
#\u542f\u52a8\u6570\u636e\uff0c\u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\nsystemctl start mysqld && systemctl enable mysqld\n#\u67e5\u770b\u8fd0\u884c\u72b6\u6001\nsystemctl status mysqld.service\n<\/code><\/pre>\n
\n
- \u52a0\u8f7dMGR\u63d2\u4ef6\uff0c\u521b\u5efa\u540c\u6b65\u8d26\u53f7<\/li>\n<\/ul>\n
# \u5b89\u88c5MGR\u63d2\u4ef6\nmysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';\n\n#\u4fee\u6539ROOT\u8d26\u6237\u521d\u59cb\u5bc6\u7801\ngrep "password" \/var\/log\/mysqld.log\nmysql -uroot -p\nmysql> SET SQL_LOG_BIN=0; #\u5173\u95ed\u4e8c\u8fdb\u5236\u65e5\u5fd7\nmysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'WANG_feng123';\nmysql> flush privileges; \n#\u521b\u5efa\u7ec4\u590d\u5236\u7528\u6237\nmysql> CREATE USER rpl_user@'%' IDENTIFIED BY 'rpl_user123W'; #\u521b\u5efa\u7528\u6237\u8bbe\u7f6e\u5bc6\u7801\nmysql> GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%'; #\u6388\u6743\nmysql> FLUSH PRIVILEGES; #\u5237\u65b0\u6743\u9650\nmysql> SET SQL_LOG_BIN=1; #\u6253\u5f00\u4e8c\u8fdb\u5236\u65e5\u5fd7\nmysql> CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='rpl_user123W' FOR CHANNEL 'group_replication_recovery'; #\u8bbe\u7f6e\u7528\u6237\u5bc6\u7801\n<\/code><\/pre>\n
\n
- \u542f\u52a8MGR\u5355\u4e3b\u6a21\u5f0fMaster\u6267\u884c<\/em><\/li>\n<\/ul>\n
# \u542f\u52a8MGR\uff0c\u5728\u4e3b\u5e93master\u4e0a\u6267\u884c\nmysql> SET GLOBAL group_replication_bootstrap_group=ON; ##\u8bbe\u7f6egroup_replication_bootstrap_group\u4e3aON\u662f\u4e3a\u4e86\u6807\u793a\u4ee5\u540e\u52a0\u5165\u96c6\u7fa4\u7684\u670d\u52a1\u5668\u4ee5\u8fd9\u53f0\u670d\u52a1\u5668\u4e3a\u57fa\u51c6\uff0c\u4ee5\u540e\u52a0\u5165\u7684\u5c31\u4e0d\u9700\u8981\u8bbe\u7f6e,\u8bbe\u7f6egroup_replication_bootstrap_group \u53ea\u9700\u8981\u5728master\u4e0a\u6267\u884c\u4e00\u6b21\uff0c\u53e6\u5916\u4e24\u4e2a\u5b9e\u4f8b\u4e0d\u6267\u884c\u8fd9\u53e5\nmysql> START GROUP_REPLICATION; ##\u4f5c\u4e3a\u9996\u4e2a\u8282\u70b9\u542f\u52a8MGR\u96c6\u7fa4\nmysql> SET GLOBAL group_replication_bootstrap_group=OFF;\n# \u67e5\u770bMGR\u7ec4\u4fe1\u606f\nmysql> SELECT * FROM performance_schema.replication_group_members;\n<\/code><\/pre>\n
<\/p>\n
\n
- Slave\u8282\u70b9\u52a0\u5165\u7ec4<\/li>\n<\/ul>\n
#slave\u8282\u70b9\u6267\u884c\nmysql> START GROUP_REPLICATION;\nmysql> SELECT * FROM performance_schema.replication_group_members;\n<\/code><\/pre>\n
\n\u6ce8\uff1a \u524d\u9762\u7684\u7528\u6237\u5bc6\u7801\u4fee\u6539\u548c\u521b\u5efa\u7528\u6237\u64cd\u4f5c\u5fc5\u987b\u8bbe\u7f6ebinlog\u4e0d\u8bb0\u5f55\uff0c\u6267\u884c\u540e\u518d\u6253\u5f00\uff0c\u5426\u5219\u4f1a\u5f15\u8d77START GROUP_REPLICATION\u6267\u884c\u62a5\u9519:\nERROR 3092 (HY000): The server is not configured properly to be an active member of the group. Please see more details on error log.\n\n\u89e3\u51b3\u65b9\u6848\u662f\uff1a\u6839\u636e\u63d0\u793a\u6253\u5f00group_replication_allow_local_disjoint_gtids_join\u9009\u9879\uff0cmysql\u547d\u4ee4\u884c\u6267\u884c:\nmysql> set global group_replication_allow_local_disjoint_gtids_join=ON;\n\u7136\u540e\u518d\u6267\u884c:\nmysql> start group_replication;\n<\/code><\/pre>\n<\/blockquote>\n
\u67e5\u770b\u72b6\u6001\u4e3aONLINE ,\u4e3b\u8282\u70b9\u4e3aCentOS76,\u53ea\u6709\u4e3b\u8282\u70b9\u53ef\u4ee5\u5199\u5165\uff0c\u5176\u4ed6\u8282\u70b9\u53ea\u8bfb\uff0cMGR\u5355\u4e3b\u6a21\u5f0f\u642d\u5efa\u5b8c\u6210\u3002<\/p>\n
<\/p>\n
\u53c2\u8003\uff1a<\/h3>\n
MGR\u539f\u7406\u53ca\u90e8\u7f72<\/a><\/p>\n