{"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":"
\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 \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 \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 \u75db\u70b92\uff1a\u6062\u590d\u4e3b\u4ece\u590d\u5236\u7684\u6b65\u9aa4\u590d\u6742 \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 |