{"rsdb":{"rid":"397616","subhead":"","postdate":"0","aid":"273658","fid":"76","uid":"1","topic":"1","content":"
\n

1 Nacos ?\u81f4\u6027\u534f\u8bae<\/h2> \n

1.1 \u4e3a\u4ec0\u4e48 Nacos \u9700\u8981?\u81f4\u6027\u534f\u8bae<\/h3> \n

Nacos\u5c3d\u53ef\u80fd\u51cf\u5c11\u7528\u6237\u90e8\u7f72\u4ee5\u53ca\u8fd0\u7ef4\u6210\u672c\uff0c\u505a\u5230\u7528\u6237\u53ea\u9700\u8981?\u4e2a\u7a0b\u5e8f\u5305\uff0c\u5c31\u5feb\u901f\u5355\u673a\u6a21\u5f0f\u542f\u52a8 Nacos \u6216\u96c6\u7fa4\u6a21\u5f0f\u542f\u52a8 Nacos\u3002\u800c Nacos \u662f?\u4e2a\u9700\u8981\u5b58\u50a8\u6570\u636e\u7684\u7ec4\u4ef6\uff0c\u4e3a\u5b9e\u73b0\u76ee\u6807\uff0c\u5c31\u8981\u5728 Nacos \u5185\u90e8\u5b9e\u73b0\u6570\u636e\u5b58\u50a8\u3002\u5355\u673a\u95ee\u9898\u4e0d\u5927\uff0c\u5185\u5d4c\u5173\u7cfb\u578b\u6570\u636e\u5e93\u5373\u53ef\uff1b\u4f46\u96c6\u7fa4\u6a21\u5f0f\u5c31\u8981\u8003\u8651\u4fdd\u969c\u5404\u8282\u70b9\u95f4\u7684\u6570\u636e?\u81f4\u6027\u53ca\u6570\u636e\u540c\u6b65\uff0c\u5c31\u5f97\u5f15\u5165\u5171\u8bc6\u7b97\u6cd5\uff0c\u901a\u8fc7\u7b97\u6cd5\u4fdd\u969c\u5404\u8282\u70b9\u95f4\u7684\u6570\u636e?\u81f4\u6027\u3002<\/p> \n

1.2 \u4e3a\u4ec0\u4e48 Nacos \u9009\u62e9\u4e86 Raft \u4ee5\u53ca Distro<\/h3> \n

Nacos \u5728\u5355\u4e2a\u96c6\u7fa4\u4e2d\u540c\u65f6\u8fd0\u884c CP \u534f\u8bae\u53ca AP \u534f\u8bae\uff1f\u8981\u4ece Nacos \u573a\u666f\u51fa\u53d1\uff1aNacos \u96c6\u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u53ca\u914d\u7f6e\u7ba1\u7406\u4e8e?\u4f53\uff0c\u96c6\u7fa4\u4e0b\uff0c\u5404\u8282\u70b9\u95f4\u7684\u6570\u636e?\u81f4\u6027\u4fdd\u969c\u95ee\u9898\uff0c\u9700\u62c6\u5206\u6210\u4e24\u65b9\u9762\uff1a<\/p> \n

\u2460 \u4ece\u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u6765\u770b<\/h4> \n

\u670d\u52a1\u4e4b\u95f4\u611f\u77e5\u5bf9\u65b9\u670d\u52a1\u7684\u5f53\u524d\u53ef\u6b63\u5e38\u63d0\u4f9b\u670d\u52a1\u7684\u5b9e\u4f8b\u4fe1\u606f\uff0c\u987b\u4ece\u670d\u52a1\u53d1\u73b0\u6ce8\u518c\u4e2d\u5fc3\u83b7\u53d6\uff0c\u56e0\u6b64\u5bf9\u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u4e2d\u5fc3\u7ec4\u4ef6\u7684\u53ef\u7528\u6027\u63d0\u51fa\u9ad8\u8981\u6c42\uff0c\u9700\u5728\u4efb\u4f55\u573a\u666f\u5c3d\u6700\u5927\u53ef\u80fd\u4fdd\u8bc1\u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u80fd\u529b\u53ef\u4ee5\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\uff1b\u540c\u65f6 Nacos \u7684\u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u8bbe\u8ba1\uff0c\u91c7\u53d6\u4e86\u5fc3\u8df3\u53ef\u81ea\u52a8\u5b8c\u6210\u670d\u52a1\u6570\u636e\u8865\u507f\u7684\u673a\u5236\u3002\u5982\u679c\u6570\u636e\u4e22\u5931\u7684\u8bdd\uff0c\u662f\u53ef\u4ee5\u901a\u8fc7\u8be5\u673a\u5236\u5feb\u901f\u5f25\u8865\u6570\u636e\u4e22\u5931\u3002<\/p> \n

\u4e3a\u6ee1\u8db3\u670d\u52a1\u53d1\u73b0\u6ce8\u518c\u4e2d\u5fc3\u7684\u53ef\u7528\u6027\uff0c\u5f3a?\u81f4\u6027\u5171\u8bc6\u7b97\u6cd5\u4e0d\u592a\u5408\u9002\uff0c\u56e0\u4e3a\u5f3a?\u81f4\u6027\u5171\u8bc6\u7b97\u6cd5\u80fd\u5426\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\u6709\u8981\u6c42\uff0c\u5982\u5f53\u524d\u96c6\u7fa4\u53ef\u7528\u8282\u70b9\u6570\u6ca1\u8fc7\u534a\uff0c\u6574\u4e2a\u7b97\u6cd5\u76f4\u63a5\u201c\u7f62\u5de5\u201d\uff0c\u800c\u6700\u7ec8?\u81f4\u5171\u8bc6\u7b97\u6cd5\u66f4\u591a\u4fdd\u969c\u670d\u52a1\u53ef\u7528\u6027\uff0c\u5e76\u80fd\u4fdd\u8bc1\u5728?\u5b9a\u65f6\u95f4\u5185\u5404\u8282\u70b9\u4e4b\u95f4\u6570\u636e\u80fd\u8fbe\u6210?\u81f4\u3002\u4e0a\u8ff0\u90fd\u662f\u9488\u5bf9 Nacos \u670d\u52a1\u53d1\u73b0\u6ce8\u518c\u4e2d\u7684\u975e\u6301\u4e45\u5316\u670d\u52a1\uff08\u5373\u9700\u5ba2\u6237\u7aef\u4e0a\u62a5\u5fc3\u8df3\u8fdb\u884c\u670d\u52a1\u5b9e\u4f8b\u7eed\u7ea6\uff09\u3002<\/p> \n

\u800c\u5bf9 Nacos \u670d\u52a1\u53d1\u73b0\u6ce8\u518c\u4e2d\u7684\u6301\u4e45\u5316\u670d\u52a1\uff0c\u56e0\u4e3a\u6240\u6709\u6570\u636e\u90fd\u662f\u76f4\u63a5\u8c03\u7528 Nacos\u670d\u52a1\u7aef\u76f4\u63a5\u521b\u5efa\uff0c\u56e0\u6b64\u9700\u7531 Nacos \u4fdd\u969c\u6570\u636e\u5728\u5404\u8282\u70b9\u95f4\u7684\u5f3a?\u81f4\u6027\uff0c\u56e0\u6b64\u9488\u5bf9\u6b64\u7c7b\u578b\u7684\u670d\u52a1\u6570\u636e\uff0c\u9009\u62e9\u5f3a?\u81f4\u6027\u5171\u8bc6\u7b97\u6cd5\u6765\u4fdd\u969c\u6570\u636e?\u81f4\u6027\u3002<\/p> \n

\u2461 \u914d\u7f6e\u7ba1\u7406<\/h4> \n

\u914d\u7f6e\u6570\u636e\u76f4\u63a5\u5728 Nacos \u670d\u52a1\u7aef\u8fdb\u884c\u521b\u5efa\u5e76\u7ba1\u7406\uff0c\u987b\u4fdd\u8bc1\u5927\u90e8\u5206\u7684\u8282\u70b9\u90fd\u4fdd\u5b58\u6b64\u914d\u7f6e\u6570\u636e\uff0c\u624d\u80fd\u8ba4\u4e3a\u914d\u7f6e\u88ab\u6210\u529f\u4fdd\u5b58\uff0c\u5426\u5219\u5c31\u4f1a\u4e22\u5931\u914d\u7f6e\u7684\u53d8\u66f4\uff0c\u95ee\u9898\u5f88\u4e25\u91cd\uff0c\u5982\u53d1\u5e03\u91cd\u8981\u914d\u7f6e\u53d8\u66f4\u51fa\u73b0\u4e22\u5931\u53d8\u66f4\uff0c\u591a\u534a\u5f15\u8d77\u4e25\u91cd\u73b0\u7f51\u6545\u969c\uff0c\u56e0\u6b64\u5bf9\u914d\u7f6e\u6570\u636e\u7684\u7ba1\u7406\uff0c\u987b\u96c6\u7fa4\u4e2d\u5927\u90e8\u5206\u8282\u70b9\u5f3a?\u81f4\uff0c\u8fd9\u91cc\u53ea\u80fd\u4f7f\u7528\u5f3a?\u81f4\u6027\u5171\u8bc6\u7b97\u6cd5\u3002<\/p> \n

\u2462 \u4e3a\u5565\u662f Raft \u548c Distro<\/h4> \n

\u5f3a?\u81f4\u6027\u5171\u8bc6\u7b97\u6cd5\uff0c\u5f53\u524d\u6700\u591a\u4f7f\u7528 Raft \u534f\u8bae\uff0c\u6613\u8ba9\u4eba\u7406\u89e3\uff0c\u5e76\u6709\u5f88\u591a\u6210\u719f\u5de5\u4e1a\u7b97\u6cd5\u5b9e\u73b0\uff0c\u5982\u8682\u8681\u91d1\u670d JRaft\u3001Zookeeper ZAB\u3001Consul Raft\u3001\u767e\u5ea6 braft\u3001Apache Ratis\uff1b\u56e0\u4e3a Nacos \u662f Java \u6280\u672f\u6808\uff0c\u56e0\u6b64\u53ea\u80fd\u5728 JRaft\u3001ZAB\u3001ApacheRatis \u4e2d\u9009\u62e9\uff0c\u4f46ZAB \u548c Zookeeper \u5f3a\u7ed1\u5b9a\uff0c\u518d\u52a0\u4e0a\u5e0c\u671b\u53ef\u4ee5\u548c Raft \u7b97\u6cd5\u5e93\u652f\u6301\u56e2\u961f\u968f\u65f6\u6c9f\u901a\u4ea4\u6d41\uff0c\u56e0\u6b64\u9009\u62e9 JRaft\uff0c\u4e5f\u56e0\u4e3a JRaft \u652f\u6301\u591a RaftGroup\uff0c\u4e3a Nacos \u540e\u9762\u7684\u591a\u6570\u636e\u5206\u7247\u5e26\u6765\u53ef\u80fd\u3002<\/p> \n

\u800c Distro \u534f\u8bae\u662f\u963f\u91cc\u5df4\u5df4\u81ea\u7814\u7684?\u4e2a\u6700\u7ec8?\u81f4\u6027\u534f\u8bae\uff0c\u6700\u7ec8?\u81f4\u6027\u534f\u8bae\u5f88\u591a\u5982 Gossip\u3001Eureka \u5185\u7684\u6570\u636e\u540c\u6b65\u7b97\u6cd5\u3002Distro \u7b97\u6cd5\u96c6 Gossip \u53ca Eureka \u534f\u8bae\u4f18\u70b9\u5e76\u4f18\u5316\u800c\u51fa\uff0c\u539f\u751f Gossip\u7531\u4e8e\u968f\u673a\u9009\u53d6\u53d1\u9001\u6d88\u606f\u7684\u8282\u70b9\uff0c\u4e0d\u53ef\u907f\u514d\u5b58\u5728\u6d88\u606f\u91cd\u590d\u53d1\u7ed9\u540c?\u8282\u70b9\u60c5\u51b5\uff0c\u589e\u52a0\u7f51\u7edc\u4f20\u8f93\u7684\u538b\u529b\uff0c\u4e5f\u7ed9\u6d88\u606f\u8282\u70b9\u5e26\u6765\u989d\u5916\u7684\u5904\u7406\u8d1f\u8f7d\uff0c\u800c Distro \u7b97\u6cd5\u5f15\u5165\u6743\u5a01 Server \u6982\u5ff5\uff0c\u6bcf\u4e2a\u8282\u70b9\u8d1f\u8d23?\u90e8\u5206\u6570\u636e\u53ca\u5c06\u81ea\u5df1\u7684\u6570\u636e\u540c\u6b65\u7ed9\u5176\u4ed6\u8282\u70b9\uff0c\u6709\u6548\u964d\u4f4e\u6d88\u606f\u5197\u4f59\u95ee\u9898\u3002<\/p> \n

2 \u65e9\u671f\u7684 Nacos ?\u81f4\u6027\u534f\u8bae<\/strong><\/h2> \n

2.1 \u65e9\u671f Naocs \u67b6\u6784<\/h3> \n

\"\"<\/p> \n

\u7279\u70b9<\/h3> \n

\u670d\u52a1\u6ce8\u518c\u548c\u914d\u7f6e\u7ba1\u7406?\u81f4\u6027\u534f\u8bae \u5206\u5f00\uff0c\u6ca1\u4e0b\u6c89\u5230 Nacos\u5185\u6838\u6a21\u5757\u4f5c\u4e3a\u901a\u7528\u80fd\u529b<\/p> \n

    \n
  • \u670d\u52a1\u53d1\u73b0\u6a21\u5757?\u81f4\u6027\u534f\u8bae\u7684\u5b9e\u73b0\u548c\u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u6a21\u5757\u7684\u903b\u8f91\u5f3a\u8026\u5408<\/li> \n
  • \u5145\u65a5\u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u7684\u6982\u5ff5<\/li> \n <\/ul> \n

    \u7f3a\u70b9<\/h3> \n
      \n
    • Nacos \u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u6a21\u5757\u903b\u8f91\u590d\u6742\u96be\u7ef4\u62a4\uff0c\u8026\u5408\u4e86?\u81f4\u6027\u534f\u8bae\u5c42\u7684\u6570\u636e\u72b6\u6001<\/li> \n
    • \u8ba1\u7b97\u5b58\u50a8\u5f7b\u5e95\u96be\u4ee5\u5206\u79bb<\/li> \n
    • \u5bf9\u8ba1\u7b97\u5c42\u7684\u65e0\u9650\u6c34\u5e73\u6269\u5bb9\u80fd\u529b\u4e5f\u6709\u5f71\u54cd<\/li> \n <\/ul> \n

      \u56e0\u6b64\u5fc5\u7136\u8981\u5bf9 Nacos?\u81f4\u6027\u534f\u8bae\u505a\u62bd\u8c61\u53ca\u4e0b\u6c89\uff0c\u4f7f\u5176\u6210\u4e3a Core \u6a21\u5757\u80fd\u529b\uff0c\u5f7b\u5e95\u8ba9\u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u6a21\u5757\u53ea\u5145\u5f53\u8ba1\u7b97\u80fd\u529b\uff0c\u540c\u65f6\u4e3a\u914d\u7f6e\u6a21\u5757\u53bb\u5916\u90e8\u6570\u636e\u5e93\u5b58\u50a8\u6253\u4e0b\u67b6\u6784\u57fa\u7840\u3002<\/p> \n

      3 \u5f53\u524d Nacos \u7684?\u81f4\u6027\u534f\u8bae\u5c42<\/h2> \n

      \u5f53\u524d Nacos \u5185\u6838\u4e2d\uff0c\u5df2\u5c06?\u81f4\u6027\u534f\u8bae\u7684\u80fd\u529b\u5b8c\u5168\u4e0b\u6c89\u5230\u5185\u6838\u6a21\u5757\u4f5c\u4e3a Nacos \u6838\u5fc3\u80fd\u529b\uff0c\u5f88\u597d\u7684\u670d\u52a1\u4e8e\u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u6a21\u5757\u53ca\u914d\u7f6e\u7ba1\u7406\u6a21\u5757\u3002<\/p> \n

      3.1 \u5f53\u524d Nacos \u7684\u67b6\u6784<\/h3> \n

      \"\"<\/p> \n

      \u7279\u70b9<\/h3> \n

      \u65b0 Nacos \u67b6\u6784\u5c06?\u81f4\u6027\u534f\u8bae\u4ece\u539f\u5148\u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u6a21\u5757\u4e0b\u6c89\u5230\u5185\u6838\u6a21\u5757\uff0c\u5e76\u5c3d\u53ef\u80fd\u63d0\u4f9b\u7edf?\u62bd\u8c61\u63a5\u53e3\uff0c\u4f7f\u4e0a\u5c42\u7684\u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u6a21\u5757\u53ca\u914d\u7f6e\u7ba1\u7406\u6a21\u5757\uff0c\u4e0d\u518d\u8026\u5408\u4efb\u4f55?\u81f4\u6027\u8bed\u4e49\u3002<\/p> \n

      \u4f18\u70b9<\/h3> \n

      \u89e3\u8026\u62bd\u8c61\u5206\u5c42\u540e\uff0c\u6bcf\u4e2a\u6a21\u5757\u80fd\u5feb\u901f\u6f14\u8fdb\uff0c\u5e76\u4e14\u6027\u80fd\u548c\u53ef\u7528\u6027\u90fd\u5927\u5e45\u63d0\u5347\u3002<\/p> \n

      4 Nacos \u5982\u4f55\u505a\u5230?\u81f4\u6027\u534f\u8bae\u4e0b\u6c89<\/h2> \n

      \u65e2\u7136 Nacos \u5c06 AP\u3001CP \u534f\u8bae\u4e0b\u6c89\u5230\u5185\u6838\u6a21\u5757\uff1a<\/p> \n

      \"\"<\/p> \n

      \u4e14\u5c3d\u53ef\u80fd\u4fdd\u6301\u4e86?\u6837\u7684\u4f7f\u7528\u4f53\u9a8c\u3002\u90a3\u8fd9?\u81f4\u6027\u534f\u8bae\u4e0b\u6c89\u5982\u4f55\u505a\u5230\u7684\uff1f<\/p> \n

      ?\u81f4\u6027\u534f\u8bae\u62bd\u8c61<\/h3> \n

      \u5176\u5b9e\uff0c?\u81f4\u6027\u534f\u8bae\uff0c\u5c31\u662f\u7528\u6765\u4fdd\u8bc1\u6570\u636e?\u81f4\u7684\uff0c\u800c\u6570\u636e\u7684\u4ea7\u751f\uff0c\u5fc5\u7136\u6709?\u4e2a\u5199\u5165\u7684\u52a8\u4f5c\uff1b\u540c\u65f6\u8fd8\u8981\u80fd\u591f\u8bfb\u6570\u636e\uff0c\u5e76\u4e14\u4fdd\u8bc1\u8bfb\u6570\u636e\u7684\u52a8\u4f5c\u4ee5\u53ca\u5f97\u5230\u7684\u6570\u636e\u7ed3\u679c\uff0c\u5e76\u4e14\u80fd\u591f\u5f97\u5230?\u81f4\u6027\u534f\u8bae\u7684\u4fdd\u969c\u3002\u56e0\u6b64\uff0c?\u81f4\u6027\u534f\u8bae\u6700\u6700\u57fa\u7840\u7684\u4e24\u4e2a\u65b9\u6cd5\uff0c\u5c31\u662f\u5199\u52a8\u4f5c\u548c\u8bfb\u52a8\u4f5c<\/p> \n

      public interface ConsistencyProtocol<T extends Config, P extends RequestProcessor> extends CommandOperations {\n  \n    \/**\n     * Obtain data according to the request.\n     *\/\n    Response getData(ReadRequest request) throws Exception;\n    \n    \/**\n     * \u540c\u6b65\u6570\u636e\u63d0\u4ea4\uff0c\u5728 Datum \u4e2d\u5df2\u643a\u5e26\u76f8\u5e94\u7684\u6570\u636e\u64cd\u4f5c\u4fe1\u606f\n     *\/\n    Response write(WriteRequest request) throws Exception;\n}\n<\/code><\/pre> \n 

      \u4efb\u4f55\u4f7f\u7528?\u81f4\u6027\u534f\u8bae\u7684\uff0c\u53ea\u9700\u4f7f\u7528 getData \u53ca write \u65b9\u6cd5\u3002<\/p> \n

      ?\u81f4\u6027\u534f\u8bae\u62bd\u8c61\u5728 consistency \u5305\uff0cNacos \u5bf9 AP\u3001CP ?\u81f4\u6027\u534f\u8bae\u63a5\u53e3\u4f7f\u7528\u62bd\u8c61\u90fd\u5728\uff0c\u4e14\u5b9e\u73b0\u5177\u4f53?\u81f4\u6027\u534f\u8bae\u65f6\uff0c\u91c7\u7528\u63d2\u4ef6\u53ef\u63d2\u62d4\uff0c\u8fdb?\u6b65\u5c06?\u81f4\u6027\u534f\u8bae\u5177\u4f53\u5b9e\u73b0\u903b\u8f91\u548c\u670d\u52a1\u6ce8\u518c\u53d1\u73b0\u3001\u914d\u7f6e\u7ba1\u7406\u4e24\u4e2a\u6a21\u5757\u89e3\u8026\u3002<\/p> \n

      package com.alibaba.nacos.core.distributed;\n\n\/**\n * Conformance protocol management, responsible for managing the lifecycle of conformance protocols in Nacos.\n *\/\n@SuppressWarnings("all")\n@Component(value = "ProtocolManager")\npublic class ProtocolManager extends MemberChangeListener implements DisposableBean {\n    \n    private void initAPProtocol() {\n        ApplicationUtils.getBeanIfExist(APProtocol.class, protocol -> {\n            Class configType = ClassUtils.resolveGenericType(protocol.getClass());\n            Config config = (Config) ApplicationUtils.getBean(configType);\n            injectMemb","orderid":"0","title":"\u8bf4\u900f Nacos \u4e00\u81f4\u6027\u534f\u8bae(\u4e00)","smalltitle":"","mid":"0","fname":"JAVA","special_id":"0","bak_id":"0","info":"0","hits":"316","pages":"2","comments":"0","posttime":"2023-09-23 15:44:46","list":"1695455086","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"\u8bf4\u900f<\/A> Nacos<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"112.94.1.100","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"\u8bf4\u900f Nacos \u4e00\u81f4\u6027\u534f\u8bae","lastview":"1716230774","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}