{"id":21532,"date":"2024-01-02T10:59:23","date_gmt":"2024-01-02T10:59:23","guid":{"rendered":"https:\/\/server.hk\/blog\/21532\/"},"modified":"2024-11-14T10:31:10","modified_gmt":"2024-11-14T02:31:10","slug":"mongodb-glossary-write-ahead-log","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21532\/","title":{"rendered":"MongoDB \u8a5e\u5f59\u8868 &#8211; \u9810\u5beb\u65e5\u8a8c"},"content":{"rendered":"<h1 id=\"mongodb-glossary-write-ahead-log-CSfHCpBtFf\">MongoDB \u8a5e\u5f59\u8868 &#8211; \u9810\u5beb\u65e5\u8a8c<\/h1>\n<p>\u5728\u6578\u64da\u5eab\u7684\u4e16\u754c\u4e2d\uff0c\u9810\u5beb\u65e5\u8a8c\uff08Write Ahead Log, WAL\uff09\u662f\u4e00\u500b\u95dc\u9375\u7d44\u4ef6\uff0c\u78ba\u4fdd\u6578\u64da\u7684\u6301\u4e45\u6027\u548c\u4e00\u81f4\u6027\u3002MongoDB \u4f5c\u70ba\u4e00\u500b\u6d41\u884c\u7684 NoSQL \u6578\u64da\u5eab\uff0c\u4e5f\u5229\u7528\u9810\u5beb\u65e5\u8a8c\u6a5f\u5236\u4f86\u63d0\u4f9b\u53ef\u9760\u6027\u548c\u5bb9\u932f\u80fd\u529b\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5c07\u63a2\u8a0e MongoDB \u4e2d\u9810\u5beb\u65e5\u8a8c\u7684\u6982\u5ff5\u53ca\u5176\u5728\u7dad\u8b77\u6578\u64da\u5b8c\u6574\u6027\u65b9\u9762\u7684\u91cd\u8981\u6027\u3002<\/p>\n<h2 id=\"understanding-write-ahead-log-wal-CSfHCpBtFf\">\u7406\u89e3\u9810\u5beb\u65e5\u8a8c\uff08WAL\uff09<\/h2>\n<p>\u9810\u5beb\u65e5\u8a8c\uff0c\u901a\u5e38\u7c21\u7a31\u70ba WAL\uff0c\u662f\u6578\u64da\u5eab\u7528\u4f86\u78ba\u4fdd\u5c0d\u6578\u64da\u5eab\u6240\u505a\u7684\u66f4\u6539\u5728\u61c9\u7528\u5230\u5be6\u969b\u6578\u64da\u6587\u4ef6\u4e4b\u524d\u5148\u8a18\u9304\u5728\u65e5\u8a8c\u4e2d\u7684\u4e00\u7a2e\u6280\u8853\u3002\u9019\u500b\u65e5\u8a8c\u4f5c\u70ba\u5b89\u5168\u7db2\uff0c\u5141\u8a31\u6578\u64da\u5eab\u5f9e\u6545\u969c\u4e2d\u6062\u5fa9\u4e26\u4fdd\u6301\u6578\u64da\u7684\u4e00\u81f4\u6027\u3002<\/p>\n<p>\u5728 MongoDB \u4e2d\uff0c\u9810\u5beb\u65e5\u8a8c\u5be6\u73fe\u70ba\u65e5\u8a8c\u6587\u4ef6\u3002\u65e5\u8a8c\u6587\u4ef6\u5b58\u5132\u5beb\u5165\u64cd\u4f5c\uff0c\u76f4\u5230\u9019\u4e9b\u64cd\u4f5c\u88ab\u63d0\u4ea4\u5230\u6578\u64da\u6587\u4ef6\u4e2d\u3002\u901a\u904e\u9996\u5148\u5c07\u66f4\u6539\u5beb\u5165\u65e5\u8a8c\uff0cMongoDB \u4fdd\u8b49\u5373\u4f7f\u5728\u7cfb\u7d71\u5d29\u6f70\u6216\u65b7\u96fb\u7684\u60c5\u6cc1\u4e0b\uff0c\u6578\u64da\u4fee\u6539\u4e5f\u662f\u6301\u4e45\u7684\u3002<\/p>\n<h2 id=\"advantages-of-write-ahead-log-in-mongodb-CSfHCpBtFf\">MongoDB \u4e2d\u9810\u5beb\u65e5\u8a8c\u7684\u512a\u52e2<\/h2>\n<p>\u9810\u5beb\u65e5\u8a8c\u6a5f\u5236\u5728 MongoDB \u4e2d\u63d0\u4f9b\u4e86\u5e7e\u500b\u512a\u52e2\uff1a<\/p>\n<h3 id=\"1-durability-CSfHCpBtFf\">1. \u6301\u4e45\u6027\uff1a<\/h3>\n<p>\u901a\u904e\u5728\u5c07\u5beb\u5165\u64cd\u4f5c\u61c9\u7528\u65bc\u6578\u64da\u6587\u4ef6\u4e4b\u524d\u5c07\u5176\u6301\u4e45\u5316\u5230\u65e5\u8a8c\u4e2d\uff0cMongoDB \u78ba\u4fdd\u5728\u767c\u751f\u610f\u5916\u6545\u969c\u7684\u60c5\u6cc1\u4e0b\u4e0d\u6703\u4e1f\u5931\u6578\u64da\u4fee\u6539\u3002\u9810\u5beb\u65e5\u8a8c\u63d0\u4f9b\u4e86\u6301\u4e45\u6027\uff0c\u4f7f\u5176\u6210\u70ba\u9700\u8981\u6578\u64da\u5b8c\u6574\u6027\u7684\u61c9\u7528\u7a0b\u5e8f\u7684\u53ef\u9760\u9078\u64c7\u3002<\/p>\n<h3 id=\"2-crash-recovery-CSfHCpBtFf\">2. \u5d29\u6f70\u6062\u5fa9\uff1a<\/h3>\n<p>\u5728\u7cfb\u7d71\u5d29\u6f70\u6216\u65b7\u96fb\u7684\u60c5\u6cc1\u4e0b\uff0cMongoDB \u53ef\u4ee5\u901a\u904e\u91cd\u64ad\u9810\u5beb\u65e5\u8a8c\u4e2d\u7684\u5beb\u5165\u64cd\u4f5c\u4f86\u6062\u5fa9\u6578\u64da\u5eab\u72c0\u614b\u3002\u9019\u4e00\u6062\u5fa9\u904e\u7a0b\u78ba\u4fdd\u6578\u64da\u5eab\u4fdd\u6301\u4e00\u81f4\uff0c\u907f\u514d\u6578\u64da\u640d\u58de\u3002<\/p>\n<h3 id=\"3-performance-optimization-CSfHCpBtFf\">3. \u6027\u80fd\u512a\u5316\uff1a<\/h3>\n<p>\u9810\u5beb\u65e5\u8a8c\u9084\u6709\u52a9\u65bc\u512a\u5316 MongoDB \u7684\u6027\u80fd\u3002\u901a\u904e\u5c07\u591a\u500b\u5beb\u5165\u64cd\u4f5c\u6279\u8655\u7406\u5230\u65e5\u8a8c\u4e2d\uff0cMongoDB \u6e1b\u5c11\u4e86\u6bcf\u6b21\u5beb\u5165\u6240\u9700\u7684\u78c1\u789f I\/O \u64cd\u4f5c\u6578\u91cf\u3002\u9019\u7a2e\u6279\u8655\u7406\u63d0\u9ad8\u4e86\u6574\u9ad4\u5beb\u5165\u6027\u80fd\u4e26\u964d\u4f4e\u4e86\u5ef6\u9072\u3002<\/p>\n<h2 id=\"write-ahead-log-workflow-CSfHCpBtFf\">\u9810\u5beb\u65e5\u8a8c\u5de5\u4f5c\u6d41\u7a0b<\/h2>\n<p>MongoDB \u4e2d\u7684\u9810\u5beb\u65e5\u8a8c\u5de5\u4f5c\u6d41\u7a0b\u6d89\u53ca\u4ee5\u4e0b\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-write-to-the-journal-CSfHCpBtFf\">1. \u5beb\u5165\u65e5\u8a8c\uff1a<\/h3>\n<p>\u7576\u5728 MongoDB \u4e2d\u57f7\u884c\u5beb\u5165\u64cd\u4f5c\u6642\uff0c\u8b8a\u66f4\u9996\u5148\u88ab\u5beb\u5165\u65e5\u8a8c\u6587\u4ef6\u3002\u9019\u78ba\u4fdd\u5beb\u5165\u64cd\u4f5c\u662f\u6301\u4e45\u7684\uff0c\u4e26\u4e14\u5728\u767c\u751f\u6545\u969c\u6642\u53ef\u4ee5\u6062\u5fa9\u3002<\/p>\n<h3 id=\"2-apply-to-memory-CSfHCpBtFf\">2. \u61c9\u7528\u5230\u5167\u5b58\uff1a<\/h3>\n<p>\u5728\u5beb\u5165\u64cd\u4f5c\u8a18\u9304\u5230\u65e5\u8a8c\u5f8c\uff0cMongoDB \u5c07\u66f4\u6539\u61c9\u7528\u5230\u5167\u5b58\u4e2d\u7684\u6578\u64da\u7d50\u69cb\u4e2d\u3002\u9019\u6a23\u53ef\u4ee5\u66f4\u5feb\u901f\u5730\u8b80\u53d6\u4fee\u6539\u5f8c\u7684\u6578\u64da\u3002<\/p>\n<h3 id=\"3-write-to-data-files-CSfHCpBtFf\">3. \u5beb\u5165\u6578\u64da\u6587\u4ef6\uff1a<\/h3>\n<p>MongoDB \u5b9a\u671f\u5c07\u5167\u5b58\u4e2d\u7684\u66f4\u6539\u5237\u65b0\u5230\u78c1\u789f\u4e0a\u7684\u6578\u64da\u6587\u4ef6\u4e2d\u3002\u9019\u78ba\u4fdd\u6578\u64da\u4fee\u6539\u88ab\u6301\u4e45\u5316\uff0c\u5373\u4f7f\u4f3a\u670d\u5668\u91cd\u65b0\u555f\u52d5\u4e5f\u80fd\u6062\u5fa9\u3002<\/p>\n<h2 id=\"conclusion-CSfHCpBtFf\">\u7d50\u8ad6<\/h2>\n<p>\u9810\u5beb\u65e5\u8a8c\uff08WAL\uff09\u662f MongoDB \u4e2d\u7684\u4e00\u500b\u95dc\u9375\u7d44\u4ef6\uff0c\u78ba\u4fdd\u6578\u64da\u7684\u6301\u4e45\u6027\u3001\u5d29\u6f70\u6062\u5fa9\u548c\u6027\u80fd\u512a\u5316\u3002\u901a\u904e\u5728\u5c07\u5beb\u5165\u64cd\u4f5c\u61c9\u7528\u5230\u6578\u64da\u6587\u4ef6\u4e4b\u524d\u5c07\u5176\u6301\u4e45\u5316\u5230\u65e5\u8a8c\u4e2d\uff0cMongoDB \u63d0\u4f9b\u4e86\u4e00\u500b\u53ef\u9760\u4e14\u4e00\u81f4\u7684\u6578\u64da\u5eab\u9ad4\u9a57\u3002\u4e86\u89e3\u9810\u5beb\u65e5\u8a8c\u6a5f\u5236\u5c0d\u65bc\u4f7f\u7528 MongoDB \u69cb\u5efa\u7a69\u5065\u4e14\u5177\u5bb9\u932f\u80fd\u529b\u7684\u61c9\u7528\u7a0b\u5e8f\u7684\u958b\u767c\u4eba\u54e1\u548c\u7ba1\u7406\u54e1\u4f86\u8aaa\u81f3\u95dc\u91cd\u8981\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u6709\u95dc MongoDB \u53ca\u5176\u529f\u80fd\u7684\u4fe1\u606f\uff0c\u8acb\u8003\u616e\u63a2\u7d22 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\uff0c\u9019\u662f\u4e00\u5bb6\u63d0\u4f9b\u53ef\u9760\u4e14\u9ad8\u6548\u7684\u8a17\u7ba1\u89e3\u6c7a\u65b9\u6848\u7684\u9818\u5148 VPS \u8a17\u7ba1\u516c\u53f8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MongoDB \u8a5e\u5f59\u8868 &#038;#82&#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-21532","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21532","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=21532"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21532\/revisions"}],"predecessor-version":[{"id":23928,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21532\/revisions\/23928"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}