{"id":149177,"date":"2024-11-01T14:54:49","date_gmt":"2024-11-01T06:54:49","guid":{"rendered":"https:\/\/server.hk\/cnblog\/149177\/"},"modified":"2024-11-01T14:54:50","modified_gmt":"2024-11-01T06:54:50","slug":"%e9%98%bf%e9%87%8c%e9%81%8b%e7%b6%ad%e5%a6%82%e4%bd%95%e7%ae%a1%e7%90%86%e5%a4%a7%e8%a6%8f%e6%a8%a1nosql%e6%95%b8%e6%93%9a%e5%ba%ab%ef%bc%9f-%e9%98%bf%e9%87%8c%e9%81%8b%e7%b6%adnosql%e6%95%b8","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/149177\/","title":{"rendered":"\u963f\u91cc\u904b\u7dad\u5982\u4f55\u7ba1\u7406\u5927\u898f\u6a21NoSQL\u6578\u64da\u5eab\uff1f (\u963f\u91cc\u904b\u7dadNoSQL\u6578\u64da\u5eab)"},"content":{"rendered":"<h1 id=\"%e9%98%bf%e9%87%8c%e9%81%8b%e7%b6%ad%e5%a6%82%e4%bd%95%e7%ae%a1%e7%90%86%e5%a4%a7%e8%a6%8f%e6%a8%a1nosql%e6%95%b8%e6%93%9a%e5%ba%ab%ef%bc%9f-HDhFDcofjW\">\u963f\u91cc\u904b\u7dad\u5982\u4f55\u7ba1\u7406\u5927\u898f\u6a21NoSQL\u6578\u64da\u5eab\uff1f<\/h1>\n<p>\u96a8\u8457\u6578\u64da\u91cf\u7684\u6025\u5287\u589e\u9577\uff0c\u8d8a\u4f86\u8d8a\u591a\u7684\u4f01\u696d\u9078\u64c7\u4f7f\u7528NoSQL\u6578\u64da\u5eab\u4f86\u8655\u7406\u975e\u7d50\u69cb\u5316\u6578\u64da\u3002\u963f\u91cc\u5df4\u5df4\u4f5c\u70ba\u5168\u7403\u6700\u5927\u7684\u96fb\u5b50\u5546\u52d9\u5e73\u53f0\u4e4b\u4e00\uff0c\u5176\u904b\u7dad\u5718\u968a\u5728\u7ba1\u7406\u5927\u898f\u6a21NoSQL\u6578\u64da\u5eab\u65b9\u9762\u7a4d\u7d2f\u4e86\u8c50\u5bcc\u7684\u7d93\u9a57\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u963f\u91cc\u904b\u7dad\u5982\u4f55\u6709\u6548\u5730\u7ba1\u7406\u9019\u4e9b\u6578\u64da\u5eab\uff0c\u4e26\u5206\u4eab\u4e00\u4e9b\u5be6\u7528\u7684\u7b56\u7565\u548c\u6280\u8853\u3002<\/p>\n<h2 id=\"nosql%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e7%89%b9%e9%bb%9e-HDhFDcofjW\">NoSQL\u6578\u64da\u5eab\u7684\u7279\u9ede<\/h2>\n<p>NoSQL\u6578\u64da\u5eab\u8207\u50b3\u7d71\u7684\u95dc\u4fc2\u578b\u6578\u64da\u5eab\u76f8\u6bd4\uff0c\u5177\u6709\u4ee5\u4e0b\u5e7e\u500b\u986f\u8457\u7279\u9ede\uff1a<\/p>\n<ul>\n<li><strong>\u9748\u6d3b\u7684\u6578\u64da\u6a21\u578b\uff1a<\/strong>\u652f\u6301\u591a\u7a2e\u6578\u64da\u7d50\u69cb\uff0c\u5982\u6587\u6a94\u3001\u9375\u503c\u3001\u5217\u65cf\u548c\u5716\u5f62\u7b49\u3002<\/li>\n<li><strong>\u9ad8\u64f4\u5c55\u6027\uff1a<\/strong>\u80fd\u5920\u8f15\u9b06\u5730\u901a\u904e\u589e\u52a0\u66f4\u591a\u7684\u4f3a\u670d\u5668\u4f86\u64f4\u5c55\u7cfb\u7d71\u7684\u8655\u7406\u80fd\u529b\u3002<\/li>\n<li><strong>\u9ad8\u53ef\u7528\u6027\uff1a<\/strong>\u901a\u5e38\u5177\u5099\u81ea\u52d5\u6545\u969c\u8f49\u79fb\u548c\u6578\u64da\u8907\u88fd\u529f\u80fd\uff0c\u78ba\u4fdd\u7cfb\u7d71\u7684\u7a69\u5b9a\u6027\u3002<\/li>\n<\/ul>\n<h2 id=\"%e9%98%bf%e9%87%8c%e9%81%8b%e7%b6%ad%e7%9a%84%e7%ae%a1%e7%90%86%e7%ad%96%e7%95%a5-HDhFDcofjW\">\u963f\u91cc\u904b\u7dad\u7684\u7ba1\u7406\u7b56\u7565<\/h2>\n<h3 id=\"1-%e6%95%b8%e6%93%9a%e5%88%86%e7%89%87-HDhFDcofjW\">1. \u6578\u64da\u5206\u7247<\/h3>\n<p>\u5728\u5927\u898f\u6a21NoSQL\u6578\u64da\u5eab\u4e2d\uff0c\u6578\u64da\u5206\u7247\u662f\u4e00\u7a2e\u5e38\u898b\u7684\u6280\u8853\u3002\u963f\u91cc\u904b\u7dad\u5718\u968a\u901a\u904e\u5c07\u6578\u64da\u5206\u6563\u5230\u591a\u500b\u4f3a\u670d\u5668\u4e0a\u4f86\u63d0\u9ad8\u6027\u80fd\u548c\u53ef\u64f4\u5c55\u6027\u3002\u9019\u6a23\u53ef\u4ee5\u6e1b\u5c11\u55ae\u500b\u4f3a\u670d\u5668\u7684\u8ca0\u64d4\uff0c\u4e26\u63d0\u9ad8\u67e5\u8a62\u901f\u5ea6\u3002<\/p>\n<pre><code>function shardData(data) {\n    \/\/ \u5047\u8a2d\u6709\u4e00\u500b\u5206\u7247\u51fd\u6578\n    return data.map(item =&gt; {\n        return {\n            shardId: getShardId(item),\n            data: item\n        };\n    });\n}<\/code><\/pre>\n<h3 id=\"2-%e6%95%b8%e6%93%9a%e8%a4%87%e8%a3%bd-HDhFDcofjW\">2. \u6578\u64da\u8907\u88fd<\/h3>\n<p>\u70ba\u4e86\u78ba\u4fdd\u6578\u64da\u7684\u9ad8\u53ef\u7528\u6027\uff0c\u963f\u91cc\u904b\u7dad\u5718\u968a\u5be6\u65bd\u4e86\u6578\u64da\u8907\u88fd\u7b56\u7565\u3002\u9019\u610f\u5473\u8457\u6bcf\u500b\u6578\u64da\u7247\u6bb5\u90fd\u6703\u5728\u591a\u500b\u4f3a\u670d\u5668\u4e0a\u9032\u884c\u5099\u4efd\uff0c\u5f9e\u800c\u5728\u67d0\u500b\u4f3a\u670d\u5668\u6545\u969c\u6642\u80fd\u5920\u8fc5\u901f\u6062\u5fa9\u6578\u64da\u3002<\/p>\n<pre><code>function replicateData(data) {\n    \/\/ \u5c07\u6578\u64da\u8907\u88fd\u5230\u591a\u500b\u4f3a\u670d\u5668\n    servers.forEach(server =&gt; {\n        server.store(data);\n    });\n}<\/code><\/pre>\n<h3 id=\"3-%e7%9b%a3%e6%8e%a7%e8%88%87%e9%a0%90%e8%ad%a6-HDhFDcofjW\">3. \u76e3\u63a7\u8207\u9810\u8b66<\/h3>\n<p>\u963f\u91cc\u904b\u7dad\u5718\u968a\u4f7f\u7528\u5148\u9032\u7684\u76e3\u63a7\u5de5\u5177\u4f86\u5be6\u6642\u8ddf\u8e64\u6578\u64da\u5eab\u7684\u6027\u80fd\u6307\u6a19\uff0c\u5982\u67e5\u8a62\u5ef6\u9072\u3001\u8cc7\u6e90\u4f7f\u7528\u7387\u7b49\u3002\u4e00\u65e6\u767c\u73fe\u7570\u5e38\u60c5\u6cc1\uff0c\u7cfb\u7d71\u6703\u81ea\u52d5\u767c\u9001\u9810\u8b66\u901a\u77e5\uff0c\u4fbf\u65bc\u904b\u7dad\u4eba\u54e1\u53ca\u6642\u8655\u7406\u3002<\/p>\n<h3 id=\"4-%e6%95%b8%e6%93%9a%e6%b8%85%e7%90%86%e8%88%87%e5%84%aa%e5%8c%96-HDhFDcofjW\">4. \u6578\u64da\u6e05\u7406\u8207\u512a\u5316<\/h3>\n<p>\u96a8\u8457\u6642\u9593\u7684\u63a8\u79fb\uff0c\u6578\u64da\u5eab\u4e2d\u53ef\u80fd\u6703\u7a4d\u7d2f\u5927\u91cf\u7684\u904e\u671f\u6216\u7121\u7528\u6578\u64da\u3002\u963f\u91cc\u904b\u7dad\u5718\u968a\u5b9a\u671f\u9032\u884c\u6578\u64da\u6e05\u7406\uff0c\u4e26\u512a\u5316\u6578\u64da\u7d50\u69cb\uff0c\u4ee5\u63d0\u9ad8\u67e5\u8a62\u6548\u7387\u548c\u5b58\u5132\u7a7a\u9593\u7684\u5229\u7528\u7387\u3002<\/p>\n<h2 id=\"%e7%b5%90%e8%ab%96-HDhFDcofjW\">\u7d50\u8ad6<\/h2>\n<p>\u963f\u91cc\u904b\u7dad\u5728\u7ba1\u7406\u5927\u898f\u6a21NoSQL\u6578\u64da\u5eab\u65b9\u9762\u7684\u6210\u529f\uff0c\u6e90\u65bc\u5176\u9748\u6d3b\u7684\u6578\u64da\u6a21\u578b\u3001\u9ad8\u6548\u7684\u6578\u64da\u5206\u7247\u548c\u8907\u88fd\u7b56\u7565\uff0c\u4ee5\u53ca\u5f37\u5927\u7684\u76e3\u63a7\u7cfb\u7d71\u3002\u9019\u4e9b\u7b56\u7565\u4e0d\u50c5\u63d0\u9ad8\u4e86\u6578\u64da\u5eab\u7684\u6027\u80fd\u548c\u53ef\u7528\u6027\uff0c\u9084\u70ba\u4f01\u696d\u7684\u6578\u64da\u7ba1\u7406\u63d0\u4f9b\u4e86\u6709\u529b\u652f\u6301\u3002<\/p>\n<p>\u5c0d\u65bc\u5e0c\u671b\u5728\u9999\u6e2f\u5c0b\u627e\u9ad8\u6548\u80fd\u7684\u6578\u64da\u89e3\u6c7a\u65b9\u6848\u7684\u4f01\u696d\uff0c\u9078\u64c7\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u6216 <a href=\"https:\/\/server.hk\">\u4e91\u4f3a\u670d\u5668<\/a> \u662f\u81f3\u95dc\u91cd\u8981\u7684\u3002\u900f\u904e\u5c08\u696d\u7684\u904b\u7dad\u7ba1\u7406\uff0c\u4f01\u696d\u80fd\u5920\u66f4\u597d\u5730\u61c9\u5c0d\u5927\u898f\u6a21\u6578\u64da\u6311\u6230\uff0c\u5be6\u73fe\u696d\u52d9\u7684\u6301\u7e8c\u589e\u9577\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u963f\u91cc\u904b\u7dad\u5982\u4f55\u9ad8\u6548\u7ba1\u7406\u5927\u898f\u6a21NoSQL\u6578\u64da\u5eab\uff0c\u78ba\u4fdd\u6578\u64da\u5b89\u5168\u6027\u3001\u53ef\u64f4\u5c55\u6027\u53ca\u6027\u80fd\u512a\u5316\u7684\u6700\u4f73\u5be6\u8e10\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-149177","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/149177","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"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=149177"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/149177\/revisions"}],"predecessor-version":[{"id":149178,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/149177\/revisions\/149178"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=149177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=149177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=149177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}