{"id":21695,"date":"2024-01-02T13:46:26","date_gmt":"2024-01-02T13:46:26","guid":{"rendered":"https:\/\/server.hk\/blog\/21695\/"},"modified":"2024-11-14T10:28:30","modified_gmt":"2024-11-14T02:28:30","slug":"how-to-fix-mongodb-error-code-105-incompatibleshardingmetadata","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21695\/","title":{"rendered":"\u5982\u4f55\u4fee\u5fa9 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 105 &#8211; IncompatibleShardingMetadata"},"content":{"rendered":"<h1 id=\"how-to-fix-mongodb-error-code-105-incompatibleshardingmetadata-wPgiYSMhbV\">\u5982\u4f55\u4fee\u5fa9 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 105 &#8211; IncompatibleShardingMetadata<\/h1>\n<p>MongoDB \u662f\u4e00\u500b\u53d7\u6b61\u8fce\u7684 NoSQL \u8cc7\u6599\u5eab\uff0c\u63d0\u4f9b\u9ad8\u64f4\u5c55\u6027\u548c\u9748\u6d3b\u6027\u3002\u7136\u800c\uff0c\u8207\u4efb\u4f55\u8edf\u4ef6\u4e00\u6a23\uff0c\u5b83\u53ef\u80fd\u6703\u9047\u5230\u9700\u8981\u89e3\u6c7a\u7684\u932f\u8aa4\u3002\u5176\u4e2d\u4e00\u500b\u932f\u8aa4\u662f MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 105 &#8211; IncompatibleShardingMetadata\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5c07\u63a2\u8a0e\u6b64\u932f\u8aa4\u7684\u539f\u56e0\uff0c\u4e26\u63d0\u4f9b\u9010\u6b65\u6307\u5c0e\u4f86\u4fee\u5fa9\u5b83\u3002<\/p>\n<h2 id=\"understanding-mongodb-error-code-105-incompatibleshardingmetadata-wPgiYSMhbV\">\u7406\u89e3 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 105 &#8211; IncompatibleShardingMetadata<\/h2>\n<p>MongoDB \u4f7f\u7528\u5206\u7247\u6280\u8853\u4f86\u5c07\u6578\u64da\u5206\u4f48\u5230\u591a\u500b\u6a5f\u5668\u4e0a\uff0c\u5be6\u73fe\u6a6b\u5411\u64f4\u5c55\u3002\u5206\u7247\u5143\u6578\u64da\u5305\u62ec\u6709\u95dc\u5206\u7247\u96c6\u5408\u3001\u5340\u584a\u53ca\u5176\u5206\u4f48\u7684\u4fe1\u606f\u3002\u7576\u5206\u7247\u5143\u6578\u64da\u8b8a\u5f97\u4e0d\u76f8\u5bb9\u6216\u4e0d\u4e00\u81f4\u6642\uff0cMongoDB \u6703\u62cb\u51fa\u932f\u8aa4\u4ee3\u78bc &#8211; 105 &#8211; IncompatibleShardingMetadata\u3002<\/p>\n<p>\u6b64\u932f\u8aa4\u901a\u5e38\u767c\u751f\u5728\u914d\u7f6e\u670d\u52d9\u5668\u4e0a\u5b58\u5132\u7684\u5143\u6578\u64da\u8207\u5206\u7247\u4e0a\u5b58\u5132\u7684\u5143\u6578\u64da\u4e0d\u5339\u914d\u6642\u3002\u9019\u53ef\u80fd\u7531\u65bc\u624b\u52d5\u4fee\u6539\u5143\u6578\u64da\u6216\u5206\u7247\u904e\u7a0b\u4e2d\u7684\u554f\u984c\u5f15\u8d77\u3002<\/p>\n<h2 id=\"fixing-mongodb-error-code-105-incompatibleshardingmetadata-wPgiYSMhbV\">\u4fee\u5fa9 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 105 &#8211; IncompatibleShardingMetadata<\/h2>\n<p>\u4fee\u5fa9 IncompatibleShardingMetadata \u932f\u8aa4\u6d89\u53ca\u78ba\u5b9a\u539f\u56e0\u4e26\u63a1\u53d6\u9069\u7576\u63aa\u65bd\u89e3\u6c7a\u5b83\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u9010\u6b65\u6307\u5c0e\uff1a<\/p>\n<h3 id=\"step-1-check-the-sharding-metadata-wPgiYSMhbV\">\u6b65\u9a5f 1\uff1a\u6aa2\u67e5\u5206\u7247\u5143\u6578\u64da<\/h3>\n<p>\u9996\u5148\uff0c\u6aa2\u67e5\u914d\u7f6e\u670d\u52d9\u5668\u548c\u5206\u7247\u4e0a\u7684\u5206\u7247\u5143\u6578\u64da\u3002\u5728 MongoDB shell \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>use config\r\ndb.collections.find()\r\ndb.chunks.find()\r\n<\/code><\/pre>\n<p>\u6bd4\u8f03\u6240\u6709\u914d\u7f6e\u670d\u52d9\u5668\u548c\u5206\u7247\u4e0a\u9019\u4e9b\u547d\u4ee4\u7684\u8f38\u51fa\u3002\u67e5\u627e\u5143\u6578\u64da\u4e2d\u7684\u4efb\u4f55\u4e0d\u4e00\u81f4\u6216\u5dee\u7570\u3002<\/p>\n<h3 id=\"step-2-resolve-metadata-inconsistencies-wPgiYSMhbV\">\u6b65\u9a5f 2\uff1a\u89e3\u6c7a\u5143\u6578\u64da\u4e0d\u4e00\u81f4\u554f\u984c<\/h3>\n<p>\u5982\u679c\u60a8\u767c\u73fe\u5206\u7247\u5143\u6578\u64da\u4e2d\u7684\u4e0d\u4e00\u81f4\uff0c\u60a8\u9700\u8981\u89e3\u6c7a\u5b83\u5011\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li><strong>\u91cd\u5efa\u5143\u6578\u64da\uff1a<\/strong> \u5982\u679c\u5143\u6578\u64da\u56b4\u91cd\u640d\u58de\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u522a\u9664\u73fe\u6709\u7684\u5143\u6578\u64da\u4e26\u91cd\u65b0\u5206\u4f48\u6578\u64da\u4f86\u91cd\u5efa\u5b83\u3002\u6b64\u65b9\u6cd5\u61c9\u8b39\u614e\u4f7f\u7528\uff0c\u56e0\u70ba\u5b83\u53ef\u80fd\u5c0e\u81f4\u6578\u64da\u4e1f\u5931\u3002<\/li>\n<li><strong>\u5f9e\u5099\u4efd\u9084\u539f\uff1a<\/strong> \u5982\u679c\u60a8\u6709\u6700\u8fd1\u7684\u5143\u6578\u64da\u5099\u4efd\uff0c\u60a8\u53ef\u4ee5\u9084\u539f\u5b83\u4ee5\u89e3\u6c7a\u4e0d\u4e00\u81f4\u554f\u984c\u3002\u78ba\u4fdd\u9075\u5faa\u9069\u7576\u7684\u5099\u4efd\u548c\u9084\u539f\u7a0b\u5e8f\u3002<\/li>\n<li><strong>\u624b\u52d5\u66f4\u65b0\u5143\u6578\u64da\uff1a<\/strong> \u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u624b\u52d5\u66f4\u65b0\u5143\u6578\u64da\u4f86\u4fee\u5fa9\u4e0d\u4e00\u81f4\u3002\u9019\u7a2e\u65b9\u6cd5\u9700\u8981\u5c0d\u5206\u7247\u67b6\u69cb\u6709\u6df1\u5165\u7684\u4e86\u89e3\uff0c\u4e26\u61c9\u5c0f\u5fc3\u57f7\u884c\u3002<\/li>\n<\/ul>\n<p>\u6839\u64da\u5143\u6578\u64da\u4e0d\u4e00\u81f4\u7684\u56b4\u91cd\u7a0b\u5ea6\u548c\u5099\u4efd\u7684\u53ef\u7528\u6027\uff0c\u9078\u64c7\u5408\u9069\u7684\u65b9\u6cd5\u3002<\/p>\n<h3 id=\"step-3-restart-mongodb-services-wPgiYSMhbV\">\u6b65\u9a5f 3\uff1a\u91cd\u555f MongoDB \u670d\u52d9<\/h3>\n<p>\u89e3\u6c7a\u5143\u6578\u64da\u4e0d\u4e00\u81f4\u5f8c\uff0c\u8acb\u91cd\u555f\u6240\u6709\u53d7\u5f71\u97ff\u670d\u52d9\u5668\u4e0a\u7684 MongoDB \u670d\u52d9\u3002\u6b64\u6b65\u9a5f\u53ef\u78ba\u4fdd\u66f4\u6539\u751f\u6548\uff0c\u4e26\u4f7f\u5206\u7247\u5143\u6578\u64da\u5728\u6240\u6709\u7bc0\u9ede\u4e0a\u540c\u6b65\u3002<\/p>\n<h3 id=\"step-4-verify-the-fix-wPgiYSMhbV\">\u6b65\u9a5f 4\uff1a\u9a57\u8b49\u4fee\u5fa9<\/h3>\n<p>\u91cd\u555f MongoDB \u670d\u52d9\u5f8c\uff0c\u9a57\u8b49 IncompatibleShardingMetadata \u932f\u8aa4\u662f\u5426\u5df2\u89e3\u6c7a\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6aa2\u67e5\u72c0\u614b\uff1a<\/p>\n<pre><code>sh.status()\r\nsh.getBalancerState()\r\n<\/code><\/pre>\n<p>\u5982\u679c\u8f38\u51fa\u986f\u793a\u5206\u7247\u5143\u6578\u64da\u4e00\u81f4\u4e14\u8ca0\u8f09\u5e73\u8861\u5668\u904b\u884c\u9806\u66a2\uff0c\u5247\u8aaa\u660e\u932f\u8aa4\u5df2\u6210\u529f\u4fee\u5fa9\u3002<\/p>\n<h2 id=\"summary-wPgiYSMhbV\">\u7e3d\u7d50<\/h2>\n<p>\u7e3d\u4e4b\uff0cMongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 105 &#8211; IncompatibleShardingMetadata \u767c\u751f\u5728\u5206\u7247\u5143\u6578\u64da\u4e0d\u4e00\u81f4\u6642\u3002\u8981\u4fee\u5fa9\u6b64\u932f\u8aa4\uff0c\u60a8\u9700\u8981\u78ba\u5b9a\u539f\u56e0\uff0c\u89e3\u6c7a\u5143\u6578\u64da\u4e0d\u4e00\u81f4\u554f\u984c\uff0c\u91cd\u555f MongoDB \u670d\u52d9\uff0c\u4e26\u9a57\u8b49\u4fee\u5fa9\u6548\u679c\u3002\u5982\u679c\u60a8\u9047\u5230\u6b64\u932f\u8aa4\uff0c\u8acb\u6309\u7167\u672c\u6587\u63d0\u4f9b\u7684\u9010\u6b65\u6307\u5c0e\u4f86\u89e3\u6c7a\u5b83\u3002<\/p>\n<p>\u5982\u9700\u53ef\u9760\u4e14\u53ef\u64f4\u5c55\u7684 VPS \u8a17\u7ba1\u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8003\u616e <a href=\"https:\/\/server.hk\">Server.HK<\/a>\u3002\u6211\u5011\u7684\u8a17\u7ba1\u670d\u52d9\u65e8\u5728\u6eff\u8db3\u5404\u7a2e\u898f\u6a21\u4f01\u696d\u7684\u9700\u6c42\uff0c\u63d0\u4f9b\u9ad8\u6548\u80fd\u57fa\u790e\u8a2d\u65bd\u548c\u5353\u8d8a\u7684\u5ba2\u6236\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4fee\u5fa9 MongoDB \u932f\u8aa4\u4ee3&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-21695","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=21695"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21695\/revisions"}],"predecessor-version":[{"id":23707,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21695\/revisions\/23707"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}