{"id":261666,"date":"2023-02-16T09:23:21","date_gmt":"2023-02-16T01:23:21","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=261666"},"modified":"2023-01-16T15:24:50","modified_gmt":"2023-01-16T07:24:50","slug":"mysql-case","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/mysql-case.html","title":{"rendered":"MySQL \u4e3b\u4ece\u6a21\u5f0f\u5b9e\u6218"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u4e3a\u4e86\u4fdd\u8bc1\u9ad8\u53ef\u7528\uff0c\u4e4b\u524d\u5728\u6d4b\u8bd5\u73af\u5883\u90e8\u7f72\u4e86\u4e00\u5957 MySQL \u53cc\u4e3b\u6a21\u5f0f\uff0c\u5f53\u4e00\u4e2a\u4e3b\u5e93\u670d\u52a1\u51fa\u73b0\u5f02\u5e38\uff0c\u53ef\u4ee5\u5c06\u6d41\u91cf\u5207\u5230\u53e6\u5916\u4e00\u4e2a\u4e3b\u5e93\uff0c\u4e24\u4e2a\u4e3b\u5e93\u4e4b\u95f4\u76f8\u4e92\u540c\u6b65\u6570\u636e\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u672c\u6587\u4e3b\u8981\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n

\"\"<\/p>\n

\u4e00\u3001\u80cc\u666f<\/strong><\/div>\n

\u4e3a\u4e86\u4fdd\u8bc1\u9ad8\u53ef\u7528\uff0c\u4e4b\u524d\u5728\u6d4b\u8bd5\u73af\u5883\u90e8\u7f72\u4e86\u4e00\u5957 MySQL \u53cc\u4e3b\u6a21\u5f0f\uff0c\u5f53\u4e00\u4e2a\u4e3b\u5e93\u670d\u52a1\u51fa\u73b0\u5f02\u5e38\uff0c\u53ef\u4ee5\u5c06\u6d41\u91cf\u5207\u5230\u53e6\u5916\u4e00\u4e2a\u4e3b\u5e93\uff0c\u4e24\u4e2a\u4e3b\u5e93\u4e4b\u95f4\u76f8\u4e92\u540c\u6b65\u6570\u636e\u3002<\/p>\n

\u53cc\u4e3b\u6a21\u5f0f<\/strong><\/div>\n

\u53cc\u4e3b\u6a21\u5f0f\u7684\u539f\u7406\u56fe\u5982\u4e0b\uff1a<\/p>\n

\"\"<\/p>\n

\u4f46\u662f\u7ecf\u5e38\u51fa\u73b0\u6570\u636e\u51b2\u7a81\u7684\u95ee\u9898\uff0c\u4e8e\u662f\u6211\u4eec\u53c8\u628a\u200b\u200b\u53cc\u4e3b\u6a21\u5f0f\u200b\u200b\u6539\u4e3a\u4e86\u200b\u200b\u4e3b\u4ece\u8bfb\u5199\u5206\u79bb\u6a21\u5f0f\u200b\u200b\u3002\u4e3b\u5e93\u4f5c\u4e3a\u8bfb\u5199\u5e93\uff0c\u518d\u52a0\u4e0a\u4e00\u4e2a\u4ece\u5e93\u7528\u6765\u505a I\/O \u5bc6\u96c6\u578b\u7684\u4efb\u52a1\uff08\u5982\u5927\u91cf\u7684\u6570\u636e\u7edf\u8ba1\u64cd\u4f5c\uff09\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n

\"\"<\/p>\n

\u53e6\u5916\u4ece\u5e93\u590d\u5236\u7684\u6a21\u5f0f\u91c7\u7528\u200b\u200b\u4f4d\u70b9\u200b\u200b\u7684\u65b9\u5f0f\uff1a\u6307\u5b9a binlog \u6587\u4ef6\u548c binlog \u4f4d\u7f6e\uff0c\u8fd9\u6837\u4ece\u5e93\u5c31\u77e5\u9053\u4e86\u590d\u5236\u7684\u8d77\u59cb\u4f4d\u7f6e\u3002(\u4e0b\u6587\u4f1a\u8bb2\u89e3\u8fd9\u79cd\u65b9\u5f0f\uff09<\/p>\n

\u867d\u7136\u6539\u4e3a\u4e86\u4e3b\u4ece\u6a21\u5f0f\uff0c\u4f46\u4f9d\u65e7\u9047\u5230\u4e86\u4e9b\u95ee\u9898\uff1a<\/p>\n

\u95ee\u9898 1\uff1a\u4ece\u5e93 B \u590d\u5236\u6570\u636e\u65f6\uff0c\u51fa\u73b0\u4e86\u4e3b\u952e\u51b2\u7a81\u95ee\u9898\uff0c\u5bfc\u81f4\u540c\u6b65\u5931\u8d25\uff0c\u4ece\u5e93\u505c\u6b62\u590d\u5236\u3002\u731c\u6d4b\u56e0\u4e3b\u5e93\u914d\u7f6e\u7684 binlog \u65e5\u5fd7\u7684\u683c\u5f0f\u4e3a mixed\uff0c\u4ece\u5e93\u540c\u6b65\u65f6\u51fa\u73b0\u4e0d\u4e00\u81f4\u7684\u60c5\u51b5\u3002
\n\u95ee\u9898 2\uff1a\u4ece\u5e93 B \u505c\u6b62\u590d\u5236\u540e\uff0c\u5bfc\u81f4\u5f88\u591a\u6570\u636e\u672a\u540c\u6b65\u5230\u4ece\u5e93\uff0c\u51fa\u73b0\u4e3b\u4ece\u5927\u91cf\u6570\u636e\u4e0d\u4e00\u81f4\u7684\u60c5\u51b5\u3002
\n\u95ee\u9898 3\uff1a\u4ece\u5e93 B \u60f3\u8981\u6062\u590d\u590d\u5236\uff0c\u5fc5\u987b\u5148\u89e3\u51b3\u540c\u6b65\u5931\u8d25\u7684\u95ee\u9898\u624d\u80fd\u6062\u590d\u3002\u6392\u67e5\u96be\u5ea6\u8f83\u5927\uff0c\u8017\u65f6\u3002
\n\u95ee\u9898 4\uff1a\u4ece\u5e93 B \u6062\u590d\u65f6\uff0c\u5fc5\u987b\u77e5\u9053\u540c\u6b65\u4f4d\u70b9\uff0c\u4e5f\u5c31\u662f\u4ece\u54ea\u4e2a binlog \u6587\u4ef6\u548c binlog \u4f4d\u7f6e\u65ad\u5f00\u590d\u5236\u7684\uff0c\u4e14\u5373\u4f7f\u627e\u5230\u4e86\u4f4d\u70b9\uff0c\u4e5f\u4e0d\u662f\u7cbe\u786e\u7684\u3002
\n\u95ee\u9898 5\uff1a\u4ece\u5e93 B \u56e0\u540c\u6b65\u5f02\u5e38\u5bfc\u81f4\u505c\u6b62\u590d\u5236\u5230\u6062\u590d\u590d\u5236\u8fd9\u6bb5\u671f\u95f4\uff0c\u4e3b\u5e93 A \u81ea\u52a8\u6e05\u7406\u4e86\u51e0\u5929\u524d\u7684 binlog \u65e5\u5fd7\uff0c\u800c\u8fd9\u4e9b\u65e5\u5fd7\u4ece\u5e93 B \u8fd8\u672a\u6765\u5f97\u53ca\u540c\u6b65\uff0c\u8fdb\u800c\u5bfc\u81f4\u518d\u6b21\u540c\u6b65\u5931\u8d25\u3002
\n\u95ee\u9898 6\uff1a\u4e3b\u4ece\u5b58\u5728\u540c\u6b65\u5ef6\u8fdf\u3002
\n\u8fd9\u7bc7\u6211\u4eec\u6765\u63a2\u8ba8\u4e0b\u95ee\u9898 4 \u548c\u95ee\u9898 6\u3002<\/p>\n

\u5176\u4e2d\u95ee\u9898 4 \u662f\u4e00\u4e2a\u6bd4\u8f83\u5934\u75bc\u7684\u95ee\u9898\uff0c\u6211\u4eec\u4e00\u822c\u662f\u901a\u8fc7\u67e5\u770b\u4ece\u5e93 B \u5f53\u524d\u7684\u540c\u6b65\u72b6\u6001\u62ff\u5230\u540c\u6b65\u4f4d\u70b9\uff0c\u7136\u540e\u8bbe\u7f6e\u540c\u6b65\u4f4d\u70b9\u540e\u3002\u4f46\u662f\u91cd\u65b0\u542f\u52a8\u540c\u6b65\u7684\u65f6\u5019\u53c8\u4f1a\u51fa\u73b0\u540c\u6b65\u5f02\u5e38\uff0c\u6bd4\u5982\u4ece\u5e93 B \u53ef\u80fd\u4f1a\u51fa\u73b0 Duplicate entry \u2018id_of_R\u2019 for key \u2018PRIMARY\u2019 \u9519\u8bef\uff0c\u63d0\u793a\u51fa\u73b0\u4e86\u4e3b\u952e\u51b2\u7a81\uff0c\u7136\u540e\u505c\u6b62\u540c\u6b65\u3002<\/p>\n

\u4e3a\u4e86\u51cf\u5c11\u4f4d\u70b9\u540c\u6b65\u5f15\u5165\u7684\u590d\u6742\u5ea6\uff0c\u6211\u4eec\u5207\u6362\u6210\u4e86 GTID \u6a21\u5f0f\u3002<\/p>\n

\u5bf9\u4e8e\u95ee\u9898 6\uff0c\u672c\u7bc7\u4e5f\u4ec5\u9650\u4e8e\u63a2\u8ba8\u5982\u4f55\u89c2\u5bdf\u5ef6\u8fdf\uff0c\u5bf9\u4e8e\u5982\u4f55\u51cf\u5c11\u5ef6\u8fdf\u4e0d\u5728\u672c\u7bc7\u63a2\u8ba8\u8303\u56f4\u4e4b\u5185\u3002<\/p>\n

\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u5c55\u5f00\u770b\u4e0b\u4f4d\u70b9\u540c\u6b65\u7684\u75db\u70b9\u3002<\/p>\n

\u4e8c\u3001\u4f4d\u70b9\u540c\u6b65\u7684\u75db\u70b9<\/strong><\/div>\n
2.1 \u901a\u8fc7\u4f4d\u70b9\u540c\u6b65\u7684\u539f\u7406\u56fe<\/strong><\/span><\/div>\n

\u4e3a\u4e86\u66f4\u6e05\u6670\u5730\u7406\u89e3\u4e3b\u4ece\u91c7\u7528\u4f4d\u70b9\u540c\u6b65\u7684\u539f\u7406\uff0c\u8fd9\u91cc\u6709\u4e00\u4e2a\u539f\u7406\u56fe\uff1a<\/p>\n

\"\"<\/p>\n

  • \u4e3b\u5e93\u4f1a\u751f\u6210\u591a\u4e2a binlog \u65e5\u5fd7\u6587\u4ef6\u3002<\/li>\n
  • \u4ece\u5e93\u7684I\/O \u7ebf\u7a0b\u8bf7\u6c42\u6307\u5b9a\u6587\u4ef6\u548c\u6307\u5b9a\u4f4d\u7f6e\u7684 binlog \u65e5\u5fd7\u6587\u4ef6\uff08\u4f4d\u70b9\uff09\u3002<\/li>\n
  • \u4e3b\u5e93 dump \u7ebf\u7a0b\u83b7\u53d6\u6307\u5b9a\u4f4d\u70b9\u7684 binlog \u65e5\u5fd7\u3002<\/li>\n
  • \u4e3b\u5e93\u6309\u7167\u4ece\u5e93\u53d1\u9001\u7ed9\u6765\u7684\u4f4d\u70b9\u4fe1\u606f\u8bfb\u53d6 binlog\uff0c\u7136\u540e\u63a8\u9001 binlog \u7ed9\u4ece\u5e93\u3002<\/li>\n
  • \u4ece\u5e93\u5c06\u5f97\u5230\u7684 binlog \u5199\u5230\u672c\u5730\u7684 relay log (\u4e2d\u7ee7\u65e5\u5fd7) \u6587\u4ef6\u4e2d\u3002<\/li>\n
  • \u4ece\u5e93\u7684 SQL \u7ebf\u7a0b\u8bfb\u53d6\u548c\u89e3\u6790 relay log \u6587\u4ef6\u3002<\/li>\n
  • \u4ece\u5e93\u7684 SQL \u7ebf\u7a0b\u91cd\u653e relay log \u4e2d\u7684\u547d\u4ee4\u3002<\/li>\n

    \u5f53\u6211\u4eec\u4f7f\u7528\u4f4d\u70b9\u540c\u6b65\u7684\u65b9\u5f0f\u65f6\uff0c\u4e24\u79cd\u573a\u666f\u4e0b\u7684\u64cd\u4f5c\u6b65\u9aa4\u6bd4\u8f83\u590d\u6742\u3002<\/p>\n

    2.2 \u75db\u70b9<\/strong><\/span><\/div>\n

    \u75db\u70b91\uff1a\u9996\u6b21\u5f00\u542f\u4e3b\u4ece\u590d\u5236\u7684\u6b65\u9aa4\u590d\u6742
    \n\u7b2c\u4e00\u6b21\u5f00\u542f\u4e3b\u4ece\u540c\u6b65\u65f6\uff0c\u8981\u6c42\u4ece\u5e93\u548c\u4e3b\u5e93\u662f\u4e00\u81f4\u7684\u3002
    \n\u627e\u5230\u4e3b\u5e93\u7684 binlog \u4f4d\u70b9\u3002
    \n\u8bbe\u7f6e\u4ece\u5e93\u7684 binlog \u4f4d\u70b9\u3002
    \n\u5f00\u542f\u4ece\u5e93\u7684\u590d\u5236\u7ebf\u7a0b\u3002<\/p>\n

    \u75db\u70b92\uff1a\u6062\u590d\u4e3b\u4ece\u590d\u5236\u7684\u6b65\u9aa4\u590d\u6742
    \n\u627e\u5230\u4ece\u5e93\u590d\u5236\u7ebf\u7a0b\u505c\u6b62\u65f6\u7684\u4f4d\u70b9\u3002
    \n\u89e3\u51b3\u590d\u5236\u5f02\u5e38\u7684\u4e8b\u52a1\u3002\u65e0\u6cd5\u89e3\u51b3\u65f6\u5c31\u9700\u8981\u624b\u52a8\u8df3\u8fc7\u6307\u5b9a\u7c7b\u578b\u7684\u9519\u8bef\uff0c\u6bd4\u5982\u901a\u8fc7\u8bbe\u7f6eslave_skip_errors=1032,1062\u3002\u5f53\u7136\u8fd9\u4e2a\u524d\u63d0\u6761\u4ef6\u662f\u8df3\u8fc7\u8fd9\u7c7b\u9519\u8bef\u662f\u65e0\u635f\u7684\u3002\uff081062 \u9519\u8bef\u662f\u63d2\u5165\u6570\u636e\u65f6\u552f\u4e00\u952e\u51b2\u7a81\uff1b1032 \u9519\u8bef\u662f\u5220\u9664\u6570\u636e\u65f6\u627e\u4e0d\u5230\u884c\uff09<\/p>\n

    \u4e0d\u8bba\u662f\u9996\u6b21\u5f00\u542f\u540c\u6b65\u65f6\u9700\u8981\u627e\u4f4d\u70b9\u548c\u8bbe\u7f6e\u4f4d\u70b9\uff0c\u8fd8\u662f\u6062\u590d\u4e3b\u4ece\u590d\u5236\u65f6\uff0c\u8bbe\u7f6e\u4f4d\u70b9\u548c\u5ffd\u7565\u9519\u8bef\uff0c\u8fd9\u4e9b\u6b65\u9aa4\u90fd\u663e\u5f97\u8fc7\u4e8e\u590d\u6742\uff0c\u800c\u4e14\u5bb9\u6613\u51fa\u9519\u3002\u6240\u4ee5 MySQL 5.6 \u7248\u672c\u5f15\u5165\u4e86 GTID\uff0c\u5f7b\u5e95\u89e3\u51b3\u4e86\u8fd9\u4e2a\u56f0\u96be\u3002<\/p>\n

    \u4e09\u3001GTID \u65b9\u6848<\/strong><\/div>\n
    3.1 GTID \u662f\u4ec0\u4e48\uff1f<\/strong><\/span><\/div>\n

    GTID \u7684\u5168\u79f0\u662f Global Transaction Identifier\uff0c\u5168\u5c40\u4e8b\u52a1 ID\uff0c\u5f53\u4e00\u4e2a\u4e8b\u52a1\u63d0\u4ea4\u65f6\uff0c\u5c31\u4f1a\u751f\u6210\u4e00\u4e2a GTID\uff0c\u76f8\u5f53\u4e8e\u4e8b\u52a1\u7684\u552f\u4e00\u6807\u8bc6\u3002<\/p>\n

    GTID \u957f\u8fd9\u6837\uff1a<\/p>\n

    c5d74746-d7ec-11ec-bf8f-0242ac110002:1<\/pre>\n

    \u7ed3\u6784\uff1a<\/p>\n

    GTID=server_uuid:gno<\/pre>\n

    server_uuid \u662f\u4e00\u4e2a\u5b9e\u4f8b\u7b2c\u4e00\u6b21\u542f\u52a8\u65f6\u81ea\u52a8\u751f\u6210\u7684\uff0c\u662f\u4e00\u4e2a\u5168\u5c40\u552f\u4e00\u7684\u503c\uff1b<\/p>\n

    gno \u662f\u4e00\u4e2a\u6574\u6570\uff0c\u521d\u59cb\u503c\u662f 1\uff0c\u6bcf\u6b21\u63d0\u4ea4\u4e8b\u52a1\u7684\u65f6\u5019\u5206\u914d\u7ed9\u8fd9\u4e2a\u4e8b\u52a1\uff0c\u5e76\u52a0 1\u3002<\/p>\n

    \u6bcf\u4e2a MySQL \u5b9e\u4f8b\u90fd\u7ef4\u62a4\u4e86\u4e00\u4e2a GTID \u96c6\u5408\uff0c\u7528\u6765\u5bf9\u5e94\u201c\u8fd9\u4e2a\u5b9e\u4f8b\u6267\u884c\u8fc7\u7684\u6240\u6709\u4e8b\u52a1\u201d\u3002<\/p>\n

    3.2 GTID \u7684\u4f18\u52bf<\/strong><\/span><\/div>\n
  • \u66f4\u7b80\u5355\u7684\u5b9e\u73b0 failover\uff0c\u4e0d\u7528\u4ee5\u524d\u90a3\u6837\u5728\u9700\u8981\u627e\u4f4d\u70b9\uff08log_file \u548c log_pos\uff09\u3002<\/li>\n
  • \u66f4\u7b80\u5355\u7684\u642d\u5efa\u4e3b\u4ece\u590d\u5236\u3002<\/li>\n
  • \u6bd4\u4f20\u7edf\u7684\u590d\u5236\u66f4\u52a0\u5b89\u5168\u3002<\/li>\n
  • GTID\u662f\u8fde\u7eed\u7684\u6ca1\u6709\u7a7a\u6d1e\u7684\uff0c\u4fdd\u8bc1\u6570\u636e\u7684\u4e00\u81f4\u6027\uff0c\u96f6\u4e22\u5931\u3002<\/li>\n
    3.3 \u5982\u4f55\u542f\u7528 GTID<\/strong><\/span><\/div>\n

    \u4fee\u6539\u4e3b\u5e93\u548c\u4ece\u5e93\u7684\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n

    #GTID:\r\ngtid_mode=on\r\nenforce_gtid_cnotallow=on<\/pre>\n

    \u4ece\u5e93\u914d\u7f6e\u540c\u6b65\u7684\u53c2\u6570\uff1a<\/p>\n

    CHANGE MASTER TO \r\nMASTER_HOST=$host_name \r\nMASTER_PORT=$port \r\nMASTER_USER=$user_name \r\nMASTER_PASSWORD=$password \r\nmaster_auto_positinotallow=1 <\/pre>\n

    \u5176\u4e2d master_auto_position \u6807\u8bc6\u4e3b\u4ece\u5173\u7cfb\u4f7f\u7528\u7684 GTID \u534f\u8bae\u3002<\/p>\n

    \u76f8\u6bd4\u4e4b\u524d\u7684\u914d\u7f6e\uff0cMASTER_LOG_FILE \u548c MASTER_LOG_POS \u53c2\u6570\u5df2\u7ecf\u4e0d\u9700\u8981\u4e86\u3002<\/p>\n

    3.4 GTID \u540c\u6b65\u65b9\u6848<\/strong><\/span><\/div>\n

    GTID \u540c\u6b65\u7684\u539f\u7406\u56fe\u3002<\/p>\n

    GTID \u65b9\u6848\uff1a\u4e3b\u5e93\u8ba1\u7b97\u4e3b\u5e93 GTID \u96c6\u5408\u548c\u4ece\u5e93 GTID \u7684\u96c6\u5408\u7684\u5dee\u96c6\uff0c\u4e3b\u5e93\u63a8\u9001\u5dee\u96c6 binlog \u7ed9\u4ece\u5e93\u3002<\/p>\n

    \u5f53\u4ece\u5e93\u8bbe\u7f6e\u5b8c\u540c\u6b65\u53c2\u6570\u540e\uff0c\u4e3b\u5e93 A \u7684GTID \u96c6\u5408\u8bb0\u4e3a\u96c6\u5408 x\uff0c\u4ece\u5e93 B \u7684 GTID \u96c6\u5408\u8bb0\u4e3a y\u3002\u4ece\u5e93\u540c\u6b65\u7684\u903b\u8f91\u5982\u4e0b\uff1a<\/p>\n

    \"\"<\/p>\n

  • \u4ece\u5e93 B \u6307\u5b9a\u4e3b\u5e93 A\uff0c\u57fa\u4e8e\u4e3b\u5907\u534f\u8bae\u7b80\u5386\u8fde\u63a5\u3002<\/li>\n
  • \u4ece\u5e93 B \u628a\u96c6\u5408 y \u53d1\u7ed9\u4e3b\u5e93 A\u3002<\/li>\n
  • \u4e3b\u5e93 A \u8ba1\u7b97\u51fa\u96c6\u5408 x \u548c\u96c6\u5408 y \u7684\u5dee\u96c6\uff0c\u4e5f\u5c31\u662f\u96c6\u5408 x \u4e2d\u5b58\u5728\uff0c\u96c6\u5408 y \u4e2d\u4e0d\u5b58\u5728\u7684 GTID \u96c6\u5408\u3002\u6bd4\u5982\u96c6\u5408 x \u662f 1~100\uff0c\u96c6\u5408 y \u662f 1~90\uff0c\u90a3\u4e48\u8fd9\u4e2a\u5dee\u96c6\u5c31\u662f 91~100\u3002\u8fd9\u91cc\u4f1a\u5224\u65ad\u96c6\u5408 x \u662f\u4e0d\u662f\u5305\u542b\u6709\u96c6\u5408 y \u7684\u6240\u6709 GTID\uff0c\u5982\u679c\u4e0d\u662f\u5219\u8bf4\u660e\u4e3b\u5e93 A \u5220\u9664\u4e86\u4ece\u5e93 B \u9700\u8981\u7684 binlog\uff0c\u4e3b\u5e93 A \u76f4\u63a5\u8fd4\u56de\u9519\u8bef\u3002<\/li>\n
  • \u4e3b\u5e93 A \u4ece\u81ea\u5df1\u7684 binlog \u6587\u4ef6\u91cc\u9762\uff0c\u627e\u5230\u7b2c\u4e00\u4e2a\u4e0d\u5728\u96c6\u5408 y \u4e2d\u7684\u4e8b\u52a1 GTID\uff0c\u4e5f\u5c31\u662f\u627e\u5230\u4e86 91\u3002<\/li>\n
  • \u4e3b\u5e93 A \u4ece GTID = 91 \u7684\u4e8b\u52a1\u5f00\u59cb\uff0c\u5f80\u540e\u8bfb binlog \u6587\u4ef6\uff0c\u6309\u987a\u5e8f\u53d6 binlog\uff0c\u7136\u540e\u53d1\u7ed9 B\u3002<\/li>\n
  • \u4ece\u5e93 B \u7684 I\/O \u7ebf\u7a0b\u8bfb\u53d6 binlog \u6587\u4ef6\u751f\u6210 relay log\uff0cSQL \u7ebf\u7a0b\u89e3\u6790 relay log\uff0c\u7136\u540e\u6267\u884c SQL \u8bed\u53e5\u3002<\/li>\n

    GTID \u540c\u6b65\u65b9\u6848\u548c\u4f4d\u70b9\u540c\u6b65\u7684\u65b9\u6848\u533a\u522b\u662f\uff1a<\/p>\n

  • \u4f4d\u70b9\u540c\u6b65\u65b9\u6848\u662f\u901a\u8fc7\u4eba\u5de5\u5728\u4ece\u5e93\u4e0a\u6307\u5b9a\u54ea\u4e2a\u4f4d\u70b9\uff0c\u4e3b\u5e93\u5c31\u53d1\u54ea\u4e2a\u4f4d\u70b9\uff0c\u4e0d\u505a\u65e5\u5fd7\u7684\u5b8c\u6574\u6027\u5224\u65ad\u3002<\/li>\n
  • \u800c GTID \u65b9\u6848\u662f\u901a\u8fc7\u4e3b\u5e93\u6765\u81ea\u52a8\u8ba1\u7b97\u4f4d\u70b9\u7684\uff0c\u4e0d\u9700\u8981\u4eba\u5de5\u53bb\u8bbe\u7f6e\u4f4d\u70b9\uff0c\u5bf9\u8fd0\u7ef4\u4eba\u5458\u53cb\u597d\u3002<\/li>\n
    \u56db\u3001\u5982\u4f55\u5224\u65ad\u4e3b\u4ece\u5e93\u662f\u5426\u6709\u5ef6\u8fdf<\/strong><\/div>\n

    \u4e0a\u9762\u63d0\u5230\u7684\u95ee\u9898 6 \u662f\u4e3b\u4ece\u8bfb\u5199\u5206\u79bb\u540e\uff0c\u4ece\u5e93\u590d\u5236\u5b58\u5728\u5ef6\u8fdf\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u63a2\u8ba8\u4e0b\u5982\u4f55\u89c2\u5bdf\u4e3b\u4ece\u5ef6\u8fdf\u591a\u5c11\u7684\u95ee\u9898\u3002<\/p>\n

    \u65b9\u6848\u4e00\uff1a\u5224\u65ad\u4ece\u5e93\u7684\u540c\u6b65\u72b6\u6001\u53c2\u6570 seconds_behind_master \u662f\u5426\u4e3a 0\u3002\uff08\u4e0d\u51c6\u786e\uff09<\/p>\n

    \u65b9\u6848\u4e8c\uff1a\u5bf9\u6bd4\u4f4d\u70b9\u786e\u4fdd\u4e3b\u5907\u65e0\u5ef6\u8fdf\u3002<\/p>\n

    \u65b9\u6848\u4e09\uff1a\u5bf9\u6bd4 GTID \u96c6\u5408\u786e\u4fdd\u4e3b\u5907\u65e0\u5ef6\u8fdf\u3002<\/p>\n

    \u65b9\u6848\u4e00\uff1a\u67e5\u770b seconds_behind_master<\/strong><\/span><\/div>\n

    \u53ef\u4ee5\u5728\u4ece\u5e93\u4e0a\u6267\u884c slow slave status \u547d\u4ee4\u6765\u770b\u6267\u884c\u7ed3\u679c\u91cc\u9762\u7684 \u200b\u200bseconds_behind_master\u200b\u200b \u53c2\u6570\u7684\u503c\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff0cSeconds_Behind_Master \u7b49\u4e8e 0<\/p>\n

    \"\"<\/p>\n

    Seconds_Behind_Master \u7684\u5355\u4f4d\u662f\u79d2\uff0c\u6240\u4ee5\u7cbe\u5ea6\u4e0d\u51c6\u786e\u3002<\/p>\n

    \u6240\u4ee5\u4e3a\u4e86\u4fdd\u8bc1\u67e5\u8be2\u7684\u6570\u636e\u662f\u548c\u4e3b\u5e93\u4e00\u81f4\u7684\uff0c\u5c31\u9700\u8981\u5148\u5224\u65ad seconds_behind_master \u662f\u5426\u5df2\u7ecf\u7b49\u4e8e 0\uff0c\u5982\u679c\u4e0d\u7b49\u4e8e 0\uff0c\u5c31\u5fc5\u987b\u7b49\u5230\u8fd9\u4e2a\u53c2\u6570\u53d8\u4e3a 0 \u624d\u80fd\u6267\u884c\u67e5\u8be2\u8bf7\u6c42\u3002<\/p>\n

    \u65b9\u6848\u4e8c\uff1a\u5bf9\u6bd4\u4f4d\u70b9<\/strong><\/span><\/div>\n

    \u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u4ece\u5e93\u5f53\u524d\u7684\u540c\u6b65\u4f4d\u70b9\u6765\u786e\u8ba4\u4ece\u5e93\u540c\u6b65\u662f\u5426\u6709\u5ef6\u8fdf\u3002\u4e0b\u56fe\u662f\u5728\u4ece\u5e93\u4e0a\u6267\u884c \u200b\u200bshow slave status \\G\u200b\u200b\u547d\u4ee4\u540e\u7684\u7ed3\u679c\uff1a<\/p>\n

    \"\"<\/p>\n

    Master_Log_File\u200b \u548c Read_Master_Log_Pos \u8fd9\u4e24\u4e2a\u53c2\u6570\u5408\u8d77\u6765\u8868\u793a\u7684\u662f\u8bfb\u5230\u7684\u4e3b\u5e93\u7684\u6700\u65b0\u4f4d\u70b9\uff0c\u7b2c\u4e00\u53c2\u6570\u662f\u4ee3\u8868\u8bfb\u53d6\u5230\u4e86\u54ea\u4e2a\u6587\u4ef6\uff0c\u7b2c\u4e8c\u4e2a\u662f\u8bfb\u53d6\u5230\u7684\u6587\u4ef6\u7684\u4f4d\u7f6e\u3002<\/p>\n

    Relay_Master_Log_File\u200b \u548c Exec_Master_Log_Pos\uff0c\u8fd9\u4e24\u4e2a\u53c2\u6570\u5408\u8d77\u6765\u8868\u793a\u7684\u662f\u4ece\u5e93\u6267\u884c\u7684\u6700\u65b0\u4f4d\u70b9\u3002<\/p>\n

    \u5982\u679c\u7ea2\u8272\u6846\u8d77\u6765\u7684\u4e24\u4e2a\u53c2\u6570\uff1aMaster_Log_File\u200b \u548c Relay_Master_Log_File \u76f8\u7b49\uff0c\u5219\u8bf4\u660e\u4ece\u5e93\u8bfb\u5230\u7684\u6700\u65b0\u6587\u4ef6\u548c\u4e3b\u5e93\u4e0a\u751f\u6210\u7684\u6587\u4ef6\u76f8\u540c\uff0c\u8fd9\u91cc\u90fd\u662f mysql-bin.000934\u3002<\/p>\n

    \u5982\u679c\u84dd\u8272\u6846\u8d77\u6765\u7684\u4e24\u4e2a\u53c2\u6570 Read_Master_Log_Pos\u200b \u548c Exec_Master_Log_Pos \u76f8\u7b49\uff0c\u5219\u8bf4\u660e\u4ece\u5e93\u8bfb\u5230\u7684\u65e5\u5fd7\u6587\u4ef6\u7684\u4f4d\u7f6e\u548c\u4ece\u5e93\u4e0a\u6267\u884c\u65e5\u5fd7\u6587\u4ef6\u7684\u4f4d\u7f6e\u76f8\u540c\uff0c\u8fd9\u91cc\u90fd\u662f 59521082\u3002<\/p>\n

    \u5f53\u4e0a\u9762\u4e24\u7ec4\u53c2\u6570\u90fd\u76f8\u7b49\u65f6\uff0c\u5219\u8bf4\u660e\u6ca1\u6709\u5ef6\u8fdf\u3002<\/p>\n

    \u65b9\u6848\u4e09\uff1a\u5bf9\u6bd4 GTID \u96c6\u5408<\/strong><\/span><\/div>\n

    \u65b9\u6848\u4e09\u662f\u5bf9\u6bd4 GTID \u96c6\u5408\u3002\u9996\u5148\u6211\u4eec\u5728\u4ece\u5e93\u4e0a\u6267\u884c show slave status \\G\u6765\u67e5\u770b GTID \u96c6\u5408\u3002<\/p>\n

    \u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n

    \"\"<\/p>\n

    Master_UUID \u8868\u793a\u5f53\u524d\u8fde\u63a5\u7684\u4e3b\u5e93\u7684 ID\u3002<\/p>\n

    Auto_Position: 1 \u8868\u793a\u4e3b\u5907\u4f7f\u7528\u4e86 GTID \u534f\u8bae\u3002<\/p>\n

    Retrieved_Gtid_Set \u8868\u793a\u4ece\u5e93\u6536\u5230\u7684\u6240\u6709\u65e5\u5fd7\u7684 GTID \u96c6\u5408\u3002<\/p>\n

    Executed_Gtid_Set \u8868\u793a\u4ece\u5e93\u5df2\u7ecf\u6267\u884c\u5b8c\u6210\u7684 GTID \u96c6\u5408\u3002<\/p>\n

    \u5982\u679c Executed_Gtid_Set \u96c6\u5408\u662f\u5305\u542b Retrieved_Gtid_Set\uff0c\u5219\u8868\u793a\u4ece\u5e93\u63a5\u6536\u5230\u7684\u65e5\u5fd7\u5df2\u7ecf\u540c\u6b65\u5b8c\u6210\u3002<\/p>\n

    \u6bd4\u5982\u4e0a\u56fe\u4e2d Retrieved_Gtid_Set \u503c\u4e3a<\/p>\n

    c5d74746-d7ec-11ec-bf8f-0242ac110002:1-87323<\/pre>\n

    \u524d\u9762\u4e00\u6bb5\u662f\u4e3b\u5e93 id\uff0c\u540e\u9762\u4e00\u6bb5 1-87383 \u662f GTID \u8303\u56f4\u3002\u800cExecuted_Gtid_Set \u7684\u503c\u6709\u4e24\u4e2a\u96c6\u5408<\/p>\n

    7083ae1f-d7ef-11ec-a329-0242ac110002:1-2,\r\nc5d74746-d7ec-11ec-bf8f-0242ac110002:1-87323<\/pre>\n

    Executed_Gtid_Set \u7684\u7b2c\u4e8c\u4e2a\u96c6\u5408\u548c\u7b2c\u4e00\u4e2a\u96c6\u5408\u5b8c\u5168\u4e00\u81f4\uff0c\u7b2c\u4e00\u4e2a\u96c6\u5408 id \u548c \u96c6\u5408\u8303\u56f4\u662f\u4e0a\u6b21\u540c\u6b65\u53e6\u5916\u4e00\u4e2a\u4e3b\u5e93\u7684\u8bb0\u5f55\u3002\u8fd9\u91cc\u8bf4\u660e\u4ece\u5e93\u5df2\u7ecf\u548c\u5f53\u524d\u4e3b\u5e93\u540c\u6b65\u5b8c\u6210\u4e86\u3002<\/p>\n

    \u65b9\u6848\u4e8c\u5bf9\u6bd4\u4f4d\u70b9\u548c\u65b9\u6848\u4e09\u7684 GTID \u6bd4\u5bf9\u90fd\u8981\u6bd4\u65b9\u6848\u4e00\u7684seconds_behind_master \u66f4\u51c6\u786e\u3002\u4f46\u662f\u8fd8\u662f\u6ca1\u6709\u8fbe\u5230\u7cbe\u786e\u7684\u7a0b\u5ea6\uff0c\u9700\u8981\u914d\u5408\u534a\u540c\u6b65\u590d\u5236\uff08semi-sync replication\uff09\u624d\u80fd\u8fbe\u5230\u3002<\/p>\n

    \u5c0f\u7ed3\uff1a\u672c\u7bc7\u901a\u8fc7 GTID \u7684\u65b9\u5f0f\u66f4\u597d\u5730\u5b9e\u73b0\u4e86\u4e3b\u4ece\u8282\u70b9\u7684\u540c\u6b65\uff0c\u4ee5\u53ca\u5982\u4f55\u89c2\u5bdf\u4e3b\u4ece\u540c\u6b65\u7684\u5ef6\u8fdf\u3002<\/p>\n

    \u53c2\u8003\u8d44\u6599\uff1a<\/strong><\/div>\n

    www.passjava.cn<\/p>\n

    https:\/\/time.geekbang.org\/column\/article\/77636<\/p>\n

    \u9ad8\u6027\u80fd MySQL \u7b2c\u56db\u7248<\/p>\n

    \u5343\u91d1\u826f\u65b9\uff1aMySQL\u6027\u80fd\u4f18\u5316\u91d1\u5b57\u5854\u6cd5\u5219<\/p>\n

    \u5173\u4e8e\u6211<\/strong><\/div>\n

    8 \u5e74\u4e92\u8054\u7f51\u5f00\u53d1\u7ecf\u9a8c\uff0c\u64c5\u957f\u5fae\u670d\u52a1\u3001\u5206\u5e03\u5f0f\u3001\u67b6\u6784\u8bbe\u8ba1\u3002\u76ee\u524d\u5728\u4e00\u5bb6\u5927\u578b\u4e0a\u5e02\u516c\u53f8\u4ece\u4e8b\u57fa\u7840\u67b6\u6784\u548c\u6027\u80fd\u4f18\u5316\u5de5\u4f5c\u3002<\/p>\n

    InfoQ \u7b7e\u7ea6\u4f5c\u8005\u3001\u84dd\u6865\u7b7e\u7ea6\u4f5c\u8005\u3001\u963f\u91cc\u4e91\u4e13\u5bb6\u535a\u4e3b\u300151CTO \u7ea2\u4eba\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u672c\u6587\u4e3b\u8981\u5185\u5bb9\u5982\u4e0b\uff1a \u4e3a\u4e86\u4fdd\u8bc1\u9ad8\u53ef\u7528\uff0c\u4e4b\u524d\u5728\u6d4b\u8bd5\u73af\u5883\u90e8\u7f72\u4e86\u4e00\u5957 MySQL \u53cc\u4e3b\u6a21\u5f0f\uff0c\u5f53\u4e00\u4e2a\u4e3b\u5e93\u670d\u52a1\u51fa\u73b0\u5f02\u5e38\uff0c\u53ef […]<\/p>\n","protected":false},"author":1920,"featured_media":208759,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-261666","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/261666","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1920"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=261666"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/261666\/revisions"}],"predecessor-version":[{"id":261676,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/261666\/revisions\/261676"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/208759"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=261666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=261666"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=261666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}