{"id":1460,"date":"2023-03-23T22:37:47","date_gmt":"2023-03-23T14:37:47","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1460"},"modified":"2023-04-28T20:42:04","modified_gmt":"2023-04-28T12:42:04","slug":"deployment-and-operation-of-ctrip-apollo-server","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/23\/deployment-and-operation-of-ctrip-apollo-server\/","title":{"rendered":"\u643a\u7a0bApollo\u670d\u52a1\u7aef\u90e8\u7f72\u4e0e\u64cd\u4f5c"},"content":{"rendered":"<h2>Apollo\u7b80\u4ecb<\/h2>\n<p>Apollo\uff08\u963f\u6ce2\u7f57\uff09\u662f\u643a\u7a0b\u6846\u67b6\u90e8\u95e8\u7814\u53d1\u7684\u5206\u5e03\u5f0f\u914d\u7f6e\u4e2d\u5fc3\uff0c\u80fd\u591f\u96c6\u4e2d\u5316\u7ba1\u7406\u5e94\u7528\u4e0d\u540c\u73af\u5883\u3001\u4e0d\u540c\u96c6\u7fa4\u7684\u914d\u7f6e\uff0c\u914d\u7f6e\u4fee\u6539\u540e\u80fd\u591f\u5b9e\u65f6\u63a8\u9001\u5230\u5e94\u7528\u7aef\uff0c\u5e76\u4e14\u5177\u5907\u89c4\u8303\u7684\u6743\u9650\u3001\u6d41\u7a0b\u6cbb\u7406\u7b49\u7279\u6027\uff0c\u9002\u7528\u4e8e\u5fae\u670d\u52a1\u914d\u7f6e\u7ba1\u7406\u573a\u666f\u3002<\/p>\n<p><!-- more --><\/p>\n<p>\u6240\u8c13\u5206\u5e03\u5f0f\u914d\u7f6e\u4e2d\u5fc3\u5c31\u662f\u628a\u5e94\u7528\u5185\u7684\u914d\u7f6e\u6587\u4ef6\u901a\u8fc7\u6280\u672f\u624b\u6bb5\u653e\u5728\u4e91\u7aef\uff0c\u5728\u4e91\u7aef\u914d\u7f6e\u8fc7\u540e\u53ef\u4ee5\u5728\u4e0d\u53d1\u5305\u7684\u60c5\u51b5\u4e0b\u7acb\u523b\u8ba9\u914d\u7f6e\u751f\u6548\u4ece\u800c\u8282\u7701\u5927\u91cf\u6253\u5305\u3001\u53d1\u5305\u3001\u91cd\u542f\u670d\u52a1\u7684\u65f6\u95f4\u3002<\/p>\n<p>\u9879\u76ee\u5730\u5740\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/ctripcorp\/apollo\">https:\/\/github.com\/ctripcorp\/apollo<\/a><br \/>\n\u5feb\u901f\u6784\u5efa\u811a\u672c\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/nobodyiam\/apollo-build-scripts\">https:\/\/github.com\/nobodyiam\/apollo-build-scripts<\/a><br \/>\nJava\u5ba2\u6237\u7aef\u4f7f\u7528\u6307\u5357\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/ctripcorp\/apollo\/wiki\/Java\">https:\/\/github.com\/ctripcorp\/apollo\/wiki\/Java<\/a><\/p>\n<h2>Apollo\u670d\u52a1\u7aef\u90e8\u7f72<\/h2>\n<h3>\u4e0b\u8f7d\u6e90\u7801\u6216\u8005\u5b89\u88c5\u5305<\/h3>\n<h4>\u5feb\u901f\u6784\u5efa\u811a\u672c\uff08\u63a8\u8350\uff09<\/h4>\n<p>\u5feb\u901f\u6784\u5efa\u811a\u672c\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/nobodyiam\/apollo-build-scripts\">https:\/\/github.com\/nobodyiam\/apollo-build-scripts<\/a><\/p>\n<p>\u53ef\u4ee5\u624b\u52a8\u6253\u5305Quick Start\u5b89\u88c5\u5305\uff0cQuick Start\u53ea\u9488\u5bf9\u672c\u5730\u6d4b\u8bd5\u4f7f\u7528\uff0c\u6240\u4ee5\u4e00\u822c\u7528\u6237\u4e0d\u9700\u8981\u81ea\u5df1\u4e0b\u8f7d\u6e90\u7801\u6253\u5305\uff0c\u53ea\u9700\u8981\u4e0b\u8f7d\u5df2\u7ecf\u6253\u597d\u7684\u5305\u5373\u53ef\u3002\u4e0d\u8fc7\u4e5f\u6709\u90e8\u5206\u7528\u6237\u5e0c\u671b\u5728\u4fee\u6539\u4ee3\u7801\uff08\u5982\u6ce8\u518c\u4e2d\u5fc3\u5730\u5740\u3001\u7aef\u53e3\u7b49\uff09\u540e\u91cd\u65b0\u6253\u5305\uff0c\u90a3\u4e48\u53ef\u4ee5\u53c2\u8003\u5982\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p>\uff081\uff09\u4fee\u6539<code>apollo-configservice<\/code>\u3001<code>apollo-adminservice<\/code>\u548c<code>apollo-portal<\/code>\u7684<code>pom.xml<\/code>\uff0c\u6ce8\u91ca\u6389<code>spring-boot-maven-plugin<\/code>\u548c<code>maven-assembly-plugin<\/code><br \/>\n\uff082\uff09\u5728\u6839\u76ee\u5f55\u4e0b\u6267\u884c<code>mvn clean package -pl apollo-assembly -am -DskipTests=true<\/code><br \/>\n\uff083\uff09\u590d\u5236<code>apollo-assembly\/target<\/code>\u4e0b\u7684jar\u5305\uff0crename\u4e3a<code>apollo-all-in-one.jar<\/code><\/p>\n<p>\u5982\u9700\u66f4\u6539\u6ce8\u518c\u4e2d\u5fc3\u5730\u5740\u53ca\u7aef\u53e3\uff0c\u5219\u9700\u4fee\u6539\u6587\u4ef6\uff1a<\/p>\n<ul>\n<li>apollo-admin\u7aef\u53e3\uff1aE:\\Apollo\u914d\u7f6e\u4e2d\u5fc3\\apollo\\apollo-adminservice\\src\\main\\resources\\application.yml<\/li>\n<li>apollo-admin\u7aef\u53e3\uff1aE:\\Apollo\u914d\u7f6e\u4e2d\u5fc3\\apollo\\apollo-adminservice\\src\\main\\resources\\adminservice.properties<\/li>\n<li>apollo-admin\u6ce8\u518c\u4e2d\u5fc3\uff1aE:\\Apollo\u914d\u7f6e\u4e2d\u5fc3\\apollo\\apollo-adminservice\\src\\main\\resources\\bootstrap.yml<\/li>\n<li>apollo-config\u7aef\u53e3\uff1aE:\\Apollo\u914d\u7f6e\u4e2d\u5fc3\\apollo\\apollo-configservice\\src\\main\\resources\\application.yml<\/li>\n<li>apollo-config\u7aef\u53e3\uff1aE:\\Apollo\u914d\u7f6e\u4e2d\u5fc3\\apollo\\apollo-configservice\\src\\main\\resources\\configservice.properties<\/li>\n<li>apollo-config\u6ce8\u518c\u4e2d\u5fc3\uff1aE:\\Apollo\u914d\u7f6e\u4e2d\u5fc3\\apollo\\apollo-configservice\\src\\main\\resources\\bootstrap.yml<\/li>\n<li>apollo-portal\u7aef\u53e3\uff1aE:\\Apollo\u914d\u7f6e\u4e2d\u5fc3\\apollo\\apollo-portal\\src\\main\\resources\\application.yml<\/li>\n<li>apollo-portal\u914d\u7f6e\uff1aE:\\Apollo\u914d\u7f6e\u4e2d\u5fc3\\apollo\\apollo-portal\\src\\main\\resources\\apollo-env.properties<\/li>\n<\/ul>\n<h4>\u5b98\u65b9releases\u5305<\/h4>\n<p>\u4ece<code>https:\/\/github.com\/ctripcorp\/apollo\/releases<\/code>\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>\u4f9d\u8d56\u5305\u3002<\/p>\n<h4>\u6e90\u7801\u6784\u5efa<\/h4>\n<p>\u4ece<code>https:\/\/github.com\/ctripcorp\/apollo<\/code>\u4e0b\u8f7d\u6e90\u7801\u540e\u5728\u672c\u5730\u6784\u5efa\u3002\u6784\u5efa\u6b65\u9aa4\u4e3a:<\/p>\n<p>\uff081\uff09\u4f7f\u7528scripts\u6587\u4ef6\u5939\u4e0b\u7684build.bat\u6216build.sh\u6784\u5efa<br \/>\n\uff082\uff09\u5206\u522b\u62f7\u8d1d\u51fa<code>apollo-adminservice<\/code>\u3001<code>apollo-configservice<\/code>\u548c<code>apollo-portal<\/code>3\u4e2a\u6587\u4ef6\u5939\u4e0b<code>target\/apollo-xxx-x.x.x-github.zip<\/code>\u6587\u4ef6<\/p>\n<h3>\u521b\u5efa\u6570\u636e\u5e93<\/h3>\n<p>Apollo\u670d\u52a1\u7aef\u5171\u9700\u8981\u4e24\u4e2a\u6570\u636e\u5e93\uff1a<code>ApolloPortalDB<\/code>\u548c<code>ApolloConfigDB<\/code>\uff0c\u5b98\u65b9\u4e3a\u6570\u636e\u5e93\u3001\u8868\u7684\u521b\u5efa\u548c\u6837\u4f8b\u6570\u636e\u90fd\u5206\u522b\u51c6\u5907\u4e86sql\u6587\u4ef6\uff0c\u53ea\u9700\u8981\u5bfc\u5165\u6570\u636e\u5e93\u5373\u53ef\u3002<\/p>\n<p>\u4ece<code>https:\/\/github.com\/nobodyiam\/apollo-build-scripts\/tree\/master\/sql<\/code>\u4e0b\u8f7d<code>apolloconfigdb.sql<\/code>\u548c<code>apolloportaldb.sql<\/code>\u6570\u636e\u5e93\u6587\u4ef6\u3002<\/p>\n<p>\u4f7f\u7528<code>apolloportaldb.sql<\/code>\u6587\u4ef6\u521b\u5efa<code>apolloportaldb<\/code>\u6570\u636e\u5e93\uff0c\u6b64\u6570\u636e\u5e93\u662f\u6211\u4eec\u7ba1\u7406\u5404\u79cd\u73af\u5883\u7b49\u7684\u901a\u7528\u6570\u636e\u5e93\u3002<\/p>\n<pre><code>source \/your_local_path\/sql\/apolloportaldb.sql\nselect `Id`, `AppId`, `Name` from ApolloPortalDB.App;<\/code><\/pre>\n<p>\u4f7f\u7528<code>apolloconfigdb.sql<\/code>\u6587\u4ef6\u5206\u522b\u521b\u5efa<code>apolloconfigdb_dev<\/code>\u548c<code>apolloconfigdb_fat<\/code>\u6570\u636e\u5e93\u4f5c\u4e3a\u6211\u4eec\u4e24\u4e2a\u73af\u5883\u7684\u6570\u636e\u5b58\u50a8\u3002<\/p>\n<pre><code>source \/your_local_path\/sql\/apolloconfigdb.sql\nselect `NamespaceId`, `Key`, `Value`, `Comment` from ApolloConfigDB.Item;<\/code><\/pre>\n<h3>\u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u4fe1\u606f<\/h3>\n<p>\u4fee\u6539<code>ApolloPortalDB<\/code>\u548c<code>ApolloConfigDB<\/code>\u76f8\u5173\u7684\u6570\u636e\u5e93\u8fde\u63a5\u4e32\u4fe1\u606f\u3002<\/p>\n<pre><code>vim demo.sh<\/code><\/pre>\n<pre><code># apollo config db info\napollo_config_db_url=jdbc:mysql:\/\/localhost:3306\/ApolloConfigDB?characterEncoding=utf8\napollo_config_db_username=apollo\napollo_config_db_password=jb6Pullq8rWZ3T5M\n\n# apollo portal db info\napollo_portal_db_url=jdbc:mysql:\/\/localhost:3306\/ApolloPortalDB?characterEncoding=utf8\napollo_portal_db_username=apollo\napollo_portal_db_password=jb6Pullq8rWZ3T5M<\/code><\/pre>\n<h3>Apollo\u914d\u7f6e\u4e2d\u5fc3<\/h3>\n<h4>\u786e\u4fdd\u7aef\u53e3\u672a\u88ab\u5360\u7528<\/h4>\n<p>Quick Start\u811a\u672c\u4f1a\u5728\u672c\u5730\u542f\u52a83\u4e2a\u670d\u52a1\uff0c\u5206\u522b\u4f7f\u7528<code>8070(apollo-portal)<\/code>\u3001<code>8080(apollo-configservice)<\/code>\u3001<code>8090(apollo-adminservice)<\/code>\u7aef\u53e3\uff0c\u786e\u4fdd\u8fd93\u4e2a\u7aef\u53e3\u5f53\u524d\u6ca1\u6709\u88ab\u4f7f\u7528\u3002<\/p>\n<p>\u5728Linux\/Mac\u4e0b\uff0c\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u68c0\u67e5\uff1a<\/p>\n<pre><code>lsof -i:8080<\/code><\/pre>\n<h4>\u542f\u52a8\u670d\u52a1<\/h4>\n<p>\u4fee\u6539\u6ce8\u518c\u4e2d\u5fc3\u5730\u5740\u53ca\u7aef\u53e3\uff1a<\/p>\n<pre><code># vim demo.sh<\/code><\/pre>\n<pre><code># meta server url\nconfig_server_url=http:\/\/localhost:8980\nadmin_server_url=http:\/\/localhost:8990\neureka_service_url=http:\/\/192.168.165.241:9999\/eureka\/\nportal_url=http:\/\/localhost:8970\n\n...\n\necho &quot;==== starting portal ====&quot;\necho &quot;Portal logging file is $PORTAL_LOG&quot;\nexport JAVA_OPTS=&quot;$PORTAL_JAVA_OPTS -Dlogging.file=.\/apollo-portal.log -Dserver.port=8970 -Dspring.datasource.url=$apollo_portal_db_url -Dspring.datasource.username=$apollo_portal_db_username -Dspring.datasource.password=$apollo_portal_db_password&quot;<\/code><\/pre>\n<p>\u6267\u884c\u542f\u52a8\u811a\u672c\uff1a<\/p>\n<pre><code># .\/demo.sh start<\/code><\/pre>\n<p>\u5f53\u770b\u5230\u5982\u4e0b\u8f93\u51fa\uff0c\u8bf4\u660e\u542f\u52a8\u6210\u529f\uff01<\/p>\n<pre><code>$ .\/demo.sh start\n==== starting service ====\nService logging file is .\/service\/apollo-service.log\nStarted [62461]\nWaiting for config service startup......\nConfig service started. You may visit http:\/\/localhost:8980 for service status now!\nWaiting for admin service startup..\nAdmin service started\n==== starting portal ====\nPortal logging file is .\/portal\/apollo-portal.log\nStarted [62657]\nWaiting for portal startup......\nPortal started. You can visit http:\/\/localhost:8970 now!<\/code><\/pre>\n<p>\u8bbf\u95eeApollo\u914d\u7f6e\u4e2d\u5fc3\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/localhost:8070\">http:\/\/localhost:8070<\/a><\/p>\n<ul>\n<li>\u7528\u6237\u540d: apollo<\/li>\n<li>\u5bc6\u7801: admin<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u8fd0\u7ef4\/Apollo\u767b\u9646\u9875.png\" alt=\"Apollo\u767b\u9646\u9875\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/\u8fd0\u7ef4\/Apollo\u914d\u7f6e\u4e2d\u5fc3.png\" alt=\"Apollo\u914d\u7f6e\u4e2d\u5fc3\" \/><\/p>\n<h3>\u5e38\u89c1\u95ee\u9898<\/h3>\n<p>\u82e5\u9047\u5230 admin \u548c config \u5747\u5df2\u542f\u52a8\uff0c\u4f46portal\u65e0\u6cd5\u8d77\u6765\uff0c\u800c\u4e14portal\u4e0b\u9762\u4e5f\u6ca1\u65e5\u5fd7\u6587\u4ef6\uff0c8070\u7aef\u53e3\u4e5f\u6ca1\u8d77\u6765\uff0c\u89e3\u51b3\u529e\u6cd5\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/nobodyiam\/apollo-build-scripts\/issues\/23\">https:\/\/github.com\/nobodyiam\/apollo-build-scripts\/issues\/23<\/a><\/p>\n<p><code>.\/demo.sh start<\/code> \u540e spring \u65e5\u5fd7\u6253\u5370\u5728\u4e86\u63a7\u5236\u53f0; \u53d1\u73b0\u662f\u56e0\u4e3a <code>service\/apollo-service.conf<\/code> \u6587\u4ef6\u683c\u5f0f\u662f dos (\u56e0\u4e3a\u81ea\u5df1\u5148 clone \u5230\u4e86 windows \u673a\u518d\u653e\u5230 lunix \u7684)\uff0c\u5c06\u5176\u8f6c\u4e3a unix \u683c\u5f0f\u540e\u5c31\u53ef\u4ee5\u4e86\uff0cportal \u7684\u7c7b\u4f3c\u95ee\u9898\u67e5\u770b <code>portal\\apollo-portal.conf<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apollo\u7b80\u4ecb Apollo\uff08\u963f\u6ce2\u7f57\uff09\u662f\u643a\u7a0b\u6846\u67b6\u90e8\u95e8\u7814\u53d1\u7684\u5206\u5e03\u5f0f\u914d\u7f6e\u4e2d\u5fc3\uff0c\u80fd\u591f\u96c6\u4e2d\u5316\u7ba1\u7406\u5e94\u7528\u4e0d\u540c\u73af\u5883\u3001\u4e0d\u540c\u96c6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[362],"tags":[361],"class_list":["post-1460","post","type-post","status-publish","format-standard","hentry","category-apollo-disconf","tag-apollo"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1460","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=1460"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1460\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}