{"id":21533,"date":"2024-01-02T11:00:28","date_gmt":"2024-01-02T11:00:28","guid":{"rendered":"https:\/\/server.hk\/blog\/21533\/"},"modified":"2024-11-14T10:31:09","modified_gmt":"2024-11-14T02:31:09","slug":"mongodb-glossary-lock","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21533\/","title":{"rendered":"MongoDB\u8a5e\u5f59\u8868 &#8211; \u9396\u5b9a"},"content":{"rendered":"<h1 id=\"mongodb-glossary-lock-ybifzveQyT\">MongoDB\u8a5e\u5f59\u8868 &#8211; \u9396\u5b9a<\/h1>\n<p>\u5728\u6578\u64da\u5eab\u7684\u4e16\u754c\u4e2d\uff0c\u4e26\u767c\u63a7\u5236\u662f\u78ba\u4fdd\u6578\u64da\u5b8c\u6574\u6027\u4e26\u5728\u591a\u500b\u7528\u6236\u6216\u9032\u7a0b\u540c\u6642\u8a2a\u554f\u6578\u64da\u5eab\u6642\u9632\u6b62\u885d\u7a81\u7684\u95dc\u9375\u65b9\u9762\u3002\u4f5c\u70ba\u4e00\u500b\u6d41\u884c\u7684NoSQL\u6578\u64da\u5eab\uff0cMongoDB\u5be6\u73fe\u4e86\u4e00\u7a2e\u9396\u5b9a\u6a5f\u5236\u4f86\u7ba1\u7406\u5c0d\u5176\u6578\u64da\u7684\u4e26\u767c\u8a2a\u554f\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5c07\u63a2\u8a0eMongoDB\u4e2d\u9396\u5b9a\u6982\u5ff5\u4ee5\u53ca\u5b83\u5011\u5982\u4f55\u5f71\u97ff\u6578\u64da\u5eab\u7684\u6027\u80fd\u548c\u53ef\u64f4\u5c55\u6027\u3002<\/p>\n<h2 id=\"understanding-locks-in-mongodb-ybifzveQyT\">\u7406\u89e3MongoDB\u4e2d\u7684\u9396\u5b9a<\/h2>\n<p>MongoDB\u4e2d\u7684\u9396\u5b9a\u662f\u4e00\u7a2e\u540c\u6b65\u6a5f\u5236\uff0c\u5b83\u4e00\u6b21\u53ea\u5141\u8a31\u4e00\u500b\u64cd\u4f5c\u8a2a\u554f\u7279\u5b9a\u8cc7\u6e90\u3002\u5b83\u78ba\u4fdd\u4e26\u767c\u64cd\u4f5c\u4e0d\u4e92\u76f8\u5e72\u64fe\u4e26\u7dad\u8b77\u6578\u64da\u5eab\u7684\u4e00\u81f4\u6027\u3002MongoDB\u63a1\u7528\u4e86\u4e00\u7a2e\u7d30\u7c92\u5ea6\u7684\u9396\u5b9a\u7cfb\u7d71\uff0c\u5728\u9019\u500b\u7cfb\u7d71\u4e2d\uff0c\u9396\u5b9a\u662f\u5728\u55ae\u500b\u6587\u6a94\u6216\u96c6\u5408\u7684\u7d1a\u5225\u7372\u53d6\u7684\u3002<\/p>\n<p>MongoDB\u4e2d\u6709\u5169\u7a2e\u985e\u578b\u7684\u9396\u5b9a\uff1a<\/p>\n<ul>\n<li><strong>\u5171\u4eab\u9396\u5b9a\uff08S\uff09\uff1a<\/strong> \u4e5f\u88ab\u7a31\u70ba\u8b80\u9396\uff0c\u5b83\u5141\u8a31\u591a\u500b\u64cd\u4f5c\u540c\u6642\u8b80\u53d6\u540c\u4e00\u8cc7\u6e90\u3002\u591a\u500b\u5171\u4eab\u9396\u53ef\u4ee5\u5171\u5b58\uff0c\u5f9e\u800c\u5be6\u73fe\u4e26\u767c\u8b80\u53d6\u64cd\u4f5c\u800c\u4e0d\u6703\u51fa\u73fe\u885d\u7a81\u3002<\/li>\n<li><strong>\u7368\u5360\u9396\u5b9a\uff08X\uff09\uff1a<\/strong> \u4e5f\u88ab\u7a31\u70ba\u5beb\u9396\uff0c\u5b83\u4e00\u6b21\u53ea\u5141\u8a31\u4e00\u500b\u64cd\u4f5c\u5beb\u5165\u6216\u4fee\u6539\u4e00\u500b\u8cc7\u6e90\u3002\u7576\u7372\u53d6\u7368\u5360\u9396\u5b9a\u6642\uff0c\u6c92\u6709\u5176\u4ed6\u64cd\u4f5c\u53ef\u4ee5\u8b80\u53d6\u6216\u5beb\u5165\u540c\u4e00\u8cc7\u6e90\u3002<\/li>\n<\/ul>\n<p>MongoDB\u4e2d\u7684\u9396\u5b9a\u7372\u53d6\u904e\u7a0b\u9075\u5faa\u4e00\u500b\u7c21\u55ae\u7684\u898f\u5247\uff1a\u5beb\u64cd\u4f5c\u9700\u8981\u7372\u53d6\u7368\u5360\u9396\uff0c\u800c\u8b80\u64cd\u4f5c\u9700\u8981\u7372\u53d6\u5171\u4eab\u9396\u3002\u7136\u800c\uff0c\u6839\u64da\u6578\u64da\u5eab\u7576\u524d\u72c0\u614b\u7684\u76f8\u5bb9\u6027\u77e9\u9663\u6703\u6c7a\u5b9a\u662f\u5426\u53ef\u4ee5\u7372\u53d6\u9396\u5b9a\u3002<\/p>\n<h2 id=\"locking-granularity-ybifzveQyT\">\u9396\u5b9a\u7c92\u5ea6<\/h2>\n<p>MongoDB\u7684\u7d30\u7c92\u5ea6\u9396\u5b9a\u7cfb\u7d71\u70ba\u4ee5\u8b80\u53d6\u70ba\u4e3b\u7684\u5de5\u4f5c\u8ca0\u8f09\u63d0\u4f9b\u4e86\u9748\u6d3b\u6027\u548c\u4e26\u767c\u6027\u3002\u9396\u5b9a\u7c92\u5ea6\u53d6\u6c7a\u65bcMongoDB\u4f7f\u7528\u7684\u5b58\u5132\u5f15\u64ce\uff1a<\/p>\n<ul>\n<li><strong>WiredTiger\u5b58\u5132\u5f15\u64ce\uff1a<\/strong> \u5728MongoDB 3.2\u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\uff0cWiredTiger\u5b58\u5132\u5f15\u64ce\u662f\u9ed8\u8a8d\u7684\u5b58\u5132\u5f15\u64ce\u3002\u5b83\u4f7f\u7528\u6587\u6a94\u7d1a\u5225\u7684\u9396\u5b9a\uff0c\u5141\u8a31\u591a\u500b\u64cd\u4f5c\u540c\u6642\u8a2a\u554f\u4e0d\u540c\u6587\u6a94\u3002\u9019\u63d0\u9ad8\u4e86\u8b80\u5beb\u64cd\u4f5c\u7684\u4e26\u767c\u6027\u548c\u53ef\u64f4\u5c55\u6027\u3002<\/li>\n<li><strong>MMapv1\u5b58\u5132\u5f15\u64ce\uff1a<\/strong> \u5728\u8f03\u65e9\u7248\u672c\u7684MongoDB\u4e2d\uff0cMMapv1\u5b58\u5132\u5f15\u64ce\u662f\u9ed8\u8a8d\u7684\u3002\u5b83\u5728\u96c6\u5408\u7d1a\u5225\u4f7f\u7528\u7c97\u7c92\u5ea6\u7684\u9396\u5b9a\u6a5f\u5236\u3002\u9019\u610f\u5473\u8457\u540c\u4e00\u96c6\u5408\u4e2d\u7684\u4e0d\u540c\u6587\u6a94\u4e0a\u7684\u4e26\u767c\u64cd\u4f5c\u53ef\u80fd\u6703\u51fa\u73fe\u722d\u7528\uff0c\u4e26\u5c0e\u81f4\u6027\u80fd\u964d\u4f4e\u3002<\/li>\n<\/ul>\n<h2 id=\"impact-on-performance-and-scalability-ybifzveQyT\">\u5c0d\u6027\u80fd\u548c\u53ef\u64f4\u5c55\u6027\u7684\u5f71\u97ff<\/h2>\n<p>MongoDB\u4e2d\u7684\u9396\u5b9a\u6a5f\u5236\u76f4\u63a5\u5f71\u97ff\u6578\u64da\u5eab\u7684\u6027\u80fd\u548c\u53ef\u64f4\u5c55\u6027\u3002\u5171\u4eab\u9396\u5141\u8a31\u4e26\u767c\u8b80\u53d6\u64cd\u4f5c\uff0c\u4f46\u7368\u5360\u9396\u53ef\u80fd\u5f15\u5165\u722d\u7528\u4e26\u964d\u4f4e\u4e26\u767c\u6027\u3002<\/p>\n<p>\u5728\u5beb\u64cd\u4f5c\u983b\u7e41\u7684\u60c5\u6cc1\u4e0b\uff0c\u7372\u53d6\u7368\u5360\u9396\u53ef\u80fd\u6210\u70ba\u74f6\u9838\uff0c\u9650\u5236\u61c9\u7528\u7a0b\u5e8f\u7684\u53ef\u64f4\u5c55\u6027\u3002\u70ba\u4e86\u6e1b\u8f15\u9019\u7a2e\u60c5\u6cc1\uff0c\u95dc\u9375\u662f\u8a2d\u8a08\u6578\u64da\u6a21\u578b\u548c\u61c9\u7528\u908f\u8f2f\uff0c\u4ee5\u6e1b\u5c11\u5c0d\u7368\u5360\u9396\u7684\u9700\u6c42\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u9078\u64c7\u5408\u9069\u7684\u5b58\u5132\u5f15\u64ce\uff0c\u4f8b\u5982WiredTiger\uff0c\u53ef\u4ee5\u986f\u8457\u6539\u5584MongoDB\u90e8\u7f72\u7684\u6027\u80fd\u548c\u53ef\u64f4\u5c55\u6027\u3002WiredTiger\u7684\u6587\u6a94\u7d1a\u5225\u7684\u9396\u5b9a\u5141\u8a31\u66f4\u597d\u7684\u4e26\u767c\u6027\uff0c\u6e1b\u5c11\u722d\u7528\uff0c\u7279\u5225\u662f\u5728\u9ad8\u8b80\u5beb\u5de5\u4f5c\u8ca0\u8f09\u7684\u60c5\u6cc1\u4e0b\u3002<\/p>\n<h2 id=\"conclusion-ybifzveQyT\">\u7d50\u8ad6<\/h2>\n<p>\u9396\u5b9a\u662fMongoDB\u4e26\u767c\u63a7\u5236\u6a5f\u5236\u7684\u91cd\u8981\u90e8\u5206\u3002\u4e86\u89e3\u9396\u5b9a\u7684\u5de5\u4f5c\u539f\u7406\u4ee5\u53ca\u5b83\u5011\u5c0d\u6027\u80fd\u548c\u53ef\u64f4\u5c55\u6027\u7684\u5f71\u97ff\u5c0d\u65bc\u8a2d\u8a08\u9ad8\u6548\u53ef\u64f4\u5c55\u7684\u61c9\u7528\u7a0b\u5e8f\u81f3\u95dc\u91cd\u8981\u3002\u901a\u904e\u5229\u7528\u7d30\u7c92\u5ea6\u7684\u9396\u5b9a\u7cfb\u7d71\u4e26\u9078\u64c7\u9069\u7576\u7684\u5b58\u5132\u5f15\u64ce\uff0c\u4f8b\u5982WiredTiger\uff0c\u60a8\u53ef\u4ee5\u512a\u5316MongoDB\u6578\u64da\u5eab\u7684\u6027\u80fd\u4e26\u78ba\u4fdd\u9806\u66a2\u7684\u4e26\u767c\u64cd\u4f5c\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u6709\u95dcMongoDB\u53ca\u5176\u5c0d\u61c9\u7528\u7a0b\u5e8f\u7684\u597d\u8655\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8acb\u8003\u616e\u67e5\u770b\u9818\u5148\u7684VPS\u4e3b\u6a5f\u63d0\u4f9b\u5546 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\uff0c\u4ed6\u5011\u63d0\u4f9b\u53ef\u9760\u4e14\u9ad8\u6027\u80fd\u7684MongoDB\u4e3b\u6a5f\u89e3\u6c7a\u65b9\u6848\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MongoDB\u8a5e\u5f59\u8868 &#038;#821&#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-21533","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21533","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=21533"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21533\/revisions"}],"predecessor-version":[{"id":23927,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21533\/revisions\/23927"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}