{"id":21750,"date":"2024-01-02T14:41:24","date_gmt":"2024-01-02T14:41:24","guid":{"rendered":"https:\/\/server.hk\/blog\/21750\/"},"modified":"2024-11-14T10:27:38","modified_gmt":"2024-11-14T02:27:38","slug":"how-to-fix-mongodb-error-code-164-initialsyncactive","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21750\/","title":{"rendered":"\u5982\u4f55\u4fee\u5fa9 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 164 &#8211; InitialSyncActive"},"content":{"rendered":"<h1 id=\"how-to-fix-mongodb-error-code-164-initialsyncactive-eUBBhVnAXJ\">\u5982\u4f55\u4fee\u5fa9 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 164 &#8211; InitialSyncActive<\/h1>\n<p>MongoDB \u662f\u4e00\u500b\u6d41\u884c\u7684\u958b\u6e90 NoSQL \u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u63d0\u4f9b\u9ad8\u6027\u80fd\u3001\u53ef\u64f4\u5c55\u6027\u548c\u9748\u6d3b\u6027\u3002\u7136\u800c\uff0c\u50cf\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; 164 &#8211; InitialSyncActive\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5c07\u63a2\u8a0e\u6b64\u932f\u8aa4\u7684\u542b\u7fa9\u4ee5\u53ca\u5982\u4f55\u4fee\u5fa9\u5b83\u3002<\/p>\n<h2 id=\"understanding-mongodb-error-code-164-initialsyncactive-eUBBhVnAXJ\">\u7406\u89e3 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 164 &#8211; InitialSyncActive<\/h2>\n<p>MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 164 &#8211; InitialSyncActive \u767c\u751f\u5728\u60a8\u5617\u8a66\u5728\u5df2\u7d93\u57f7\u884c\u521d\u59cb\u540c\u6b65\u7684\u526f\u672c\u96c6\u6210\u54e1\u4e0a\u555f\u52d5\u521d\u59cb\u540c\u6b65\u64cd\u4f5c\u6642\u3002\u932f\u8aa4\u6d88\u606f\u901a\u5e38\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><code>2021-01-01T12:34:56.789+0000 E REPL [initial sync] Initial sync active, cannot initiate another initial sync<\/code><\/p>\n<p>\u6b64\u932f\u8aa4\u8868\u793a\u540c\u4e00\u526f\u672c\u96c6\u6210\u54e1\u4e0a\u5df2\u7d93\u6709\u53e6\u4e00\u500b\u521d\u59cb\u540c\u6b65\u64cd\u4f5c\u6b63\u5728\u9032\u884c\u3002MongoDB \u9632\u6b62\u540c\u6642\u904b\u884c\u591a\u500b\u521d\u59cb\u540c\u6b65\u64cd\u4f5c\uff0c\u4ee5\u907f\u514d\u885d\u7a81\u548c\u6578\u64da\u4e0d\u4e00\u81f4\u3002<\/p>\n<h2 id=\"resolving-mongodb-error-code-164-initialsyncactive-eUBBhVnAXJ\">\u89e3\u6c7a MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 164 &#8211; InitialSyncActive<\/h2>\n<p>\u8981\u4fee\u5fa9 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 164 &#8211; InitialSyncActive\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u526f\u672c\u96c6\u6210\u54e1\u4e0a\u6c92\u6709\u6b63\u5728\u9032\u884c\u7684\u521d\u59cb\u540c\u6b65\u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u9700\u8981\u9075\u5faa\u7684\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"step-1-check-the-replica-set-status-eUBBhVnAXJ\">\u6b65\u9a5f 1\uff1a\u6aa2\u67e5\u526f\u672c\u96c6\u72c0\u614b<\/h3>\n<p>\u9023\u63a5\u5230 MongoDB \u5be6\u4f8b\u4e26\u6aa2\u67e5\u526f\u672c\u96c6\u7684\u72c0\u614b\u3002\u60a8\u53ef\u4ee5\u5728 MongoDB shell \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>rs.status()<\/code><\/pre>\n<p>\u6b64\u547d\u4ee4\u5c07\u986f\u793a\u6709\u95dc\u526f\u672c\u96c6\u7684\u8a73\u7d30\u4fe1\u606f\uff0c\u5305\u62ec\u6bcf\u500b\u6210\u54e1\u7684\u72c0\u614b\u3002<\/p>\n<h3 id=\"step-2-verify-initial-sync-status-eUBBhVnAXJ\">\u6b65\u9a5f 2\uff1a\u9a57\u8b49\u521d\u59cb\u540c\u6b65\u72c0\u614b<\/h3>\n<p>\u67e5\u627e\u51fa\u73fe\u521d\u59cb\u540c\u6b65\u932f\u8aa4\u7684\u6210\u54e1\u3002\u6aa2\u67e5\u5176\u72c0\u614b\u548c &#8220;syncingTo&#8221; \u5b57\u6bb5\u7684\u503c\u3002\u5982\u679c\u8a72\u6210\u54e1\u4ecd\u8655\u65bc\u521d\u59cb\u540c\u6b65\u72c0\u614b\u4e14 &#8220;syncingTo&#8221; \u4e0d\u70ba\u7a7a\uff0c\u5247\u8868\u793a\u5df2\u7d93\u6709\u4e00\u500b\u521d\u59cb\u540c\u6b65\u64cd\u4f5c\u6b63\u5728\u9032\u884c\u3002<\/p>\n<h3 id=\"step-3-stop-the-initial-sync-operation-eUBBhVnAXJ\">\u6b65\u9a5f 3\uff1a\u505c\u6b62\u521d\u59cb\u540c\u6b65\u64cd\u4f5c<\/h3>\n<p>\u5982\u679c\u60a8\u767c\u73fe\u6709\u521d\u59cb\u540c\u6b65\u64cd\u4f5c\u6b63\u5728\u9032\u884c\uff0c\u5247\u9700\u8981\u5728\u555f\u52d5\u65b0\u7684\u64cd\u4f5c\u4e4b\u524d\u505c\u6b62\u5b83\u3002\u8981\u505c\u6b62\u521d\u59cb\u540c\u6b65\uff0c\u8acb\u5728 MongoDB shell \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>db.adminCommand({ \"stopReplication\": 1 })<\/code><\/pre>\n<p>\u6b64\u547d\u4ee4\u5c07\u505c\u6b62\u521d\u59cb\u540c\u6b65\u64cd\u4f5c\uff0c\u4e26\u5141\u8a31\u60a8\u555f\u52d5\u65b0\u7684\u64cd\u4f5c\u3002<\/p>\n<h3 id=\"step-4-restart-the-initial-sync-eUBBhVnAXJ\">\u6b65\u9a5f 4\uff1a\u91cd\u65b0\u555f\u52d5\u521d\u59cb\u540c\u6b65<\/h3>\n<p>\u4e00\u65e6\u5148\u524d\u7684\u521d\u59cb\u540c\u6b65\u64cd\u4f5c\u505c\u6b62\uff0c\u60a8\u53ef\u4ee5\u555f\u52d5\u65b0\u7684\u521d\u59cb\u540c\u6b65\u3002\u5728 MongoDB shell \u4e2d\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>rs.syncFrom(\"source\")<\/code><\/pre>\n<p>\u5c07 &#8220;source&#8221; \u66ff\u63db\u70ba\u526f\u672c\u96c6\u4e2d\u7684\u5065\u5eb7\u6210\u54e1\u7684\u4e3b\u6a5f\u540d\u6216 IP \u5730\u5740\u3002\u6b64\u547d\u4ee4\u5c07\u5f9e\u6307\u5b9a\u7684\u6e90\u6210\u54e1\u958b\u59cb\u521d\u59cb\u540c\u6b65\u3002<\/p>\n<h2 id=\"summary-eUBBhVnAXJ\">\u7e3d\u7d50<\/h2>\n<p>\u7e3d\u4e4b\uff0cMongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 164 &#8211; InitialSyncActive \u767c\u751f\u5728\u60a8\u5617\u8a66\u5728\u5df2\u7d93\u57f7\u884c\u521d\u59cb\u540c\u6b65\u7684\u526f\u672c\u96c6\u6210\u54e1\u4e0a\u555f\u52d5\u521d\u59cb\u540c\u6b65\u64cd\u4f5c\u6642\u3002\u8981\u4fee\u5fa9\u6b64\u932f\u8aa4\uff0c\u60a8\u9700\u8981\u505c\u6b62\u6b63\u5728\u9032\u884c\u7684\u521d\u59cb\u540c\u6b65\u64cd\u4f5c\u4e26\u555f\u52d5\u65b0\u7684\u64cd\u4f5c\u3002\u901a\u904e\u9075\u5faa\u672c\u6587\u4e2d\u6982\u8ff0\u7684\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u89e3\u6c7a MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 164 &#8211; InitialSyncActive\uff0c\u4e26\u78ba\u4fdd\u60a8\u7684 MongoDB \u526f\u672c\u96c6\u7684\u9806\u5229\u904b\u884c\u3002<\/p>\n<p>\u6709\u95dc VPS \u4e3b\u6a5f\u7684\u66f4\u591a\u4fe1\u606f\u4ee5\u53ca\u5b83\u5982\u4f55\u4f7f\u60a8\u7684 MongoDB \u90e8\u7f72\u53d7\u76ca\uff0c\u8003\u616e\u63a2\u7d22 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\u3002\u901a\u904e\u4ed6\u5011\u7684\u9802\u7d1a VPS \u89e3\u6c7a\u65b9\u6848\uff0c\u60a8\u53ef\u4ee5\u70ba\u60a8\u7684 MongoDB \u6578\u64da\u5eab\u5be6\u73fe\u6700\u4f73\u6027\u80fd\u548c\u53ef\u64f4\u5c55\u6027\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":[101],"tags":[],"class_list":["post-21750","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21750","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=21750"}],"version-history":[{"count":2,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21750\/revisions"}],"predecessor-version":[{"id":23633,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21750\/revisions\/23633"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}