{"id":21928,"date":"2024-01-02T17:39:22","date_gmt":"2024-01-02T17:39:22","guid":{"rendered":"https:\/\/server.hk\/blog\/21928\/"},"modified":"2024-11-14T10:24:53","modified_gmt":"2024-11-14T02:24:53","slug":"how-to-fix-mongodb-error-code-13388-staleconfig","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21928\/","title":{"rendered":"\u5982\u4f55\u4fee\u590d MongoDB \u9519\u8bef\u4ee3\u7801 &#8211; 13388 &#8211; StaleConfig"},"content":{"rendered":"<h1 id=\"how-to-fix-mongodb-error-code-13388-staleconfig-keEqSyvZcM\">\u5982\u4f55\u4fee\u590d MongoDB \u9519\u8bef\u4ee3\u7801 &#8211; 13388 &#8211; StaleConfig<\/h1>\n<p>MongoDB \u662f\u4e00\u500b\u53d7\u6b61\u8fce\u7684 NoSQL \u6570\u636e\u5e93\uff0c\u63d0\u4f9b\u9ad8\u6027\u80fd\u3001\u53ef\u6269\u5c55\u6027\u548c\u7075\u6d3b\u6027\u3002\u7136\u800c\uff0c\u5c31\u50cf\u4efb\u4f55\u8f6f\u4ef6\u4e00\u6837\uff0c\u5b83\u53ef\u80fd\u4f1a\u9047\u5230\u9700\u8981\u89e3\u51b3\u7684\u9519\u8bef\u3002\u5176\u4e2d\u4e00\u500b\u9519\u8bef\u662f MongoDB \u9519\u8bef\u4ee3\u7801 &#8211; 13388\uff0c\u53c8\u540d StaleConfig\u3002\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u63a2\u8ba8\u8fd9\u4e2a\u9519\u8bef\u7684\u542b\u4e49\u53ca\u5176\u89e3\u51b3\u65b9\u6cd5\u3002<\/p>\n<h2 id=\"understanding-mongodb-error-code-13388-staleconfig-keEqSyvZcM\">\u7406\u89e3 MongoDB \u9519\u8bef\u4ee3\u7801 &#8211; 13388 &#8211; StaleConfig<\/h2>\n<p>\u5f53\u60a8\u9047\u5230 MongoDB \u9519\u8bef\u4ee3\u7801 &#8211; 13388 \u65f6\uff0c\u610f\u5473\u8457\u60a8\u7684 MongoDB \u96c6\u7fa4\u4e0a\u7684\u914d\u7f6e\u6570\u636e\u5df2\u7ecf\u8fc7\u65f6\u6216\u5931\u6548\u3002\u8fd9\u4e2a\u9519\u8bef\u901a\u5e38\u53d1\u751f\u5728\u914d\u7f6e\u670d\u52a1\u5668\u4e0a\u5b58\u50a8\u7684\u914d\u7f6e\u6570\u636e\u4e0e\u96c6\u7fa4\u7684\u5b9e\u9645\u72b6\u6001\u4e0d\u5339\u914d\u65f6\u3002<\/p>\n<p>StaleConfig \u9519\u8bef\u53ef\u80fd\u5bfc\u81f4\u5404\u79cd\u95ee\u9898\uff0c\u4f8b\u5982\u5206\u7247\u5206\u5e03\u4e0d\u6b63\u786e\u3001\u6570\u636e\u5206\u5e03\u4e0d\u5747\u6216\u751a\u81f3\u6570\u636e\u4e22\u5931\u3002\u53ca\u65f6\u89e3\u51b3\u8fd9\u4e2a\u9519\u8bef\u5bf9\u4e8e\u786e\u4fdd\u60a8\u7684 MongoDB \u90e8\u7f72\u7684\u7a33\u5b9a\u6027\u548c\u53ef\u9760\u6027\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<h2 id=\"fixing-mongodb-error-code-13388-staleconfig-keEqSyvZcM\">\u4fee\u590d MongoDB \u9519\u8bef\u4ee3\u7801 &#8211; 13388 &#8211; StaleConfig<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u6b65\u9aa4\uff0c\u53ef\u5e2e\u52a9\u60a8\u89e3\u51b3 StaleConfig \u9519\u8bef\uff1a<\/p>\n<h3 id=\"step-1-identify-the-affected-shards-keEqSyvZcM\">\u7b2c 1 \u6b65\uff1a\u8bc6\u522b\u53d7\u5f71\u54cd\u7684\u5206\u7247<\/h3>\n<p>\u7b2c\u4e00\u6b65\u662f\u8bc6\u522b\u53d7 StaleConfig \u9519\u8bef\u5f71\u54cd\u7684\u5206\u7247\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u8fde\u63a5\u5230\u60a8\u7684 MongoDB \u96c6\u7fa4\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b9e\u73b0\uff1a<\/p>\n<pre><code>use config\r\ndb.shards.find({ \"stale\" : true })<\/code><\/pre>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u5c06\u8fd4\u56de\u4e00\u4e2a\u5e26\u6709\u8fc7\u65f6\u914d\u7f6e\u6570\u636e\u7684\u5206\u7247\u5217\u8868\u3002<\/p>\n<h3 id=\"step-2-update-the-configuration-data-keEqSyvZcM\">\u7b2c 2 \u6b65\uff1a\u66f4\u65b0\u914d\u7f6e\u6570\u636e<\/h3>\n<p>\u4e00\u65e6\u60a8\u786e\u5b9a\u4e86\u53d7\u5f71\u54cd\u7684\u5206\u7247\uff0c\u60a8\u5c31\u9700\u8981\u66f4\u65b0\u914d\u7f6e\u6570\u636e\u4ee5\u89e3\u51b3 StaleConfig \u9519\u8bef\u3002MongoDB \u63d0\u4f9b\u4e86\u4e00\u4e2a\u5185\u7f6e\u547d\u4ee4\u53eb\u505a &#8220;cleanupOrphaned&#8221; \u53ef\u4ee5\u5e2e\u52a9\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\u3002\u5bf9\u4e8e\u6bcf\u4e2a\u53d7\u5f71\u54cd\u7684\u5206\u7247\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>use admin\r\ndb.runCommand({ cleanupOrphaned: \"shardsvr\" })<\/code><\/pre>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u5c06\u66f4\u65b0\u6307\u5b9a\u5206\u7247\u7684\u914d\u7f6e\u6570\u636e\uff0c\u5e76\u79fb\u9664\u4efb\u4f55\u8fc7\u65f6\u6216\u5b64\u7acb\u7684\u6570\u636e\u3002<\/p>\n<h3 id=\"step-3-verify-the-fix-keEqSyvZcM\">\u7b2c 3 \u6b65\uff1a\u9a8c\u8bc1\u4fee\u590d<\/h3>\n<p>\u66f4\u65b0\u914d\u7f6e\u6570\u636e\u540e\uff0c\u9a8c\u8bc1 StaleConfig \u9519\u8bef\u662f\u5426\u5df2\u89e3\u51b3\u81f3\u5173\u91cd\u8981\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u8fdb\u884c\u9a8c\u8bc1\uff1a<\/p>\n<pre><code>use config\r\ndb.shards.find({ \"stale\" : true })<\/code><\/pre>\n<p>\u5982\u679c\u547d\u4ee4\u8fd4\u56de\u7a7a\u7ed3\u679c\uff0c\u610f\u5473\u8457 StaleConfig \u9519\u8bef\u5df2\u7ecf\u88ab\u4fee\u590d\uff0c\u914d\u7f6e\u6570\u636e\u662f\u6700\u65b0\u7684\u3002<\/p>\n<h2 id=\"conclusion-keEqSyvZcM\">\u7ed3\u8bba<\/h2>\n<p>MongoDB \u9519\u8bef\u4ee3\u7801 &#8211; 13388\uff0c\u6216 StaleConfig\uff0c\u53ef\u80fd\u4f1a\u5f71\u54cd\u60a8\u7684 MongoDB \u96c6\u7fa4\u7684\u914d\u7f6e\u6570\u636e\u3002\u901a\u8fc7\u9075\u5faa\u672c\u6587\u4e2d\u6982\u8ff0\u7684\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u89e3\u51b3\u8fd9\u4e2a\u9519\u8bef\u5e76\u786e\u4fdd\u60a8\u7684 MongoDB \u90e8\u7f72\u7684\u7a33\u5b9a\u6027\u548c\u53ef\u9760\u6027\u3002<\/p>\n<p>\u6b32\u4e86\u89e3\u66f4\u591a\u5173\u4e8e VPS \u6258\u7ba1\u53ca\u5176\u5982\u4f55\u6709\u52a9\u4e8e\u60a8\u7684 MongoDB \u90e8\u7f72\u7684\u4fe1\u606f\uff0c\u8bf7\u8003\u8651 <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS \u6258\u7ba1<\/a>\u3002\u6211\u4eec\u9876\u7ea7\u7684 VPS \u89e3\u51b3\u65b9\u6848\u63d0\u4f9b\u4e86\u60a8\u7684 MongoDB \u5e94\u7528\u6240\u9700\u7684\u6027\u80fd\u548c\u53ef\u6269\u5c55\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4fee\u590d MongoDB \u9519\u8bef\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":[101],"tags":[],"class_list":["post-21928","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21928","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=21928"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21928\/revisions"}],"predecessor-version":[{"id":23398,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21928\/revisions\/23398"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}