{"id":1999,"date":"2020-07-29T22:17:50","date_gmt":"2020-07-29T14:17:50","guid":{"rendered":"http:\/\/39.97.231.10\/?p=1999"},"modified":"2020-07-29T22:17:50","modified_gmt":"2020-07-29T14:17:50","slug":"mysql-8-0-%e5%85%8b%e9%9a%86clone%e6%8f%92%e4%bb%b6%e5%bf%ab%e9%80%9f%e6%90%ad%e5%bb%ba%e4%b8%bb%e4%bb%8e%e5%a4%8d%e5%88%b6","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=1999","title":{"rendered":"MySQL 8.0 \u514b\u9686(clone)\u63d2\u4ef6\u5feb\u901f\u642d\u5efa\u4e3b\u4ece\u590d\u5236"},"content":{"rendered":"<div>\n<h2>MySQL 8.0 clone\u63d2\u4ef6\u63d0\u4f9b\u4ece\u4e00\u4e2a\u5b9e\u4f8b\u514b\u9686\u6570\u636e\u7684\u529f\u80fd\uff0c\u514b\u9686\u529f\u80fd\u63d0\u4f9b\u4e86\u66f4\u6709\u6548\u7684\u65b9\u5f0f\u6765\u5feb\u901f\u521b\u5efaMySQL\u5b9e\u4f8b\uff0c\u642d\u5efa\u4e3b\u4ece\u590d\u5236\u548c\u7ec4\u590d\u5236\u3002\u672c\u6587\u4ecb\u7ecd\u4f7f\u7528 MySQL 8.0 clone \u63d2\u4ef6\u5feb\u901f\u642d\u5efa\u4e3b\u4ece\u590d\u5236\u7684\u65b9\u6cd5\u3002<\/h2>\n<\/div>\n<div>\n<div>\n<div><\/div>\n<div>\u73af\u5883\uff1a<\/div>\n<ul>\n<li>\n<div>mysql 8.0.19<\/div>\n<\/li>\n<li>\n<div>\u4e3b\u5e93\uff1a192.168.56.201<\/div>\n<\/li>\n<li>\n<div>\u4ece\u5e93\uff1a192.168.56.202<\/div>\n<\/li>\n<\/ul>\n<div><\/div>\n<div>\u672c\u6587\u5c06\u901a\u8fc7\u5b9e\u4f8b\u64cd\u4f5c\uff0c\u5b9e\u73b0\u4ece\u5e93\u7531\u4e3b\u5e93\u514b\u9686\uff0c\u514b\u9686\u5b8c\u6210\u540e\uff0c\u642d\u5efa\u4e3b\u4ece\u590d\u5236\u3002<\/div>\n<div><\/div>\n<div>1\u3001\u5b89\u88c5clone\u63d2\u4ef6<\/div>\n<div><\/div>\n<div>\u4e3b\u3001\u4ece\u8282\u70b9\u90fd\u9700\u8981\u5b89\u88c5\u3002<\/div>\n<div><\/div>\n<div>\n<div># \u5b89\u88c5\u514b\u9686\u63d2\u4ef6<\/div>\n<div>INSTALL PLUGIN clone SONAME \\&#8217;mysql_clone.so\\&#8217;;<\/div>\n<div><\/div>\n<div># \u68c0\u67e5\u63d2\u4ef6\u662f\u5426\u5b89\u88c5\u6210\u529f<\/div>\n<div>mysql&gt; SELECT PLUGIN_NAME,PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME=\\&#8217;clone\\&#8217;;<\/div>\n<div>+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+<\/div>\n<div>| PLUGIN_NAME | PLUGIN_STATUS |<\/div>\n<div>+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+<\/div>\n<div>| clone \u00a0 \u00a0 \u00a0 | ACTIVE \u00a0 \u00a0 \u00a0 \u00a0|<\/div>\n<div>+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;+<\/div>\n<\/div>\n<div><\/div>\n<div>2\u3001\u521b\u5efa\u7528\u6237\u5e76\u6388\u6743<\/div>\n<div><\/div>\n<div>\u521b\u5efa\u590d\u5236\u8d26\u53f7\uff0c\u53ea\u9700\u8981\u5728\u4e3b\u5e93\u521b\u5efa\uff0c\u5728\u514b\u9686\u5b8c\u6210\u540e\uff0c\u642d\u5efa\u4e3b\u4ece\u590d\u5236\u4f7f\u7528\u3002<\/div>\n<div>\n<div>#\u00a0\u5728\u4e3b\u5e93\u4e0a\u521b\u5efa\u590d\u5236\u8d26\u53f7<\/div>\n<div>create user repl@\\&#8217;%\\&#8217; identified by \\&#8217;123456\\&#8217;;<\/div>\n<div>grant\u00a0\u00a0replication slave on *.* to \\&#8217;repl\\&#8217;@\\&#8217;%\\&#8217;;<\/div>\n<\/div>\n<div><\/div>\n<div>\u514b\u9686\u6e90\uff0c\u4e5f\u5c31\u662f\u4e3b\u5e93\uff0c\u9700\u8981\u6709\u3010BACKUP_ADMIN\u3011\u6743\u9650\uff0c\u514b\u9686\u53d7\u4f53\uff0c\u4e5f\u5c31\u662f\u4ece\u5e93\uff0c\u9700\u8981\u3010CLONE_ADMIN\u3011\u6743\u9650\uff0c\u4e3a\u4e86\u65b9\u4fbf\uff0c\u6211\u4eec\u5728\u4e24\u4e2a\u673a\u5668\u4e0a\u628a\u8fd9\u4e24\u4e2a\u6743\u9650\u90fd\u52a0\u4e0a\u3002<\/div>\n<div><\/div>\n<div>\n<div>#\u00a0\u4e3b\u3001\u4ece\u5e93\u90fd\u9700\u8981\u521b\u5efa\u514b\u9686\u7528\u6237\u5e76\u6388\u6743<\/div>\n<div>create user \\&#8217;clone_user\\&#8217;@\\&#8217;%\\&#8217;\u00a0identified by \\&#8217;123456\\&#8217;;<\/div>\n<div>grant BACKUP_ADMIN on *.* to \\&#8217;clone_user\\&#8217;@\\&#8217;%\\&#8217;;<\/div>\n<div>grant CLONE_ADMIN on *.* to \\&#8217;clone_user\\&#8217;@\\&#8217;%\\&#8217;;<\/div>\n<\/div>\n<div><\/div>\n<div>3\u3001\u6267\u884c\u514b\u9686\u4efb\u52a1\uff1a<\/div>\n<div><\/div>\n<div>\u5728\u4ece\u5e93\u4e0a\u6267\u884c\u514b\u9686\u547d\u4ee4\uff0c\u5982\u4e0b\uff1a<\/div>\n<div><\/div>\n<div>\n<div>#\u00a0\u8bbe\u7f6e\u514b\u9686\u6e90\uff0c\u5c06clone_valid_donor_list\u8bbe\u7f6e\u4e3a\u4e3b\u5e93<\/div>\n<div>SET GLOBAL clone_valid_donor_list = \\&#8217;192.168.56.201:3306\\&#8217;;<\/div>\n<div><\/div>\n<div>#\u00a0\u5f00\u59cb\u514b\u9686<\/div>\n<div>CLONE INSTANCE FROM \\&#8217;clone_user\\&#8217;@\\&#8217;192.168.56.201\\&#8217;:3306 IDENTIFIED BY \\&#8217;123456\\&#8217;;<\/div>\n<\/div>\n<div><\/div>\n<div>\u5728\u6267\u884c\u514b\u9686\u65f6\uff0c\u4f1a\u5148\u5c06\u4ece\u5e93\u672c\u5730\u7684\u6570\u636e\u76ee\u5f55\u6e05\u7a7a\uff0c\u8bf7\u786e\u4fdd\u672c\u5730\u6570\u636e\u76ee\u5f55\u6ca1\u6709\u91cd\u8981\u6570\u636e\uff0c\u53ef\u4ee5\u6e05\u7a7a\uff0c\u5426\u5219\u5c06\u5bfc\u81f4\u672c\u5730\u6570\u636e\u4e22\u5931\u3002<\/div>\n<div><\/div>\n<div>\u514b\u9686\u5b8c\u6210\u540e\uff0c\u4ece\u5e93MySQL\u5b9e\u4f8b\u81ea\u52a8\u91cd\u542f\u3002<\/div>\n<div><\/div>\n<div>4\u3001\u542f\u52a8\u590d\u5236<\/div>\n<div><\/div>\n<div>\u4ece\u5e93\u91cd\u542f\u5b8c\u6210\u540e\uff0c\u67e5\u770bBinlog\u6587\u4ef6\u3001\u4f4d\u7f6e\u548c\u5df2\u7ecf\u6267\u884c\u7684GTID\u3002<\/div>\n<div>\n<div>SELECT BINLOG_FILE, BINLOG_POSITION FROM performance_schema.clone_status;<\/div>\n<div>SELECT @@GLOBAL.GTID_EXECUTED;<\/div>\n<\/div>\n<div><\/div>\n<div>\u91cd\u5efa\u590d\u5236\uff1a<\/div>\n<div>\n<div>change master to master_host=\\&#8217;192.168.56.201\\&#8217;,master_port=3306,master_user=\\&#8217;repl\\&#8217;,master_password=\\&#8217;123456\\&#8217;,master_auto_position=1;<\/div>\n<div><\/div>\n<div># \u542f\u52a8\u590d\u5236\uff0c\u67e5\u770b\u590d\u5236\u72b6\u6001<\/div>\n<div>start slave;<\/div>\n<div>show slave status\\\\G<\/div>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div>5\u3001\u514b\u9686\u8fc7\u7a0b\u4e2d\u7684\u72b6\u6001\u76d1\u63a7<\/div>\n<div><\/div>\n<div>MySQL performance_schema\u5e93\u4e2d\u63d0\u4f9b\u4e86clone_status\u548cclone_progress\u6765\u67e5\u8be2\u514b\u9686\u7684\u72b6\u6001\u4e0e\u8fdb\u5ea6\uff0c\u4ee5\u4fbf\u5bf9\u514b\u9686\u8fc7\u7a0b\u8fdb\u884c\u76d1\u63a7\u3002<\/div>\n<div><\/div>\n<div>\n<div>SELECT STATE, ERROR_NO, ERROR_MESSAGE FROM performance_schema.clone_status;<\/div>\n<div>SELECT STAGE, STATE, END_TIME FROM performance_schema.clone_progress;<\/div>\n<\/div>\n<div><\/div>\n<div>6\u3001\u4f7f\u7528\u9650\u5236<\/div>\n<div><\/div>\n<div>clone\u529f\u80fd\u4f7f\u7528\u9650\u5236\uff1a<\/div>\n<ul>\n<li>\n<div>\u514b\u9686\u64cd\u4f5c\u671f\u95f4\uff0c\u4e0d\u5141\u8bb8DDL\uff0c\u5305\u62ectruncate table<\/div>\n<\/li>\n<li>\n<div>\u514b\u9686\u7684\u4e24\u4e2aMySQL\u5b9e\u4f8b\u7248\u672c\u5fc5\u987b\u4e00\u81f4<\/div>\n<\/li>\n<li>\n<div>\u4e00\u6b21\u53ea\u80fd\u514b\u9686\u4e00\u4e2a\u5b9e\u4f8b<\/div>\n<\/li>\n<li>\n<div>\u4e0d\u652f\u6301\u514b\u9686MySQL\u914d\u7f6e\u4fe1\u606f<\/div>\n<\/li>\n<li>\n<div>\u4e0d\u652f\u6301\u514b\u9686Binlog\u65e5\u5fd7<\/div>\n<\/li>\n<li>\n<div>\u53ea\u652f\u6301\u514b\u9686Innodb\u5b58\u50a8\u5f15\u64ce\u7684\u6570\u636e\uff0c\u5176\u4ed6\u5b58\u50a8\u5f15\u64ce\u7684\u6570\u636e\u4e0d\u4f1a\u88ab\u514b\u9686<\/div>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>MySQL 8.0 clone\u63d2\u4ef6\u63d0\u4f9b\u4ece\u4e00\u4e2a\u5b9e\u4f8b\u514b\u9686\u6570\u636e\u7684\u529f\u80fd\uff0c\u514b\u9686\u529f\u80fd\u63d0\u4f9b\u4e86\u66f4\u6709\u6548\u7684\u65b9\u5f0f\u6765\u5feb\u901f\u521b\u5efaMySQL &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=1999\"> <span class=\"screen-reader-text\">MySQL 8.0 \u514b\u9686(clone)\u63d2\u4ef6\u5feb\u901f\u642d\u5efa\u4e3b\u4ece\u590d\u5236<\/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 8.0 clone\u63d2\u4ef6\u63d0\u4f9b\u4ece\u4e00\u4e2a\u5b9e\u4f8b\u514b\u9686\u6570\u636e\u7684\u529f\u80fd\uff0c\u514b\u9686\u529f\u80fd\u63d0\u4f9b\u4e86\u66f4\u6709\u6548\u7684\u65b9\u5f0f\u6765\u5feb\u901f\u521b\u5efaMySQL&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1999"}],"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=1999"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1999\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1999"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}