{"id":21975,"date":"2024-01-02T18:26:24","date_gmt":"2024-01-02T18:26:24","guid":{"rendered":"https:\/\/server.hk\/blog\/21975\/"},"modified":"2024-11-14T10:23:57","modified_gmt":"2024-11-14T02:23:57","slug":"a-deep-dive-into-mongodb-server-architecture","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21975\/","title":{"rendered":"\u6df1\u5165\u63a2\u8a0e MongoDB \u4f3a\u670d\u5668\u67b6\u69cb"},"content":{"rendered":"<h1 id=\"a-deep-dive-into-mongodb-server-architecture-mMQamDYTNI\">\u6df1\u5165\u63a2\u8a0e MongoDB \u4f3a\u670d\u5668\u67b6\u69cb<\/h1>\n<p>MongoDB \u662f\u4e00\u500b\u53d7\u6b61\u8fce\u7684 NoSQL \u6578\u64da\u5eab\uff0c\u63d0\u4f9b\u9ad8\u6027\u80fd\u3001\u53ef\u64f4\u5c55\u6027\u548c\u9748\u6d3b\u6027\u3002\u5b83\u88ab\u958b\u767c\u4eba\u54e1\u548c\u7d44\u7e54\u5ee3\u6cdb\u4f7f\u7528\uff0c\u4ee5\u8655\u7406\u5927\u91cf\u6578\u64da\u4e26\u69cb\u5efa\u73fe\u4ee3\u61c9\u7528\u7a0b\u5e8f\u3002\u8981\u5145\u5206\u7406\u89e3 MongoDB \u7684\u904b\u4f5c\u65b9\u5f0f\uff0c\u5fc5\u9808\u63a2\u8a0e\u5176\u4f3a\u670d\u5668\u67b6\u69cb\u3002<\/p>\n<h2 id=\"introduction-to-mongodb-server-architecture-mMQamDYTNI\">MongoDB \u4f3a\u670d\u5668\u67b6\u69cb\u4ecb\u7d39<\/h2>\n<p>MongoDB \u7684\u4f3a\u670d\u5668\u67b6\u69cb\u7531\u5e7e\u500b\u7d44\u4ef6\u7d44\u6210\uff0c\u9019\u4e9b\u7d44\u4ef6\u5354\u540c\u5de5\u4f5c\u4ee5\u63d0\u4f9b\u5f37\u5927\u800c\u9ad8\u6548\u7684\u6578\u64da\u5eab\u7cfb\u7d71\u3002\u9019\u4e9b\u7d44\u4ef6\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><strong>Mongod:<\/strong> mongod \u9032\u7a0b\u662f\u8ca0\u8cac\u7ba1\u7406\u6578\u64da\u5b58\u5132\u3001\u7d22\u5f15\u548c\u67e5\u8a62\u8655\u7406\u7684\u4e3b\u8981\u5b88\u8b77\u9032\u7a0b\u3002\u5b83\u8655\u7406\u6240\u6709\u7684\u8b80\u53d6\u548c\u5beb\u5165\u64cd\u4f5c\uff0c\u4ee5\u53ca\u6578\u64da\u8907\u88fd\u548c\u5206\u7247\u3002<\/li>\n<li><strong>\u5b58\u5132\u5f15\u64ce:<\/strong> MongoDB \u652f\u6301\u591a\u7a2e\u5b58\u5132\u5f15\u64ce\uff0c\u5305\u62ec WiredTiger \u548c MMAPv1\u3002\u5b58\u5132\u5f15\u64ce\u8ca0\u8cac\u7ba1\u7406\u78c1\u789f\u548c\u5167\u5b58\u4e2d\u7684\u6578\u64da\u5b58\u5132\uff0c\u4e26\u8655\u7406\u6578\u64da\u58d3\u7e2e\u548c\u5feb\u53d6\u3002<\/li>\n<li><strong>\u7d22\u5f15:<\/strong> MongoDB \u4f7f\u7528\u7d22\u5f15\u4f86\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\u3002\u7d22\u5f15\u662f\u5728\u96c6\u5408\u4e2d\u7684\u7279\u5b9a\u5b57\u6bb5\u4e0a\u5275\u5efa\u7684\uff0c\u5141\u8a31\u9ad8\u6548\u7684\u6578\u64da\u6aa2\u7d22\u3002<\/li>\n<li><strong>\u8907\u88fd\u96c6:<\/strong> MongoDB \u8907\u88fd\u96c6\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027\u548c\u6578\u64da\u5197\u9918\u3002\u8907\u88fd\u96c6\u7531\u591a\u500b mongod \u5be6\u4f8b\u7d44\u6210\uff0c\u5176\u4e2d\u4e00\u500b\u4f5c\u70ba\u4e3b\u7bc0\u9ede\uff0c\u5176\u4ed6\u4f5c\u70ba\u5f9e\u7bc0\u9ede\u3002\u5982\u679c\u4e3b\u7bc0\u9ede\u5931\u6548\uff0c\u67d0\u500b\u5f9e\u7bc0\u9ede\u6703\u81ea\u52d5\u6210\u70ba\u65b0\u7684\u4e3b\u7bc0\u9ede\u3002<\/li>\n<li><strong>\u5206\u7247:<\/strong> \u5206\u7247\u662f\u4e00\u7a2e\u5c07\u6578\u64da\u5206\u914d\u5230\u591a\u53f0\u4f3a\u670d\u5668\u6216\u5206\u7247\u7684\u6280\u8853\u3002\u5b83\u4f7f MongoDB \u80fd\u5920\u6a6b\u5411\u64f4\u5c55\uff0c\u901a\u904e\u5c0d\u6578\u64da\u9032\u884c\u5206\u5340\uff0c\u4e26\u5c07\u5176\u5206\u4f48\u5230\u591a\u53f0\u6a5f\u5668\u4e0a\u4f86\u8655\u7406\u5927\u6578\u64da\u96c6\u3002<\/li>\n<\/ul>\n<h2 id=\"how-mongodb-handles-reads-and-writes-mMQamDYTNI\">MongoDB \u5982\u4f55\u8655\u7406\u8b80\u53d6\u548c\u5beb\u5165<\/h2>\n<p>\u7576\u5ba2\u6236\u7aef\u61c9\u7528\u7a0b\u5e8f\u5411 MongoDB \u767c\u9001\u8b80\u53d6\u6216\u5beb\u5165\u8acb\u6c42\u6642\uff0c\u8acb\u6c42\u7531 mongod \u9032\u7a0b\u8655\u7406\u3002\u4ee5\u4e0b\u662f MongoDB \u8655\u7406\u8b80\u53d6\u548c\u5beb\u5165\u7684\u9010\u6b65\u6982\u8ff0\uff1a<\/p>\n<ol>\n<li>\u5ba2\u6236\u7aef\u61c9\u7528\u7a0b\u5e8f\u5411 MongoDB \u4f3a\u670d\u5668\u767c\u9001\u8acb\u6c42\u3002<\/li>\n<li>mongod \u9032\u7a0b\u63a5\u6536\u8acb\u6c42\u4e26\u6aa2\u67e5\u6240\u8acb\u6c42\u7684\u6578\u64da\u662f\u5426\u5728\u5167\u5b58\u4e2d\u53ef\u7528\u3002<\/li>\n<li>\u5982\u679c\u6578\u64da\u5728\u5167\u5b58\u4e2d\uff0cMongoDB \u6703\u76f4\u63a5\u5c07\u7d50\u679c\u8fd4\u56de\u7d66\u5ba2\u6236\u7aef\u3002<\/li>\n<li>\u5982\u679c\u6578\u64da\u4e0d\u5728\u5167\u5b58\u4e2d\uff0cMongoDB \u6703\u5f9e\u78c1\u789f\u4e2d\u8b80\u53d6\u8a72\u6578\u64da\u4e26\u52a0\u8f09\u5230\u5167\u5b58\u4e2d\u3002<\/li>\n<li>\u4e00\u65e6\u6578\u64da\u5728\u5167\u5b58\u4e2d\uff0cMongoDB \u6703\u57f7\u884c\u8acb\u6c42\u7684\u64cd\u4f5c\uff08\u8b80\u53d6\u6216\u5beb\u5165\uff09\uff0c\u4e26\u5c07\u7d50\u679c\u8fd4\u56de\u7d66\u5ba2\u6236\u7aef\u3002<\/li>\n<li>\u5982\u679c\u64cd\u4f5c\u6d89\u53ca\u5beb\u5165\u6578\u64da\uff0cMongoDB \u6703\u5728\u5167\u5b58\u4e2d\u66f4\u65b0\u6578\u64da\uff0c\u4e26\u5c07\u5176\u7570\u6b65\u6301\u4e45\u5316\u5230\u78c1\u789f\uff0c\u4ee5\u78ba\u4fdd\u6578\u64da\u7684\u6301\u4e45\u6027\u3002<\/li>\n<\/ol>\n<h2 id=\"scaling-mongodb-with-replica-sets-and-sharding-mMQamDYTNI\">\u901a\u904e\u8907\u88fd\u96c6\u548c\u5206\u7247\u64f4\u5c55 MongoDB<\/h2>\n<p>MongoDB \u63d0\u4f9b\u4e86\u5169\u7a2e\u64f4\u5c55\u6a5f\u5236\uff1a\u8907\u88fd\u96c6\u548c\u5206\u7247\u3002<\/p>\n<p>\u8907\u88fd\u96c6\u901a\u904e\u5728\u4e0d\u540c\u4f3a\u670d\u5668\u4e0a\u4fdd\u6301\u591a\u500b\u6578\u64da\u526f\u672c\u4f86\u78ba\u4fdd\u9ad8\u53ef\u7528\u6027\u548c\u6578\u64da\u5197\u9918\u3002\u5982\u679c\u4e3b\u7bc0\u9ede\u5931\u6548\uff0c\u67d0\u500b\u5f9e\u7bc0\u9ede\u6703\u81ea\u52d5\u63a5\u7ba1\u6210\u70ba\u65b0\u7684\u4e3b\u7bc0\u9ede\uff0c\u78ba\u4fdd\u6578\u64da\u5eab\u4fdd\u6301\u53ef\u8a2a\u554f\uff0c\u4e26\u6700\u5c0f\u5316\u505c\u6a5f\u6642\u9593\u3002<\/p>\n<p>\u5206\u7247\u4f7f MongoDB \u80fd\u5920\u901a\u904e\u5c0d\u6578\u64da\u9032\u884c\u5206\u4f48\uff0c\u4f7f\u5176\u80fd\u5920\u8655\u7406\u5927\u6578\u64da\u96c6\u3002\u6bcf\u500b\u5206\u7247\u5305\u542b\u6578\u64da\u7684\u4e00\u90e8\u5206\uff0cMongoDB \u81ea\u52d5\u5c07\u8b80\u5beb\u64cd\u4f5c\u8def\u7531\u5230\u9069\u7576\u7684\u5206\u7247\u3002\u9019\u7a2e\u6a6b\u5411\u64f4\u5c55\u7684\u65b9\u6cd5\u4f7f MongoDB \u80fd\u5920\u61c9\u5c0d\u589e\u52a0\u7684\u6578\u64da\u91cf\u548c\u6d41\u91cf\u3002<\/p>\n<h2 id=\"conclusion-mMQamDYTNI\">\u7d50\u8ad6<\/h2>\n<p>MongoDB \u7684\u4f3a\u670d\u5668\u67b6\u69cb\u65e8\u5728\u63d0\u4f9b\u9ad8\u6027\u80fd\u3001\u53ef\u64f4\u5c55\u6027\u548c\u9748\u6d3b\u6027\u3002\u4e86\u89e3 MongoDB \u5982\u4f55\u8655\u7406\u8b80\u5beb\uff0c\u4ee5\u53ca\u5176\u5c0d\u8907\u88fd\u96c6\u548c\u5206\u7247\u7684\u652f\u6301\uff0c\u5c0d\u65bc\u69cb\u5efa\u9ad8\u6548\u4e14\u53ef\u64f4\u5c55\u7684\u61c9\u7528\u7a0b\u5e8f\u81f3\u95dc\u91cd\u8981\u3002<\/p>\n<p>\u5982\u9700\u66f4\u591a\u6709\u95dc MongoDB \u7684\u4fe1\u606f\u53ca\u5176\u5982\u4f55\u70ba\u60a8\u7684\u696d\u52d9\u5e36\u4f86\u597d\u8655\uff0c\u8acb\u8003\u616e\u63a2\u7d22 <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS \u4e3b\u6a5f\u670d\u52d9<\/a>\u3002\u901a\u904e\u4ed6\u5011\u9ad8\u7aef\u7684 VPS \u89e3\u6c7a\u65b9\u6848\uff0c\u60a8\u53ef\u4ee5\u5229\u7528 MongoDB \u7684\u5f37\u5927\u529f\u80fd\uff0c\u5c07\u60a8\u7684\u61c9\u7528\u7a0b\u5e8f\u63d0\u5347\u5230\u65b0\u6c34\u5e73\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6df1\u5165\u63a2\u8a0e MongoDB \u4f3a\u670d\u5668&#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-21975","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21975","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=21975"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21975\/revisions"}],"predecessor-version":[{"id":23330,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21975\/revisions\/23330"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}