{"id":1078,"date":"2024-12-06T23:21:07","date_gmt":"2024-12-06T15:21:07","guid":{"rendered":"http:\/\/www.huerpu.cc:7000\/?p=1078"},"modified":"2024-12-06T23:21:07","modified_gmt":"2024-12-06T15:21:07","slug":"spring-cloudkilburn-2022-0-2%e7%89%88%e6%9c%ac%e7%b3%bb%e5%88%97%e6%95%99%e7%a8%8b%e5%85%ad-%e5%88%86%e5%b8%83%e5%bc%8f%e9%85%8d%e7%bd%ae%e4%b8%ad%e5%bf%83apollo","status":"publish","type":"post","link":"http:\/\/www.huerpu.cc:7000\/?p=1078","title":{"rendered":"Spring Cloud(Kilburn 2022.0.2\u7248\u672c)\u7cfb\u5217\u6559\u7a0b(\u516d) \u5206\u5e03\u5f0f\u914d\u7f6e\u4e2d\u5fc3(Apollo)"},"content":{"rendered":"<h1>Spring Cloud(Kilburn 2022.0.2\u7248\u672c)\u7cfb\u5217\u6559\u7a0b(\u516d) \u5206\u5e03\u5f0f\u914d\u7f6e\u4e2d\u5fc3(Apollo)<\/h1>\n<h2>\u4e00\u3001\u5b89\u88c5\u8bf4\u660e<\/h2>\n<p>\u5b89\u88c5Apollo\u5fc5\u987b\u6709Java\u73af\u5883\u3002<\/p>\n<ul>\n<li>Apollo\u670d\u52a1\u7aef\uff1a1.8+<\/li>\n<li>Apollo\u5ba2\u6237\u7aef\uff1a1.8+<\/li>\n<\/ul>\n<pre><code class=\"language-shell\">#\u5b89\u88c5jdk8\u5f88\u7b80\u5355\uff0c\u5c31\u4e00\u884c\u547d\u4ee4\u5373\u53ef\napt install openjdk-8-jdk\n\n#\u67e5\u770bjava\u7248\u672c\njava -version<\/code><\/pre>\n<p>\u5b89\u88c5Apollo\u5fc5\u987b\u6709\u6570\u636e\u5e93\uff0cMySQL\u3001H2\u5185\u5b58\u6570\u636e\u5e93\u3001H2\u6587\u4ef6\u6570\u636e\u5e93\u4e09\u8005\u9009\u5176\u4e00\u3002\u4e3a\u4e86\u66f4\u597d\u7684\u5b89\u5168\u6027\u4e0e\u6027\u80fd\uff0c\u5efa\u8bae\u4f7f\u7528MySQL\u3002<\/p>\n<pre><code class=\"language-shell\">#\u6211\u4eec\u662f\u5728Ubuntu24.04\u4e0a\u5b89\u88c5\u7684MySQL8,\u5148\u83b7\u53d6deb\u5b89\u88c5\u5305\nwget https:\/\/dev.mysql.com\/get\/mysql-apt-config_0.8.17-1_all.deb\n\n#\u5b89\u88c5\nsudo dpkg -i mysql-apt-config_0.8.17-1_all.deb\n\n#\u9009\u62e9 ubuntu focal\n#\u9009\u62e9 MySQL Server &amp; Cluster (Currently selected: mysql-8.0)\n\n#\u5b89\u88c5\napt-get  install mysql-server\n\n#\u67e5\u770b\u72b6\u6001\nsystemctl status mysql\n\n#\u767b\u5f55MySQL\nmysql -uroot -p\n\n#\u4fee\u6539root\u5bc6\u7801\nALTER USER &#039;root&#039;@&#039;localhost&#039; IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY &#039;123456&#039;;\n\n#\u5982\u679c\u4fee\u6539\u4e0d\u6210\u529f\uff0c\u53ef\u4ee5\u6267\u884c\u4e0b\u9762\u8fd9\u4e00\u53e5\ncreate user &#039;root&#039;@&#039;%&#039; identified by &#039;123456&#039;;\n\n#\u6388\u6743\u6240\u6709\u64cd\u4f5c\u6743\u9650\u7ed9root\ngrant all privileges on *.* to &#039;root&#039;@&#039;%&#039;;\n\n#\u521b\u5efa\u4e00\u4e2ahep\u7528\u6237\uff0c\u5e76\u6388\u6743\u6240\u6709\u64cd\u4f5c\u6743\u9650\ncreate user &#039;hep&#039;@&#039;%&#039; identified by &#039;123456&#039;;\ngrant all privileges on *.* to &#039;hep&#039;@&#039;%&#039;;\n\n#\u5237\u65b0\u6743\u9650\nflush privileges;\n\n#\u9000\u51fa\nexit;\n\n#\u4f7f\u5f97mysql\u53ef\u4ee5\u8fdc\u7a0b\u767b\u9646\nvim \/etc\/mysql\/mysql.conf.d\/mysqld.cnf\n#\u6ce8\u91ca\u6389\u8fd9\u4e00\u884c\n#bind-address = 127.0.0.1\n\n#\u91cd\u542fmysql\nservice mysql restart;\n\n#\u5f00\u653e3306\u7aef\u53e3\nufw allow 3306\n\n#\u67e5\u770b3306\u7aef\u53e3\u662f\u5426\u88ab\u76d1\u542c\nnetstat -anp | grep mysql<\/code><\/pre>\n<p>\u4e0b\u9762\u5373\u53ef\u7528navicat\u7c7b\u4f3c\u7684\u8f6f\u4ef6\u8fde\u63a5\u5e76\u8fdb\u884c\u521b\u5efa\u6570\u636e\u5e93\u4e86\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e24\u4e2a\u6570\u636e\u5e93<code>ApolloConfigDB<\/code>\u548c<code>ApolloPortalDB<\/code>\u3002<\/p>\n<h2>\u4e8c\u3001\u4e0b\u8f7dapollo-quick-start<\/h2>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/github.com\/apolloconfig\/apollo-quick-start\">https:\/\/github.com\/apolloconfig\/apollo-quick-start<\/a><\/p>\n<ol>\n<li>\n<p>apollo \u670d\u52a1\u7aef\u8fdb\u7a0b\u9700\u8981\u5206\u522b\u4f7f\u75288070, 8080, 8090\u7aef\u53e3\uff0c\u8bf7\u786e\u4fdd\u8fd93\u4e2a\u7aef\u53e3\u5f53\u524d\u6ca1\u6709\u88ab\u4f7f\u7528\u3002<\/p>\n<pre><code class=\"language-shell\">ufw allow 8070\nufw allow 8080\nufw allow 8090<\/code><\/pre>\n<\/li>\n<li>\n<p>\u811a\u672c\u4e2d\u7684 <code>SPRING_PROFILES_ACTIVE<\/code> \u73af\u5883\u53d8\u91cf\u4e2d\u7684 <code>github<\/code> \u662f\u5fc5\u987b\u7684 profile\uff0c<code>database-discovery<\/code> \u6307\u5b9a\u4f7f\u7528\u6570\u636e\u5e93\u670d\u52a1\u53d1\u73b0\uff0c <code>auth<\/code> \u662f portal \u63d0\u4f9b\u7b80\u5355\u8ba4\u8bc1\u7684 profile\uff0c\u4e0d\u9700\u8981\u8ba4\u8bc1\u6216\u8005\u4f7f\u7528\u5176\u5b83\u8ba4\u8bc1\u65b9\u5f0f\u65f6\u53ef\u4ee5\u53bb\u6389<\/p>\n<\/li>\n<\/ol>\n<h2>\u4e09\u3001\u4f7f\u7528 mysql \u6570\u636e\u5e93\uff0c\u81ea\u52a8\u521d\u59cb\u5316<\/h2>\n<p>\u811a\u672c\u73af\u5883\u53d8\u91cf\u4e2d\u7684 <code>your-mysql-server:3306 <\/code>\u9700\u8981\u66ff\u6362\u4e3a\u5b9e\u9645\u7684 mysql \u670d\u52a1\u5668\u5730\u5740\u548c\u7aef\u53e3\uff0c<code>ApolloConfigDB <\/code>\u548c <code>ApolloPortalDB<\/code> \u9700\u8981\u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u6570\u636e\u5e93\u540d\u79f0\uff0c\u811a\u672c\u73af\u5883\u53d8\u91cf\u4e2d\u7684 <code>&quot;apollo-username&quot; <\/code>\u548c <code>&quot;apollo-password&quot;<\/code> \u9700\u8981\u586b\u5199\u5b9e\u9645\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002<\/p>\n<h3>3.1 \u9996\u6b21\u542f\u52a8<\/h3>\n<p>\u9996\u6b21\u542f\u52a8\u4f7f\u7528<code> SPRING_SQL_INIT_MODE=&quot;always&quot; <\/code>\u73af\u5883\u53d8\u91cf\u6765\u8fdb\u884c\u521d\u59cb\u5316<\/p>\n<pre><code class=\"language-bash\">export SPRING_PROFILES_ACTIVE=&quot;github,database-discovery,auth&quot;\n# config db\nexport SPRING_SQL_CONFIG_INIT_MODE=&quot;always&quot;\nexport SPRING_CONFIG_DATASOURCE_URL=&quot;jdbc:mysql:\/\/192.168.31.111:3306\/ApolloConfigDB?useUnicode=true&amp;characterEncoding=UTF8&quot;\nexport SPRING_CONFIG_DATASOURCE_USERNAME=&quot;hep&quot;\nexport SPRING_CONFIG_DATASOURCE_PASSWORD=&quot;123456&quot;\n# portal db\nexport SPRING_SQL_PORTAL_INIT_MODE=&quot;always&quot;\nexport SPRING_PORTAL_DATASOURCE_URL=&quot;jdbc:mysql:\/\/192.168.31.111:3306\/ApolloPortalDB?useUnicode=true&amp;characterEncoding=UTF8&quot;\nexport SPRING_PORTAL_DATASOURCE_USERNAME=&quot;hep&quot;\nexport SPRING_PORTAL_DATASOURCE_PASSWORD=&quot;123456&quot;\njava -jar apollo-all-in-one.jar<\/code><\/pre>\n<h3>3.2 \u540e\u7eed\u542f\u52a8<\/h3>\n<p>\u540e\u7eed\u542f\u52a8\u53bb\u6389 <code>SPRING_SQL_CONFIG_INIT_MODE <\/code>\u548c <code>SPRING_SQL_PORTAL_INIT_MODE <\/code>\u73af\u5883\u53d8\u91cf\u6765\u907f\u514d\u91cd\u590d\u521d\u59cb\u5316<\/p>\n<pre><code class=\"language-bash\">export SPRING_PROFILES_ACTIVE=&quot;github,database-discovery,auth&quot;\n# config db\nunset SPRING_SQL_CONFIG_INIT_MODE\nexport SPRING_CONFIG_DATASOURCE_URL=&quot;jdbc:mysql:\/\/192.168.31.111:3306\/ApolloConfigDB?useUnicode=true&amp;characterEncoding=UTF8&quot;\nexport SPRING_CONFIG_DATASOURCE_USERNAME=&quot;hep&quot;\nexport SPRING_CONFIG_DATASOURCE_PASSWORD=&quot;123456&quot;\n# portal db\nunset SPRING_SQL_PORTAL_INIT_MODE\nexport SPRING_PORTAL_DATASOURCE_URL=&quot;jdbc:mysql:\/\/192.168.31.111:3306\/ApolloPortalDB?useUnicode=true&amp;characterEncoding=UTF8&quot;\nexport SPRING_PORTAL_DATASOURCE_USERNAME=&quot;hep&quot;\nexport SPRING_PORTAL_DATASOURCE_PASSWORD=&quot;123456&quot;\n\n#\u4f60\u53ef\u80fd\u5e76\u4e0d\u60f3\u770b\u540e\u53f0\u8f93\u51fa\u7684\u4ee3\u7801\uff0c\u4e5f\u4e0d\u60f3\u6ca1\u6cd5\u6572\u5176\u4ed6\u7684\u547d\u4ee4\u884c\u4e86\uff0c\u4e0b\u9762\u4e00\u6761\u547d\u4ee4\u8ba9Apollo\u540e\u53f0\u8fd0\u884c\nnohup java -jar \/usr\/software\/apollo-quick-start-master\/apollo-all-in-one.jar &gt; \/usr\/software\/apollo-quick-start-master\/apollo.log 2&gt;&amp;1 &amp;<\/code><\/pre>\n<p>\u5e76\u4e14\uff0c\u6211\u628a\u4e0a\u9762\u7684\u5185\u5bb9\u5199\u5165\u4e86\u81ea\u542f\u52a8\u6587\u4ef6\/root\/.bashrc\u7684\u6700\u540e\u9762\uff0c\u8fd9\u6837\u5f00\u673a\u5c31\u53ef\u4ee5\u81ea\u542f\u52a8\u8fd9\u6761\u547d\u4ee4\uff0c\u8fd9\u6837Apollo\u5f00\u673a\u5c31\u81ea\u52a8\u8fd0\u884c\u4e86\uff0c\u518d\u4e5f\u4e0d\u7528\u6211\u4eec\u8fdb\u5165\u5230\u7279\u5b9a\u76ee\u5f55\uff0c\u8fd8\u8981\u6267\u884cjava -jar\u7684\u547d\u4ee4\u4e86\u3002<\/p>\n<pre><code class=\"language-shell\">#\u540e\u53f0\u8fd0\u884cApollo\u547d\u4ee4\nnohup java -jar \/usr\/software\/apollo-quick-start-master\/apollo-all-in-one.jar &gt; \/usr\/software\/apollo-quick-start-master\/apollo.log 2&gt;&amp;1 &amp;<\/code><\/pre>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/12\/03\/Apollo.jpg\" alt=\"Apollo\" \/><\/p>\n<h2>\u56db\u3001\u4f7f\u7528Apollo\u914d\u7f6e\u4e2d\u5fc3<\/h2>\n<h3>4.1 \u521d\u59cb\u5316\u914d\u7f6e<\/h3>\n<p>\u6211\u4eec\u628a\u963f\u6ce2\u7f57\u5b89\u88c5\u5230\u4e86\u4e00\u53f0Ubuntu24.04\u7684\u673a\u5668\u4e0a\u4e86\uff0c\u5176IP\u5730\u5740\u4e3a<code>192.168.31.111<\/code>\uff0c\u6253\u5f00<code>http:\/\/192.168.31.111:8070<\/code>\uff0c\u8f93\u5165\u7528\u6237\u540dapollo\u5bc6\u7801admin\u540e\u767b\u5f55\u3002<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/12\/03\/Screenshot-2024-11-11-190708.png\" alt=\"Screenshot 2024-11-11 190708\" \/><\/p>\n<h2>\u4e94\u3001\u5206\u5e03\u5f0f\u90e8\u7f72<\/h2>\n<h3>5.1 \u67b6\u6784\u914d\u7f6e\u4e0e\u8bbe\u8ba1<\/h3>\n<p>\u6211\u4eec\u51c6\u5907\u4e866\u53f0\u673a\u5668\uff0c\u6765\u90e8\u7f72Apollo\u914d\u7f6e\u4e2d\u5fc3\uff0c\u5f00\u53d1\u73af\u5883\u914d\u7f6e\u4e00\u53f0\uff0c\u6d4b\u8bd5\u73af\u5883\u914d\u7f6e\u4e24\u53f0\uff0c\u751f\u4ea7\u73af\u5883\u914d\u7f6e\u4e24\u53f0\uff0cportal\u914d\u7f6e\u4e00\u53f0\uff0c\u4e00\u5171\u516d\u53f0\uff0c\u5f53\u7136\u8fd9\u4e9b\u5e76\u6ca1\u6709\u628amysql\u6570\u636e\u5e93\u7b97\u4f5c\u5176\u4e2d\uff0c\u6570\u636e\u5e93\u662f\u4e4b\u524d\u5c31\u642d\u5efa\u597d\u7684\uff0c\u5f00\u53d1\u3001\u6d4b\u8bd5\u3001\u751f\u4ea7\u90fd\u6709\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u73af\u5883<\/th>\n<th>\u4e3b\u673a<\/th>\n<th>IP<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u5f00\u53d1<\/td>\n<td>hep-apollo-server-admin-config-dev<\/td>\n<td>192.168.31.51<\/td>\n<\/tr>\n<tr>\n<td>\u6d4b\u8bd5<\/td>\n<td>hep-apollo-server-admin-config-test-01<\/td>\n<td>192.168.31.52<\/td>\n<\/tr>\n<tr>\n<td>\u6d4b\u8bd5<\/td>\n<td>hep-apollo-server-admin-config-test-02<\/td>\n<td>192.168.31.53<\/td>\n<\/tr>\n<tr>\n<td>\u751f\u4ea7<\/td>\n<td>hep-apollo-server-admin-config-prd-01<\/td>\n<td>192.168.31.54<\/td>\n<\/tr>\n<tr>\n<td>\u751f\u4ea7<\/td>\n<td>hep-apollo-server-admin-config-prd-02<\/td>\n<td>192.168.31.55<\/td>\n<\/tr>\n<tr>\n<td>\u751f\u4ea7<\/td>\n<td>hep-apollo-server-portal-prd<\/td>\n<td>192.168.31.56<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u603b\u4f53\u7684\u67b6\u6784\u56fe\u5982\u4e0b\u3002<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/12\/03\/Screenshot-2024-11-26-195507.png\" alt=\"Screenshot 2024-11-26 195507\" \/><\/p>\n<h3>5.2 \u6570\u636e\u5e93\u811a\u672c\u4e0eApollo\u5b89\u88c5\u5305\u4e0b\u8f7d<\/h3>\n<p>Apollo\u76ee\u524d\u652f\u6301\u4ee5\u4e0b\u73af\u5883\uff1a<\/p>\n<ul>\n<li>DEV\u5f00\u53d1\u73af\u5883<\/li>\n<li>FAT\u6d4b\u8bd5\u73af\u5883\uff0c\u76f8\u5f53\u4e8ealpha\u73af\u5883(\u529f\u80fd\u6d4b\u8bd5)<\/li>\n<li>UAT\u96c6\u6210\u73af\u5883\uff0c\u76f8\u5f53\u4e8ebeta\u73af\u5883(\u56de\u5f52\u6d4b\u8bd5)<\/li>\n<li>PRO\u751f\u4ea7\u73af\u5883<\/li>\n<\/ul>\n<p>Apollo\u670d\u52a1\u7aef\u5171\u9700\u8981\u4e24\u4e2a\u6570\u636e\u5e93\uff1a<code>ApolloPortalDB<\/code>\u548c<code>ApolloConfigDB<\/code>\uff0c<code>ApolloPortalDB<\/code>\u53ea\u9700\u8981\u5728\u751f\u4ea7\u73af\u5883\u90e8\u7f72\u4e00\u4e2a\u5373\u53ef\uff0c\u800c<code>ApolloConfigDB<\/code>\u9700\u8981\u5728\u6bcf\u4e2a\u73af\u5883\u90e8\u7f72\u4e00\u5957\uff0c\u5982fat\u3001uat\u548cpro\u5206\u522b\u90e8\u7f723\u5957<code>ApolloConfigDB<\/code>\u3002\u6211\u4eec\u8fd9\u91cc\u4f7f\u7528\u7684\u662f\u5f00\u53d1dev\u3001\u6d4b\u8bd5test\u3001\u751f\u4ea7prd\u4e00\u5171\u4e09\u4e2a\u73af\u5883\uff0c\u5404\u914d\u7f6e\u4e86\u4e00\u5957<code>ApolloConfigDB<\/code>\uff0c\u53ea\u914d\u7f6e\u4e86\u751f\u4ea7\u4e00\u5957<code>ApolloPortalDB<\/code>\u3002<\/p>\n<p>\u901a\u8fc7\u5404\u79cdMySQL\u5ba2\u6237\u7aef\u5bfc\u5165<a href=\"https:\/\/github.com\/apolloconfig\/apollo\/blob\/master\/scripts\/sql\/profiles\/mysql-default\/apolloportaldb.sql\">apolloportaldb.sql<\/a>\u5373\u53ef\u3002<\/p>\n<pre><code class=\"language-shell\">#apolloportaldb.sql\u4e0b\u8f7d\u5730\u5740\uff1a\nhttps:\/\/github.com\/apolloconfig\/apollo\/blob\/master\/scripts\/sql\/profiles\/mysql-default\/apolloportaldb.sql\n#apolloconfigdb.sql\u4e0b\u8f7d\u5730\u5740\uff1a\nhttps:\/\/github.com\/apolloconfig\/apollo\/blob\/master\/scripts\/sql\/profiles\/mysql-default\/apolloconfigdb.sql<\/code><\/pre>\n<p>\u83b7\u53d6<code>apollo-configservice<\/code>\u3001<code>apollo-adminservice<\/code>\u3001<code>apollo-portal<\/code>\u5b89\u88c5\u5305\uff0c\u4ece<a href=\"https:\/\/github.com\/apolloconfig\/apollo\/releases\">GitHub Release<\/a>\u9875\u9762\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684<code>apollo-configservice-x.x.x-github.zip<\/code>\u3001<code>apollo-adminservice-x.x.x-github.zip<\/code>\u548c<code>apollo-portal-x.x.x-github.zip<\/code>\u5373\u53ef\u3002<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/12\/03\/apollo.png\" alt=\"apollo\u5b89\u88c5\u5305\" \/><\/p>\n<h3>5.3 \u5f00\u53d1\u73af\u5883<\/h3>\n<p>\u628a\u4e0b\u8f7d\u597d\u7684<code>apollo-configservice-2.3.0-github.zip<\/code>\u3001<code>apollo-adminservice-2.3.0-github.zip<\/code>\u4e24\u4e2a\u6587\u4ef6\u4e0a\u4f20\u5230<code>hep-apollo-server-admin-config-dev(192.168.31.51)<\/code>\u8fd9\u53f0\u673a\u5668\uff0c\u5e76\u89e3\u538b\u7f29\uff0c\u5728cofig\u548cadmin\u4e24\u4e2a\u6587\u4ef6\u5939\u4e0b\uff0c\u5206\u522b\u6709config\u548cscripts\u4e24\u4e2a\u6587\u4ef6\u5939\u3002<\/p>\n<p><code>config<\/code>\u76ee\u5f55\u4e0b\u7684<code>application-github.properties<\/code>\u6587\u4ef6\u4e2d\u6709mysql\u6570\u636e\u5e93\u7684\u914d\u7f6e\u9879\uff0c\u628a\u6570\u636e\u5e93\u5730\u5740\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\u6539\u6210\u5bf9\u5e94\u7684\u5f00\u53d1\u73af\u5883\u7684\uff0c\u6ce8\u610f\u7528\u6237\u540d\u548c\u5bc6\u7801\u540e\u9762\u4e0d\u8981\u6709\u7a7a\u683c\u3002<\/p>\n<pre><code class=\"language-properties\">spring.datasource.url = jdbc:mysql:\/\/192.168.31.79:3306\/ApolloConfigDB?characterEncoding=utf8\nspring.datasource.username = hepadmin\nspring.datasource.password = admin123<\/code><\/pre>\n<p>scripts\u4e0b\u6709startup.sh\u548cshutdown.sh\u4e24\u4e2a\u6587\u4ef6\uff0c\u5206\u522b\u5bf9\u5e94\u7740\u542f\u52a8\u548c\u5173\u95ed\u7684\u811a\u672c\u3002\u4f7f\u7528\u4e0b\u9762\u547d\u4ee4\u542f\u52a8admin\u548cconfig\u670d\u52a1\uff0c\u5f53\u7136\u4e5f\u8981\u653e\u884c\u4e00\u4e0b\u7aef\u53e3\u53f7\uff0c\u8fd9\u4e09\u4e2a\u7aef\u53e3\u53f7\u662f\u6709\u7528\u4e8e\u901a\u4fe1\u7684\u3002<\/p>\n<pre><code class=\"language-shell\">#\u5f00\u653e\u7aef\u53e3\nufw  allow  8070\nufw  allow  8080\nufw  allow  8090\n\ncd apollo-adminservice-2.3.0\/scripts\nnohup .\/startup.sh &amp;\n\ncd apollo-configservice-2.3.0\/scripts\nnohup .\/startup.sh &amp;<\/code><\/pre>\n<h3>5.4 \u6d4b\u8bd5\u73af\u5883<\/h3>\n<p>\u628a\u4e0b\u8f7d\u597d\u7684<code>apollo-configservice-2.3.0-github.zip<\/code>\u3001<code>apollo-adminservice-2.3.0-github.zip<\/code>\u4e24\u4e2a\u6587\u4ef6\u90fd\u4e0a\u4f20\u5230<code>hep-apollo-server-admin-config-test-01(192.168.31.52)<\/code>\u548c<code>hep-apollo-server-admin-config-test-02(192.168.31.53)<\/code>\u8fd9\u4e24\u53f0\u673a\u5668\uff0c\u5e76\u89e3\u538b\u7f29\uff0c\u5728cofig\u548cadmin\u4e24\u4e2a\u6587\u4ef6\u5939\u4e0b\uff0c\u5206\u522b\u6709config\u548cscripts\u4e24\u4e2a\u6587\u4ef6\u5939\u3002<\/p>\n<p><code>config<\/code>\u76ee\u5f55\u4e0b\u7684<code>application-github.properties<\/code>\u6587\u4ef6\u6709mysql\u6570\u636e\u5e93\u7684\u914d\u7f6e\uff0c\u4fee\u6539\u6210\u6d4b\u8bd5\u73af\u5883\u7684\u6570\u636e\u5e93<code>ApolloConfigDB<\/code>\u7684\u3002\u4e24\u53f0\u673a\u5668\u90fd\u8981\u505a\u3002<\/p>\n<pre><code class=\"language-properties\">spring.datasource.url = jdbc:mysql:\/\/192.168.31.4:6446\/ApolloConfigDB?characterEncoding=utf8\nspring.datasource.username = hepadmin\nspring.datasource.password = admin123<\/code><\/pre>\n<p>\u7528Navicat\u8fde\u63a5\u5230\u6d4b\u8bd5\u73af\u5883\u6570\u636e\u5e93<code>ApolloConfigDB<\/code>\uff0c\u628a<code>ServerConfig<\/code>\u8868\u4e2d\u7684<code>eureka.service.url<\/code>\u5b57\u6bb5\u4fee\u6539\u6210<code>http:\/\/192.168.31.52:8080\/eureka\/,http:\/\/192.168.31.53:8080\/eureka\/<\/code>\u3002<code>eureka.service.url<\/code>\u5b57\u6bb5\u7528\u4e8e\u5b58\u50a8 Eureka \u670d\u52a1\u6ce8\u518c\u4e2d\u5fc3\u7684\u5730\u5740\uff0c\u8fd9\u610f\u5473\u7740 Apollo \u914d\u7f6e\u4e2d\u5fc3\u81ea\u8eab\u4f5c\u4e3a\u4e00\u4e2a\u5fae\u670d\u52a1\uff0c\u53ef\u80fd\u4f1a\u5c06\u81ea\u5df1\u7684\u670d\u52a1\u4fe1\u606f\u6ce8\u518c\u5230 Eureka \u670d\u52a1\u6ce8\u518c\u4e2d\u5fc3\uff0c\u4ee5\u4fbf\u5176\u4ed6\u670d\u52a1(\u5982 Apollo \u5ba2\u6237\u7aef)\u80fd\u591f\u901a\u8fc7 Eureka \u53d1\u73b0 Apollo \u914d\u7f6e\u4e2d\u5fc3\u7684\u4f4d\u7f6e\uff0c\u4ece\u800c\u83b7\u53d6\u914d\u7f6e\u4fe1\u606f\u3002<\/p>\n<p>scripts\u4e0b\u6709startup.sh\u548cshutdown.sh\u4e24\u4e2a\u6587\u4ef6\uff0c\u5206\u522b\u5bf9\u5e94\u7740\u542f\u52a8\u548c\u5173\u95ed\u7684\u811a\u672c\u3002\u4f7f\u7528\u4e0b\u9762\u547d\u4ee4\u542f\u52a8admin\u548cconfig\u670d\u52a1\uff0c\u4e24\u53f0\u673a\u5668\u90fd\u8981\u505a\u3002<\/p>\n<pre><code class=\"language-shell\">#\u5f00\u653e\u7aef\u53e3\nufw  allow  8070\nufw  allow  8080\nufw  allow  8090\n\ncd apollo-configservice-2.3.0\/scripts\nnohup .\/startup.sh &amp;\n\ncd apollo-adminservice-2.3.0\/scripts\nnohup .\/startup.sh &amp;<\/code><\/pre>\n<h3>5.5 \u751f\u4ea7\u73af\u5883<\/h3>\n<p>\u628a\u4e0b\u8f7d\u597d\u7684<code>apollo-configservice-2.3.0-github.zip<\/code>\u3001<code>apollo-adminservice-2.3.0-github.zip<\/code>\u4e24\u4e2a\u6587\u4ef6\u4e0a\u4f20\u5230<code>hep-apollo-server-admin-config-prd-01(192.168.31.54)<\/code>\u548c<code>hep-apollo-server-admin-config-prd-02(192.168.31.55)<\/code>\u8fd9\u4e24\u53f0\u673a\u5668\uff0c\u5e76\u89e3\u538b\u7f29\uff0c\u5728cofig\u548cadmin\u4e24\u4e2a\u6587\u4ef6\u5939\u4e0b\uff0c\u5206\u522b\u6709config\u548cscripts\u4e24\u4e2a\u6587\u4ef6\u5939\u3002<\/p>\n<p><code>config<\/code>\u76ee\u5f55\u4e0b\u7684<code>application-github.properties<\/code>\u6587\u4ef6\u6709mysql\u6570\u636e\u5e93\u7684\u914d\u7f6e\uff0c\u4fee\u6539\u6210\u751f\u4ea7\u73af\u5883\u7684\u6570\u636e\u5e93<code>ApolloConfigDB<\/code>\u7684\u3002\u4e24\u53f0\u673a\u5668\u90fd\u8981\u505a\u3002<\/p>\n<pre><code class=\"language-properties\">spring.datasource.url = jdbc:mysql:\/\/192.168.31.14:6446\/ApolloConfigDB?characterEncoding=utf8\nspring.datasource.username = hepadmin\nspring.datasource.password = admin123<\/code><\/pre>\n<p>\u7528Navicat\u8fde\u63a5\u5230\u751f\u4ea7\u73af\u5883\u6570\u636e\u5e93<code>ApolloConfigDB<\/code>\uff0c\u628a<code>ServerConfig<\/code>\u8868\u4e2d\u7684<code>eureka.service.url<\/code>\u5b57\u6bb5\u4fee\u6539\u6210<code>http:\/\/192.168.31.54:8080\/eureka\/,http:\/\/192.168.31.55:8080\/eureka\/<\/code>\u3002<code>eureka.service.url<\/code>\u5b57\u6bb5\u7528\u4e8e\u5b58\u50a8 Eureka \u670d\u52a1\u6ce8\u518c\u4e2d\u5fc3\u7684\u5730\u5740\uff0c\u8fd9\u610f\u5473\u7740 Apollo \u914d\u7f6e\u4e2d\u5fc3\u81ea\u8eab\u4f5c\u4e3a\u4e00\u4e2a\u5fae\u670d\u52a1\uff0c\u53ef\u80fd\u4f1a\u5c06\u81ea\u5df1\u7684\u670d\u52a1\u4fe1\u606f\u6ce8\u518c\u5230 Eureka \u670d\u52a1\u6ce8\u518c\u4e2d\u5fc3\uff0c\u4ee5\u4fbf\u5176\u4ed6\u670d\u52a1(\u5982 Apollo \u5ba2\u6237\u7aef)\u80fd\u591f\u901a\u8fc7 Eureka \u53d1\u73b0 Apollo \u914d\u7f6e\u4e2d\u5fc3\u7684\u4f4d\u7f6e\uff0c\u4ece\u800c\u83b7\u53d6\u914d\u7f6e\u4fe1\u606f\u3002<\/p>\n<p>scripts\u4e0b\u6709startup.sh\u548cshutdown.sh\u4e24\u4e2a\u6587\u4ef6\uff0c\u5206\u522b\u5bf9\u5e94\u7740\u542f\u52a8\u548c\u5173\u95ed\u7684\u811a\u672c\u3002\u4f7f\u7528\u4e0b\u9762\u547d\u4ee4\u542f\u52a8admin\u548cconfig\u670d\u52a1\uff0c\u4e24\u53f0\u673a\u5668\u90fd\u8981\u505a\u3002<\/p>\n<pre><code class=\"language-shell\">#\u5f00\u653e\u7aef\u53e3\nufw  allow  8070\nufw  allow  8080\nufw  allow  8090\n\ncd apollo-configservice-2.3.0\/scripts\nnohup .\/startup.sh &amp;\n\ncd apollo-adminservice-2.3.0\/scripts\nnohup .\/startup.sh &amp;<\/code><\/pre>\n<p>\u628a\u4e0b\u8f7d\u597d\u7684<code>apollo-portal-2.3.0-github.zip<\/code>\u6587\u4ef6\u4e0a\u4f20\u5230<code>hep-apollo-server-portal-prd(192.168.31.56)<\/code>\uff0c\u5e76\u89e3\u538b\u7f29\uff0c\u5728cofig\u548cadmin\u4e24\u4e2a\u6587\u4ef6\u5939\u4e0b\uff0c\u5206\u522b\u6709config\u548cscripts\u4e24\u4e2a\u6587\u4ef6\u5939\u3002<\/p>\n<p><code>config<\/code>\u76ee\u5f55\u4e0b\u7684<code>application-github.properties<\/code>\u6587\u4ef6\u6709mysql\u6570\u636e\u5e93\u7684\u914d\u7f6e\uff0c\u4fee\u6539\u6210\u751f\u4ea7\u73af\u5883\u7684\u6570\u636e\u5e93<code>ApolloPortalDB<\/code>\u7684\u3002<\/p>\n<pre><code class=\"language-properties\">spring.datasource.url = jdbc:mysql:\/\/192.168.31.14:6446\/ApolloPortalDB?characterEncoding=utf8\nspring.datasource.username = hepadmin\nspring.datasource.password = admin123<\/code><\/pre>\n<p>\u4fee\u6539apollo-env.properties\u914d\u7f6e\u6587\u4ef6\uff0c\u4fdd\u7559\u4e86\u5f00\u53d1\u3001\u6d4b\u8bd5\u3001\u751f\u4ea7\u4e09\u4e2a\u73af\u5883\uff0c\u5e76\u4e14\u5bf9\u5e94meta\u5730\u5740\u5c31\u662f\u4e0a\u9762\u914d\u7f6e\u7684Admin\u670d\u52a1\u5730\u5740\uff0c\u591a\u4e2a\u5730\u5740\u4e4b\u95f4\u7528\u82f1\u6587\u9017\u53f7\u9694\u5f00\u3002<\/p>\n<pre><code class=\"language-properties\">dev.meta=http:\/\/192.168.31.51:8080\ntest.meta=http:\/\/192.168.31.52:8080,http:\/\/192.168.31.53:8080\n#uat.meta=http:\/\/fill-in-uat-meta-server:8080\n#lpt.meta=${lpt_meta}\nprd.meta=http:\/\/192.168.31.54:8080,http:\/\/192.168.31.55:8080<\/code><\/pre>\n<p><code>Apollo Portal<\/code>\u9700\u8981\u5728\u4e0d\u540c\u7684\u73af\u5883\u8bbf\u95ee\u4e0d\u540c\u7684<code>meta service(apollo-configservice)<\/code>\u5730\u5740\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u5728\u914d\u7f6e\u4e2d\u63d0\u4f9b\u8fd9\u4e9b\u4fe1\u606f\u3002\u4e3a\u4e86\u5b9e\u73b0meta service\u7684\u9ad8\u53ef\u7528\uff0c\u63a8\u8350\u901a\u8fc7<code>SLB(Software Load Balancer)<\/code>\u505a\u52a8\u6001\u8d1f\u8f7d\u5747\u8861\u3002meta service\u5730\u5740\u4e5f\u53ef\u4ee5\u586b\u5165IP\uff0c0.11.0\u7248\u672c\u4e4b\u524d\u53ea\u652f\u6301\u586b\u5165\u4e00\u4e2aIP\u3002\u4ece0.11.0\u7248\u672c\u5f00\u59cb\u652f\u6301\u586b\u5165\u4ee5\u9017\u53f7\u5206\u9694\u7684\u591a\u4e2a\u5730\u5740\uff0c\u5982<code>http:\/\/192.168.31.52:8080,http:\/\/192.168.31.53:8080<\/code>\u3002<\/p>\n<p>\u7528Navicat\u8fde\u63a5\u5230\u751f\u4ea7\u73af\u5883\u6570\u636e\u5e93<code>ApolloPortalDB<\/code>\uff0c\u628a<code>ServerConfig<\/code>\u8868\u4e2d\u7684<code>apollo.portal.meta.servers<\/code>\u4fee\u6539\u6210<\/p>\n<pre><code class=\"language-json\">{\n    &quot;DEV&quot;:&quot;http:\/\/192.168.31.51:8080&quot;,\n    &quot;TEST&quot;:&quot;http:\/\/192.168.31.52:8080,http:\/\/192.168.31.53:8080&quot;,\n    &quot;PRD&quot;:&quot;http:\/\/192.168.31.54:8080,http:\/\/192.168.31.55:8080&quot;\n}<\/code><\/pre>\n<p>\u628a<code>apollo.portal.envs<\/code>\u4fee\u6539\u6210<code>DEV,TEST,PRD<\/code>\uff0c\u628a<code>organizations<\/code>\u4fee\u6539\u6210<code>[{&quot;orgId&quot;:&quot;hep01&quot;,&quot;orgName&quot;:&quot;\u6caa\u5c13\u6d66\u5f00\u53d1\u4e00\u90e8&quot;},{&quot;orgId&quot;:&quot;hep02&quot;,&quot;orgName&quot;:&quot;\u6caa\u5c13\u6d66\u5f00\u53d1\u4e8c\u90e8&quot;}]<\/code>\uff0c\u628a<code>configView.memberOnly.envs<\/code>\u4fee\u6539\u6210<code>DEV,TEST,PRD<\/code>\u3002<\/p>\n<p>\u6700\u540e\u542f\u52a8portal<\/p>\n<pre><code class=\"language-shell\">cd apollo-portal-2.3.0\/scripts\nnohup .\/startup.sh &amp;<\/code><\/pre>\n<p>\u5f53\u7136\u540e\u9762\u90a3\u51e0\u9879\u4e5f\u53ef\u4ee5\u542f\u52a8portal\u4e4b\u540e\uff0c\u901a\u8fc7\u64cd\u4f5c\u754c\u9762\u8fdb\u884c\u4fee\u6539\uff0c\u90fd\u53ef\u3002<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/12\/03\/Screenshot-2024-12-02-131951.png\" alt=\"Screenshot 2024-12-02 131951\" \/><\/p>\n<h2>\u516d\u3001\u725b\u5200\u5c0f\u8bd5<\/h2>\n<p>\u60f3\u5fc5\u641e\u5fae\u670d\u52a1\u7684\u5c0f\u4f19\u4f34\u90fd\u770b\u817b\u4e86\u7f51\u4e0a\u7684Apollo\u914d\u7f6e\u4e2d\u5fc3\u7684\u7b2c\u4e00\u4e2a<code>ConfigService.getConfig<\/code>\u6837\u4f8b\uff0c\u8fd9\u79cd\u6f14\u793a\u6027\u7684Demo\u786e\u5b9e\u8ba9\u4eba\u5f88\u53cd\u611f\uff0c\u9664\u4e86\u6f14\u793a\u6ca1\u5565\u7528\uff0c\u6211\u4eec\u4eca\u5929\u5c31\u6765\u70b9\u4e0d\u4e00\u6837\u7684\u3002\u524d\u9762\u7684\u6559\u7a0b\u91cc\u6709\u90e8\u7f72Eureka\u5230\u4e09\u53f0\u670d\u52a1\u5668\u4e0a\uff0c\u4ece\u800c\u5f62\u6210\u4e86\u4e00\u4e2a\u6ce8\u518c\u4e2d\u5fc3\u7684\u96c6\u7fa4\uff0c\u6d4b\u8bd5\u73af\u5883\u548c\u751f\u4ea7\u73af\u5883\u5404\u6709\u4e09\u53f0\u673a\u5668\uff0c\u4e0d\u719f\u6089\u7684\u53ef\u4ee5\u53bb\u7784\u4e00\u773c\u524d\u9762\u7684\u6559\u7a0b\u54c8\uff0c\u6211\u4eec\u6bcf\u6b21\u6253\u4e2ajar\u5305\u653e\u5230\u670d\u52a1\u5668\u4e0a\uff0c\u6bcf\u53f0\u673a\u5668\u4e0aEureka\u7684\u6ce8\u518c\u5730\u5740\u90fd\u4e0d\u4e00\u6837\uff0c\u800c\u6bcf\u6b21\u90fd\u624b\u52a8\u53bb\u6539\u7136\u540e\u518d\u6253\u5305\u6709\u70b9\u7e41\u7410\uff0c\u6211\u4eec\u4eca\u5929\u5c31\u7528\u4e00\u4e2aApollo\u8fdb\u884c\u8fd9\u4e2a<code>eureka.client.serviceUrl.defaultZone<\/code>\u7684\u914d\u7f6e\uff0c\u5e76\u4e14\u5b9e\u73b0\u5b9e\u65f6\u751f\u6548\uff0c\u76f8\u6bd4\u8fd9\u4e2a\u597d\u73a9\u7684\u529f\u80fd\u5f88\u591a\u5c0f\u4f19\u4f34\u5728\u5fc3\u91cc\u4e50\u5f00\u4e86\u82b1\uff0c\u786e\u5b9e\u5f88\u5b9e\u7528\u7684\u54c8\u3002<\/p>\n<p>\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u5e94\u7528\uff0cid\u4e3a<code>hep-eureka-server<\/code>\uff0c\u5e76\u4e14\u4e0a\u9762\u6211\u4eec\u4e5f\u914d\u7f6e\u597d\u4e86\u5f00\u53d1\u3001\u6d4b\u8bd5\u3001\u751f\u4ea7\u7684\u73af\u5883\uff0c\u56e0\u4e3a\u5f00\u53d1\u73af\u5883\u5c31\u7ed9\u4e86\u4e00\u53f0Eureka\uff0c\u6240\u4ee5\u5c31\u4e0d\u5efa\u96c6\u7fa4\u4e86\uff0c\u6d4b\u8bd5\u548c\u751f\u4ea7\u5404\u6709\u4e09\u53f0\u673a\u5668\uff0c\u6240\u4ee5\u521b\u5efa\u4e86\u4e09\u4e2a\u96c6\u7fa4\uff0c\u5206\u522b\u53d6\u540d01\u300102\u300103\uff0c\u5e76\u4e14\u589e\u52a0\u4e86\u4e00\u4e2a\u914d\u7f6e\u9879<code>eureka.client.serviceUrl.defaultZone<\/code>\u3002<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/12\/03\/Screenshot-2024-12-03-171403.png\" alt=\"Screenshot 2024-12-03 171403\" \/><\/p>\n<p>\u9996\u5148\u5728<code>eurekaServer<\/code>\u7684\u9879\u76ee\u4e2d\u589e\u52a0Apollo\u5ba2\u6237\u7aef\u7684\u4f9d\u8d56\u3002<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\n    &lt;groupId&gt;com.ctrip.framework.apollo&lt;\/groupId&gt;\n    &lt;artifactId&gt;apollo-client&lt;\/artifactId&gt;\n    &lt;version&gt;2.1.0&lt;\/version&gt;\n&lt;\/dependency&gt;\n&lt;dependency&gt;\n    &lt;groupId&gt;javax.annotation&lt;\/groupId&gt;\n    &lt;artifactId&gt;javax.annotation-api&lt;\/artifactId&gt;\n    &lt;version&gt;1.3.2&lt;\/version&gt;\n&lt;\/dependency&gt;<\/code><\/pre>\n<p><code>Spring Boot<\/code> \u542f\u52a8\u7c7b\uff0c\u6dfb\u52a0 <code>@EnableApolloConfig<\/code><\/p>\n<pre><code class=\"language-java\">@SpringBootApplication\n@EnableEurekaServer\n@EnableApolloConfig\npublic class EurekaServerApplication {\n\n    public static void main(String[] args) {\n        SpringApplication.run(EurekaServerApplication.class, args);\n    }\n\n}<\/code><\/pre>\n<p>\u589e\u52a0\u4e00\u4e2a<code>EurekaConfigFromApollo<\/code>\u914d\u7f6e\u9879\uff0c\u8fd9\u4e2a\u662f\u53ef\u4ee5\u52a8\u6001\u76d1\u6d4b\u5230Eureka\u53d8\u5316\uff0c\u7acb\u5373\u751f\u6548\uff0c\u4e0d\u7528\u91cd\u542fEureka\u673a\u5668\u3002<\/p>\n<pre><code class=\"language-java\">package cc.huerpu.eurekaserver.security;\nimport com.ctrip.framework.apollo.Config;\nimport com.ctrip.framework.apollo.model.ConfigChange;\nimport com.ctrip.framework.apollo.model.ConfigChangeEvent;\nimport com.ctrip.framework.apollo.spring.annotation.ApolloConfig;\nimport com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.context.annotation.Configuration;\nimport org.springframework.util.StringUtils;\nimport javax.annotation.PostConstruct;\nimport java.util.HashMap;\nimport java.util.Map;\n\n@Configuration\npublic class EurekaConfigFromApollo {\n    private static final Logger logger = LoggerFactory.getLogger(EurekaConfigFromApollo.class);\n    @ApolloConfig\n    private Config config;\n    private static final String EUREKA_CLIENT_SERVICE_URL_DEFAULT_ZONE_KEY = &quot;eureka.client.serviceUrl.defaultZone&quot;;\n    @Autowired\n    private org.springframework.cloud.netflix.eureka.EurekaClientConfigBean eurekaClientConfigBean;\n\n    @PostConstruct\n    public void init() {\n        updateEurekaServiceUrl();\n    }\n\n    @ApolloConfigChangeListener\n    private void onChange(ConfigChangeEvent changeEvent) {\n        ConfigChange change = changeEvent.getChange(EUREKA_CLIENT_SERVICE_URL_DEFAULT_ZONE_KEY);\n        if (change!= null) {\n            updateEurekaServiceUrl();\n        }\n    }\n\n    private void updateEurekaServiceUrl() {\n        String eurekaServiceUrl = config.getProperty(EUREKA_CLIENT_SERVICE_URL_DEFAULT_ZONE_KEY, &quot;&quot;);\n        if (!StringUtils.isEmpty(eurekaServiceUrl)) {\n            Map&lt;String, String&gt; defaultZoneUrls = new HashMap&lt;&gt;();\n            defaultZoneUrls.put(&quot;defaultZone&quot;, eurekaServiceUrl);\n            eurekaClientConfigBean.setServiceUrl(defaultZoneUrls);\n            logger.trace(&quot;eurekaServiceUrl:&quot; + eurekaServiceUrl);\n        } else {\n            logger.error(&quot;Failed to get the value of &#039;eureka.client.serviceUrl.defaultZone&#039; from Apollo configuration.&quot;);\n        }\n    }\n}<\/code><\/pre>\n<p>\u5f00\u53d1\u73af\u5883application.yml\u589e\u52a0\u4e0b\u9762\u914d\u7f6e\uff0capp.id\u5c31\u662fApollo\u4e0a\u9762\u521b\u5efa\u7684\u5e94\u7528ID\uff0c\u5168\u5c40\u552f\u4e00\uff0cApollo.meta\u5c31\u662f\u4e0a\u9762\u914d\u7f6e\u7684<code>Apollo Config Service<\/code>\u5bf9\u5e94\u7684\u5730\u5740\uff0c\u6bcf\u4e2a\u73af\u5883\u7684\u90fd\u5bf9\u5e94\u597d\u5373\u53ef\u3002<\/p>\n<pre><code class=\"language-yml\">#\u6ce8\u91ca\u6389eureka.client.serviceUrl.defaultZone\uff0c\u5e76\u589e\u52a0\u4e0b\u9762\u914d\u7f6e\napp:\n  id: hep-eureka-server\napollo:\n  meta: http:\/\/192.168.31.51:8080\n  bootstrap:\n    enabled: true<\/code><\/pre>\n<p>\u6d4b\u8bd5\u73af\u5883application-test.yml<\/p>\n<pre><code class=\"language-yml\">#\u6ce8\u91ca\u6389eureka.client.serviceUrl.defaultZone\uff0c\u5e76\u589e\u52a0\u4e0b\u9762\u914d\u7f6e\napp:\n  id: hep-eureka-server\napollo:\n  meta: http:\/\/192.168.31.52:8080,http:\/\/192.168.31.53:8080\n  bootstrap:\n    enabled: true<\/code><\/pre>\n<p>\u751f\u4ea7\u73af\u5883application-prd.yml<\/p>\n<pre><code class=\"language-yml\">#\u6ce8\u91ca\u6389eureka.client.serviceUrl.defaultZone\uff0c\u5e76\u589e\u52a0\u4e0b\u9762\u914d\u7f6e\napp:\n  id: hep-eureka-server\napollo:\n  meta: http:\/\/192.168.31.54:8080,http:\/\/192.168.31.55:8080\n  bootstrap:\n    enabled: true<\/code><\/pre>\n<p>\u5728\u673a\u5668\u4e0a\u9762\u6211\u4eec\u5199\u4e86\u4e00\u4e2a\u811a\u672c\u8ba9\u5b83\u5f00\u673a\u81ea\u542f\u52a8Eureka\u670d\u52a1\uff0c\u56e0\u4e3a\u6d4b\u8bd5\u73af\u5883\u548c\u751f\u4ea7\u73af\u5883\u914d\u7f6e\u4e86\u96c6\u7fa4\uff0c\u6240\u4ee5\u5728\u811a\u672c\u4e2d\u6307\u5b9a\u4e00\u4e0b<code>export APOLLO_CLUSTER=01<\/code>\u3001<code>export APOLLO_CLUSTER=02<\/code>\u3001<code>export APOLLO_CLUSTER=03<\/code>\u5c5e\u4e8e\u54ea\u4e00\u4e2a\u96c6\u7fa4\u5c31\u884c\u4e86\uff0c\u5c31\u8fd9\u4e48\u7b80\u5355\u3002<\/p>\n<pre><code class=\"language-shell\">vim \/etc\/rc.local\n\n#!\/bin\/bash\nexport APOLLO_CLUSTER=01\nnohup java -jar \/usr\/software\/eurekaServer-auth-prd-03.jar &gt; \/usr\/software\/log.log 2&gt;&amp;1 &amp;\nexit 0\n\nchmod +x \/etc\/rc.local<\/code><\/pre>\n<p>\u542f\u52a8\u4e4b\u540e\u53ef\u4ee5\u770b\u5230\u6bcf\u4e2a\u96c6\u7fa4\u5bf9\u5e94\u7684\u673a\u5668\uff0c\u6bcf\u4e2a\u673a\u5668\u7684\u914d\u7f6e\u9879\u4e5f\u4e0d\u540c\uff0c\u662f\u76f8\u4e92\u6ce8\u518c\u7684\u914d\u7f6e\u9879<\/p>\n<ul>\n<li>\n<p><code>192.168.31.34<\/code>\u5411<code>192.168.31.35<\/code>\u3001<code>192.168.31.36<\/code> \u6ce8\u518c<\/p>\n<\/li>\n<li>\n<p><code>192.168.31.35<\/code>\u5411<code>192.168.31.34<\/code>\u3001<code>192.168.31.36<\/code> \u6ce8\u518c<\/p>\n<\/li>\n<li>\n<p><code>192.168.31.36<\/code>\u5411<code>192.168.31.34<\/code>\u3001<code>192.168.31.35<\/code> \u6ce8\u518c<\/p>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/12\/03\/Apollob9c3861730a539ae.jpg\" alt=\"Apollo\u6d4b\u8bd5\u73af\u5883\" \/><\/p>\n<p>\u751f\u4ea7\u73af\u5883\u4e5f\u662f\u76f8\u4e92\u6ce8\u518c\u7684\u914d\u7f6e\u9879<\/p>\n<ul>\n<li>\n<p><code>192.168.31.31<\/code>\u5411<code>192.168.31.32<\/code>\u3001<code>192.168.31.33<\/code> \u6ce8\u518c<\/p>\n<\/li>\n<li>\n<p><code>192.168.31.32<\/code>\u5411<code>192.168.31.31<\/code>\u3001<code>192.168.31.33<\/code> \u6ce8\u518c<\/p>\n<\/li>\n<li>\n<p><code>192.168.31.33<\/code>\u5411<code>192.168.31.31<\/code>\u3001<code>192.168.31.32<\/code> \u6ce8\u518c<\/p>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/12\/03\/apollo-prd.jpg\" alt=\"apollo-prd\" \/><\/p>\n<p>\u73b0\u5728\u5f53\u4f60\u4fee\u6539\u4e86\u8fd9\u4e2a\u914d\u7f6e\u9879\uff0c\u5e76\u4e14\u53d1\u5e03\u4e86\uff0ceureka\u5c31\u4f1a\u7acb\u5373\u751f\u6548\uff0c\u518d\u4e5f\u4e0d\u7528\u53bb\u624b\u52a8\u914d\u7f6e\u518d\u6253\u5305\u4e86\uff0c\u53ef\u4ee5\u6109\u5feb\u5730\u73a9\u800d\u4e86\u3002<\/p>\n<h2>\u4e03\u3001\u6700\u540e<\/h2>\n<p>\u6309\u7167Apollo\u7684\u6587\u6863\u987a\u5e8f\u542f\u52a8\u670d\u52a1\uff0c\u4e00\u822c\u5148\u542f\u52a8\u6570\u636e\u5e93\u3001Eureka(\u5982\u679c\u6709)\u3001<code>Apollo Config Service<\/code>\u3001<code>Apollo Admin Service<\/code>\uff0c\u6700\u540e\u542f\u52a8<code>Apollo Portal<\/code>\u3002<\/p>\n<p>\u4e5f\u53ef\u4ee5\u6dfb\u52a0\u51e0\u4e2a\u7528\u6237\uff0c\u4ece\u800c\u8fdb\u884c\u5404\u79cd\u6743\u9650\u7684\u7ba1\u7406\u5de5\u4f5c\u3002<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2024\/12\/03\/Screenshot-2024-12-02-133822.png\" alt=\"Screenshot 2024-12-02 133822\" \/><\/p>\n<blockquote>\n<p>Reference\uff1a <\/p>\n<p>\u643a\u7a0bApollo\u5b98\u7f51\uff1a<a href=\"https:\/\/www.apolloconfig.com\/\">https:\/\/www.apolloconfig.com\/<\/a>#\/<\/p>\n<p>Apollo quick start\uff1a<a href=\"https:\/\/github.com\/apolloconfig\/apollo-quick-start\">https:\/\/github.com\/apolloconfig\/apollo-quick-start<\/a><\/p>\n<p>\u4e00\u6b65\u5230\u4f4d\u8bb2\u89e3ubuntu\u5b89\u88c5MySql\uff1a<a href=\"https:\/\/blog.csdn.net\/zhiqingcn\/article\/details\/140794841\">https:\/\/blog.csdn.net\/zhiqingcn\/article\/details\/140794841<\/a><\/p>\n<p>Apollo \u914d\u7f6e\u4e2d\u5fc3\u8be6\u7ec6\u6559\u7a0b:<a href=\"https:\/\/xie.infoq.cn\/article\/eb8b8c2d63f86ac26fae23692\">https:\/\/xie.infoq.cn\/article\/eb8b8c2d63f86ac26fae23692<\/a><\/p>\n<p>Apollo\u5206\u5e03\u5f0f\u96c6\u7fa4\u90e8\u7f72:<a href=\"https:\/\/www.cnblogs.com\/jluo\/p\/16985091.html\">https:\/\/www.cnblogs.com\/jluo\/p\/16985091.html<\/a><\/p>\n<p>Apollo\u914d\u7f6e\u4e2d\u5fc3\u89e3\u60d1\uff1a\u5173\u4e8e\u4e00\u4e2aportal\u7ba1\u7406\u591a\u4e2a\u73af\u5883\uff0c\u8981\u6c42\u73af\u5883\u76f8\u4e92\u4e4b\u95f4\u4e0d\u5f71\u54cd\uff0c\u72ec\u7acb:<a href=\"https:\/\/www.cnblogs.com\/xiaohouzai\/p\/8923463.html\">https:\/\/www.cnblogs.com\/xiaohouzai\/p\/8923463.html<\/a><\/p>\n<p>2023\u5e74\u6700\u65b0\u7248Apollo\u4fdd\u59c6\u7ea7\u4f7f\u7528\u624b\u518c(\u8d85\u7ea7\u8be6\u5c3d\u7248\u672c)\uff1a<a href=\"https:\/\/www.cnblogs.com\/liuyangfirst\/p\/17726702.html\">https:\/\/www.cnblogs.com\/liuyangfirst\/p\/17726702.html<\/a><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Spring Cloud(Kilburn 2022.0.2\u7248\u672c)\u7cfb\u5217\u6559\u7a0b(\u516d) \u5206\u5e03\u5f0f\u914d\u7f6e\u4e2d\u5fc3(Apollo) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-1078","post","type-post","status-publish","format-standard","hentry","category-spring-cloudkilburn-2022-0-2"],"_links":{"self":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts\/1078","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1078"}],"version-history":[{"count":1,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts\/1078\/revisions"}],"predecessor-version":[{"id":1079,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=\/wp\/v2\/posts\/1078\/revisions\/1079"}],"wp:attachment":[{"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1078"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.huerpu.cc:7000\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}