{"id":1465,"date":"2023-03-24T22:10:48","date_gmt":"2023-03-24T14:10:48","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1465"},"modified":"2023-04-28T20:37:12","modified_gmt":"2023-04-28T12:37:12","slug":"alibaba-registration-center-nacos-production-deployment-plan","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/24\/alibaba-registration-center-nacos-production-deployment-plan\/","title":{"rendered":"\u963f\u91cc\u6ce8\u518c\u4e2d\u5fc3Nacos\u751f\u4ea7\u90e8\u7f72\u65b9\u6848"},"content":{"rendered":"<h2>\u8bf4\u660e<\/h2>\n<p>\u751f\u4ea7\u73af\u5883\u4e2d\u90e8\u7f72<code>nacos<\/code>\u9996\u5148\u80af\u5b9a\u662f\u4f7f\u7528\u96c6\u7fa4\u6a21\u5f0f<code>cluster<\/code>\u4fdd\u8bc1\u9ad8\u53ef\u7528\uff0c\u672c\u6587\u4e3b\u8981\u8be6\u7ec6\u4ecb\u7ecd\u6700\u4f73\u7684\u96c6\u7fa4\u65b9\u6848\u600e\u6837\u642d\u5efa\u4e0e<code>spring cloud<\/code>\u7a0b\u5e8f\u600e\u6837\u96c6\u6210<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/nacos.io\/zh-cn\/docs\/cluster-mode-quick-start.html\">https:\/\/nacos.io\/zh-cn\/docs\/cluster-mode-quick-start.html<\/a><br \/>\n\u672c\u6587\u8f6c\u8f7d\u81f3\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/www.cnblogs.com\/zlt2000\/p\/11381823.html\">https:\/\/www.cnblogs.com\/zlt2000\/p\/11381823.html<\/a><\/p>\n<p><!-- more --><\/p>\n<h2>\u96c6\u7fa4\u65b9\u6848<\/h2>\n<p>\u4e0b\u56fe\u662f\u5b98\u65b9\u63a8\u8350\u7684\u96c6\u7fa4\u65b9\u6848\uff0c\u901a\u8fc7<code>\u57df\u540d + VIP<\/code>\u6a21\u5f0f\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\uff0c\u53ef\u8bfb\u6027\u597d\u800c\u4e14\u6362ip\u65b9\u4fbf<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u8fd0\u7ef4\/Nacos\u96c6\u7fa4\u65b9\u6848.jpg\" alt=\"Nacos\u96c6\u7fa4\u65b9\u6848\" \/><\/p>\n<p>\u8fd9\u91cc\u7684<code>VIP<\/code>\u76f4\u63a5\u4f7f\u7528<code>Nginx<\/code>\u5373\u53ef\u5b9e\u73b0<\/p>\n<h2>\u65b9\u6848\u5b9e\u73b0<\/h2>\n<p><code>nacos<\/code>\u96c6\u7fa4\u6700\u4f4e\u914d\u7f6e\u662f\u81f3\u5c11\u9700\u89813\u4e2a\u5b9e\u4f8b\uff0c\u56e0\u4e3a\u6211\u5728\u672c\u5730\u642d\u5efa\u53ea\u6709\u4e00\u53f0\u673a\u5668\u6240\u4ee5\u901a\u8fc7\u4fee\u6539\u7aef\u53e3\u7684\u65b9\u5f0f\u6765\u90e8\u7f72\u8fd93\u4e2a\u5b9e\u4f8b\uff0c\u7aef\u53e3\u5206\u522b\u4e3a\uff1a<code>8848<\/code>\u3001<code>8849<\/code>\u3001<code>8850<\/code><\/p>\n<h3>\u4fee\u6539\u96c6\u7fa4\u914d\u7f6e<\/h3>\n<p><code>nacos<\/code>\u7684<code>conf<\/code>\u76ee\u5f55\u4e0b\u6709\u914d\u7f6e\u6587\u4ef6<code>cluster.conf<\/code>\uff0c\u8bf7\u6bcf\u884c\u914d\u7f6e\u6210<code>ip:port<\/code>\u3002<\/p>\n<pre><code>192.168.28.130:8848\n192.168.28.130:8849\n192.168.28.130:8850<\/code><\/pre>\n<p>\u4e3a\u6d4b\u8bd5\u65b9\u4fbf\uff0c\u5c06\u4e09\u4e2a\u793a\u4f8b\u5747\u90e8\u7f72\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\uff0c192.168.28.130\u662f\u672c\u673aip\uff0c\u4e09\u4e2anacos\u5b9e\u4f8b\u90fd\u914d\u7f6e\u4e00\u6837\u5373\u53ef<\/p>\n<h3>\u914d\u7f6e MySQL \u6570\u636e\u5e93<\/h3>\n<p>\u96c6\u7fa4\u6a21\u5f0f\u5fc5\u987b\u4f7f\u7528MySQL\u6570\u636e\u5e93\uff0c\u751f\u4ea7\u4f7f\u7528\u5efa\u8bae\u81f3\u5c11\u4e3b\u5907\u6a21\u5f0f\uff0c\u6216\u8005\u91c7\u7528\u9ad8\u53ef\u7528\u6570\u636e\u5e93<\/p>\n<h4>\u521d\u59cb\u5316 MySQL \u6570\u636e\u5e93<\/h4>\n<p>\u811a\u672c\u5728<code>nacos<\/code>\u7684<code>conf<\/code>\u76ee\u5f55\u4e0b\u6709\u914d\u7f6e\u6587\u4ef6<code>nacos-mysql.sql<\/code>\uff0c\u76f4\u63a5\u6267\u884c\u5373\u53ef<\/p>\n<h4>\u6dfb\u52a0\u6570\u636e\u5e93\u914d\u7f6e<\/h4>\n<p>\u914d\u7f6e\u6587\u4ef6\u5728<code>nacos<\/code>\u7684<code>conf<\/code>\u76ee\u5f55\u4e0b\u7684<code>application.properties<\/code>\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e<\/p>\n<pre><code>db.num=1\ndb.url.0=jdbc:mysql:\/\/192.168.28.131:3306\/nacos_config?characterEncoding=utf8&amp;connectTimeout=1000&amp;socketTimeout=3000&amp;autoReconnect=true\ndb.user=root\ndb.password=root<\/code><\/pre>\n<pre><code>`db.num`\u4e3a\u6570\u636e\u5e93\u5b9e\u4f8b\u6570\u91cf\n\u5982\u679c\u6709\u591a\u4e2a\u6570\u636e\u5e93\u5b9e\u4f8b\u901a\u8fc7`db.url.0`\u3001`db.url.1`..... \u6307\u5b9a\u4e0d\u540c\u7684\u6570\u636e\u5e93\u94fe\u63a5<\/code><\/pre>\n<h3>\u5176\u4ed6\u5b9e\u4f8b\u4fee\u6539Nacos\u7aef\u53e3<\/h3>\n<p>\u4fee\u6539<code>nacos<\/code>\u7684<code>conf<\/code>\u76ee\u5f55\u4e0b<code>application.properties<\/code>\u4e0b\u7684<code>server.port<\/code>\u53d8\u91cf\uff0c\u4e09\u4e2a\u5b9e\u4f8b\u5206\u522b\u4e3a\uff1a<code>8848<\/code>\u3001<code>8849<\/code>\u3001<code>8850<\/code><\/p>\n<pre><code>server.contextPath=\/nacos\nserver.servlet.contextPath=\/nacos\nserver.port=8848<\/code><\/pre>\n<p>\u5982\u679c\u662f\u4e0d\u540c\u673a\u5668\u90e8\u7f72\u96c6\u7fa4\u7684\u8bdd\u8fd9\u6b65\u53ef\u4ee5\u5ffd\u7565<\/p>\n<h3>\u542f\u52a8Nacos\u96c6\u7fa4<\/h3>\n<p>\u5206\u522b\u628a3\u4e2a\u5b9e\u4f8b\u90fd\u542f\u52a8\u8d77\u6765\uff0c\u6267\u884c<code>nacos<\/code>\u7684<code>bin<\/code>\u76ee\u5f55\u4e0b<code>startup.sh<\/code>\uff0c\u8be5\u542f\u52a8\u6587\u4ef6\u9ed8\u8ba4\u5c31\u662f\u96c6\u7fa4\u6a21\u5f0f<\/p>\n<h3>\u4fee\u6539Nginx\u914d\u7f6e<\/h3>\n<p>\u4fee\u6539<code>conf\/nginx.conf<\/code>\u914d\u7f6e<\/p>\n<pre><code>upstream nacos {\n    server 192.168.28.130:8848;\n    server 192.168.28.130:8849;\n    server 192.168.28.130:8850;\n}\n\nserver {\n    listen 80;\n\n    server_name test.nacos.com;\n\n    location \/ {\n        proxy_pass http:\/\/nacos;\n    }\n}<\/code><\/pre>\n<p>\u914d\u7f6e\u57df\u540d<code>test.nacos.com<\/code>\u7ed1\u5b9a<code>VIP<\/code><\/p>\n<h3>\u5e94\u7528\u96c6\u6210Nacos\u96c6\u7fa4<\/h3>\n<p><code>nacos<\/code>\u7684\u5730\u5740<code>server-addr<\/code>\u914d\u7f6e\u57df\u540d<code>test.nacos.com<\/code><\/p>\n<pre><code class=\"language-yml\">common:\n  nacos:\n    server-addr: test.nacos.com\n\nspring:\n  application:\n    name: user-center\n  cloud:\n    nacos:\n      config:\n        server-addr: ${common.nacos.server-addr}\n        file-extension: yaml\n        shared-dataids: common.yml\n        refreshable-dataids: common.yml\n      discovery:\n        server-addr: ${common.nacos.server-addr}<\/code><\/pre>\n<h2>Nacos\u96c6\u7fa4\u7ba1\u7406<\/h2>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u8fd0\u7ef4\/Nacos\u96c6\u7fa4\u7ba1\u7406.jpg\" alt=\"Nacos\u96c6\u7fa4\u7ba1\u7406\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf4\u660e \u751f\u4ea7\u73af\u5883\u4e2d\u90e8\u7f72nacos\u9996\u5148\u80af\u5b9a\u662f\u4f7f\u7528\u96c6\u7fa4\u6a21\u5f0fcluster\u4fdd\u8bc1\u9ad8\u53ef\u7528\uff0c\u672c\u6587\u4e3b\u8981\u8be6\u7ec6\u4ecb\u7ecd\u6700\u4f73\u7684\u96c6\u7fa4\u65b9\u6848\u600e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-1465","post","type-post","status-publish","format-standard","hentry","category-nacos"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1465"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1465\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}