From 821c8559e6106985aca0313f30992690c4f1f8f6 Mon Sep 17 00:00:00 2001 From: wxq Date: Sun, 6 Nov 2022 13:34:56 +0800 Subject: [PATCH] feat: use can change spring.profiles.active's value without rebuild project (#4616) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: move spring.profiles.active to application.properties * fix: h2 test error when spring.jpa.properties.hibernate.globally_quoted_identifiers=true * fix(adminservice): test fail h2 test error when globally_quoted_identifiers = true * fix(configservice): test fail h2 test error when globally_quoted_identifiers=true * fix(portal): test fail h2 test error when globally_quoted_identifiers=true * fix: ${apollo_profile} * fix: license * feat: user only need to uncomment spring.profiles.active * test: fix * refactor: rename back to application.properties in src/test/resources * fix: applicatioin.properties -> applicatioin.yaml forbid cover config * test: add config DB_CLOSE_DELAY=-1 * test: fix config apolloconfigdb -> apolloportaldb * refactor: remove @TestPropertySource("classpath:" + "application.properties") * Update distributed-deployment-guide.md * fix: delete kubernetes and nacos discovery in application.properties * Update docs/zh/deployment/distributed-deployment-guide.md Co-authored-by: Jason Song * Update docs/zh/deployment/distributed-deployment-guide.md Co-authored-by: Jason Song * Update docs/zh/deployment/distributed-deployment-guide.md Co-authored-by: Jason Song * Apply suggestions from code review Co-authored-by: Jason Song * move up `启用外部xxxxxx` * docs: Replace built-in eureka with another service registry * Update CHANGES.md Co-authored-by: Jason Song --- CHANGES.md | 1 + .../src/assembly/assembly-descriptor.xml | 1 + .../src/main/resources/application.properties | 21 ++ .../src/test/resources/application.properties | 13 +- .../src/test/resources/application.properties | 2 +- .../apollo/biz/AbstractIntegrationTest.java | 6 +- .../src/test/resources/application.properties | 16 +- .../src/main/resources/application.properties | 40 --- .../src/main/resources/application.yaml | 57 +++++ .../src/assembly/assembly-descriptor.xml | 1 + .../src/main/resources/application.properties | 21 ++ .../src/test/resources/application.properties | 12 +- .../src/test/resources/application.properties | 12 +- .../distributed-deployment-guide.md | 231 +++++++++++++----- .../distributed-deployment-guide.md | 218 ++++++++++++----- 15 files changed, 477 insertions(+), 175 deletions(-) create mode 100644 apollo-adminservice/src/main/resources/application.properties delete mode 100644 apollo-common/src/main/resources/application.properties create mode 100644 apollo-common/src/main/resources/application.yaml create mode 100644 apollo-configservice/src/main/resources/application.properties diff --git a/CHANGES.md b/CHANGES.md index fba34333279..fc23ae8760e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -36,6 +36,7 @@ Apollo 2.1.0 * [feat: support use database as a registry](https://github.com/apolloconfig/apollo/pull/4595) * [fix doc bug](https://github.com/apolloconfig/apollo/pull/4579) * [fix Grayscale release Item Value length limit can not be synchronized with its main version](https://github.com/apolloconfig/apollo/pull/4622) +* [feat: use can change spring.profiles.active's value without rebuild project](https://github.com/apolloconfig/apollo/pull/4616) ------------------ All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/11?closed=1) diff --git a/apollo-adminservice/src/assembly/assembly-descriptor.xml b/apollo-adminservice/src/assembly/assembly-descriptor.xml index a219f6b7f20..4bf181a6a04 100644 --- a/apollo-adminservice/src/assembly/assembly-descriptor.xml +++ b/apollo-adminservice/src/assembly/assembly-descriptor.xml @@ -56,6 +56,7 @@ /config application-github.properties + application.properties diff --git a/apollo-adminservice/src/main/resources/application.properties b/apollo-adminservice/src/main/resources/application.properties new file mode 100644 index 00000000000..64b387aaffd --- /dev/null +++ b/apollo-adminservice/src/main/resources/application.properties @@ -0,0 +1,21 @@ +# +# Copyright 2022 Apollo Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# You may uncomment the following config to activate different spring profiles +#spring.profiles.active=github,consul-discovery +#spring.profiles.active=github,zookeeper-discovery +#spring.profiles.active=github,custom-defined-discovery +#spring.profiles.active=github,database-discovery diff --git a/apollo-adminservice/src/test/resources/application.properties b/apollo-adminservice/src/test/resources/application.properties index 6023ea462e3..b7bb47b8188 100644 --- a/apollo-adminservice/src/test/resources/application.properties +++ b/apollo-adminservice/src/test/resources/application.properties @@ -13,13 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # +spring.cloud.consul.enabled=false +spring.cloud.zookeeper.enabled=false +spring.cloud.discovery.enabled=false + spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1 + spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl +spring.jpa.hibernate.globally_quoted_identifiers=false +spring.jpa.properties.hibernate.globally_quoted_identifiers=false spring.jpa.properties.hibernate.show_sql=false spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor +spring.jpa.defer-datasource-initialization=true + spring.h2.console.enabled = true spring.h2.console.settings.web-allow-others=true + spring.main.allow-bean-definition-overriding=true -spring.cloud.consul.enabled=false -spring.cloud.zookeeper.enabled=false -spring.jpa.defer-datasource-initialization=true \ No newline at end of file diff --git a/apollo-assembly/src/test/resources/application.properties b/apollo-assembly/src/test/resources/application.properties index fd5ed8d5558..c85ae7e2cd2 100644 --- a/apollo-assembly/src/test/resources/application.properties +++ b/apollo-assembly/src/test/resources/application.properties @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE +spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1 spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.properties.hibernate.show_sql=false spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor diff --git a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java index 114835a3016..0a47a5d0835 100644 --- a/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java +++ b/apollo-biz/src/test/java/com/ctrip/framework/apollo/biz/AbstractIntegrationTest.java @@ -26,8 +26,10 @@ @RunWith(SpringJUnit4ClassRunner.class) @Rollback @Transactional -@SpringBootTest(classes = BizTestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT - , properties = {"spring.cloud.discovery.enabled=false"}) +@SpringBootTest( + classes = BizTestConfiguration.class, + webEnvironment = WebEnvironment.RANDOM_PORT +) public abstract class AbstractIntegrationTest { } diff --git a/apollo-biz/src/test/resources/application.properties b/apollo-biz/src/test/resources/application.properties index 9b4c61093ad..a66f0db707e 100644 --- a/apollo-biz/src/test/resources/application.properties +++ b/apollo-biz/src/test/resources/application.properties @@ -13,12 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # -spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE +spring.cloud.consul.enabled=false +spring.cloud.zookeeper.enabled=false +spring.cloud.discovery.enabled=false + +spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1 + spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl +spring.jpa.hibernate.globally_quoted_identifiers=false +spring.jpa.properties.hibernate.globally_quoted_identifiers=false spring.jpa.properties.hibernate.show_sql=false spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor +spring.jpa.defer-datasource-initialization=true + spring.h2.console.enabled = true -spring.h2.console.settings.web-allow-others=true -spring.cloud.consul.enabled=false -spring.cloud.zookeeper.enabled=false -spring.jpa.defer-datasource-initialization=true \ No newline at end of file +spring.h2.console.settings.web-allow-others=true \ No newline at end of file diff --git a/apollo-common/src/main/resources/application.properties b/apollo-common/src/main/resources/application.properties deleted file mode 100644 index 5aa63e48675..00000000000 --- a/apollo-common/src/main/resources/application.properties +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright 2022 Apollo Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -spring.mvc.converters.preferred-json-mapper=gson - -# DataSource -spring.datasource.hikari.connectionInitSql=set names utf8mb4 -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver - -# Naming strategy -spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl -spring.jpa.hibernate.globally_quoted_identifiers=true -spring.jpa.properties.hibernate.globally_quoted_identifiers=true - -# Tomcat configuration -server.tomcat.accept-count=5000 -# Increase tomcat header size for longer GET query parameter, should be n * 1024 -server.max-http-header-size=10240 - -# Spring Boot 2.x -management.endpoints.web.base-path=/ -logging.logback.rollingpolicy.max-file-size=50MB -logging.logback.rollingpolicy.max-history=10 - -management.endpoints.web.exposure.include=info,health,metrics,prometheus - -# Project information -spring.info.git.location=classpath:apollo-git.properties \ No newline at end of file diff --git a/apollo-common/src/main/resources/application.yaml b/apollo-common/src/main/resources/application.yaml new file mode 100644 index 00000000000..450f08d992e --- /dev/null +++ b/apollo-common/src/main/resources/application.yaml @@ -0,0 +1,57 @@ +# +# Copyright 2022 Apollo Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +spring: + jpa: + properties: + hibernate: + globally_quoted_identifiers: 'true' + hibernate: + globally_quoted_identifiers: 'true' + # Naming strategy + naming: + physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + info: + # Project information + git: + location: classpath:apollo-git.properties + mvc: + converters: + preferred-json-mapper: gson + # DataSource + datasource: + hikari: + connectionInitSql: set names utf8mb4 + +# Tomcat configuration +server: + tomcat: + accept-count: '5000' + # Increase tomcat header size for longer GET query parameter, should be n * 1024 + max-http-header-size: '10240' + +# Spring Boot 2.x +management: + endpoints: + web: + exposure: + include: info,health,metrics,prometheus + base-path: / +logging: + logback: + rollingpolicy: + max-history: '10' + max-file-size: 50MB \ No newline at end of file diff --git a/apollo-configservice/src/assembly/assembly-descriptor.xml b/apollo-configservice/src/assembly/assembly-descriptor.xml index 55d785d9073..9ee41cb8e24 100644 --- a/apollo-configservice/src/assembly/assembly-descriptor.xml +++ b/apollo-configservice/src/assembly/assembly-descriptor.xml @@ -56,6 +56,7 @@ /config application-github.properties + application.properties diff --git a/apollo-configservice/src/main/resources/application.properties b/apollo-configservice/src/main/resources/application.properties new file mode 100644 index 00000000000..64b387aaffd --- /dev/null +++ b/apollo-configservice/src/main/resources/application.properties @@ -0,0 +1,21 @@ +# +# Copyright 2022 Apollo Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# You may uncomment the following config to activate different spring profiles +#spring.profiles.active=github,consul-discovery +#spring.profiles.active=github,zookeeper-discovery +#spring.profiles.active=github,custom-defined-discovery +#spring.profiles.active=github,database-discovery diff --git a/apollo-configservice/src/test/resources/application.properties b/apollo-configservice/src/test/resources/application.properties index 6ac3f5447d1..a96d38b5180 100644 --- a/apollo-configservice/src/test/resources/application.properties +++ b/apollo-configservice/src/test/resources/application.properties @@ -13,16 +13,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # +spring.cloud.consul.enabled=false +spring.cloud.zookeeper.enabled=false + spring.datasource.url = jdbc:h2:mem:~/apolloconfigdb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1 + spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl +spring.jpa.hibernate.globally_quoted_identifiers=false +spring.jpa.properties.hibernate.globally_quoted_identifiers=false spring.jpa.properties.hibernate.show_sql=false spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor +spring.jpa.defer-datasource-initialization=true + spring.h2.console.enabled = true spring.h2.console.settings.web-allow-others=true -spring.cloud.consul.enabled=false -spring.cloud.zookeeper.enabled=false + spring.main.allow-bean-definition-overriding=true -spring.jpa.defer-datasource-initialization=true # for ReleaseMessageScanner test apollo.message-scan.interval=100 diff --git a/apollo-portal/src/test/resources/application.properties b/apollo-portal/src/test/resources/application.properties index e502376bfdc..2811617703f 100644 --- a/apollo-portal/src/test/resources/application.properties +++ b/apollo-portal/src/test/resources/application.properties @@ -13,11 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # -spring.session.store-type=none +spring.cloud.consul.enabled=false +spring.cloud.zookeeper.enabled=false +spring.cloud.discovery.enabled=false + spring.datasource.url = jdbc:h2:mem:~/apolloportaldb;mode=mysql;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1 + spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl +spring.jpa.hibernate.globally_quoted_identifiers=false +spring.jpa.properties.hibernate.globally_quoted_identifiers=false spring.jpa.properties.hibernate.show_sql=false spring.jpa.properties.hibernate.metadata_builder_contributor=com.ctrip.framework.apollo.common.jpa.SqlFunctionsMetadataBuilderContributor +spring.jpa.defer-datasource-initialization=true + spring.h2.console.enabled = true spring.h2.console.settings.web-allow-others=true + +spring.session.store-type=none spring.main.allow-bean-definition-overriding=true diff --git a/docs/en/deployment/distributed-deployment-guide.md b/docs/en/deployment/distributed-deployment-guide.md index 5e9ee6a9b6d..94d4ee483d7 100644 --- a/docs/en/deployment/distributed-deployment-guide.md +++ b/docs/en/deployment/distributed-deployment-guide.md @@ -499,7 +499,67 @@ Note that since ApolloConfigDB is deployed in each environment, the admin-servic `apollo-portal-x.x.x-github.zip` located in the `apollo-portal/target/` directory -##### 2.2.1.2.7 Enable external nacos service registry to replace built-in eureka +### 2.2.2 Deploy Apollo server + +#### 2.2.2.1 Deploy apollo-configservice + +Upload the `apollo-configservice-x.x.x-github.zip` of the corresponding environment to the server, decompress it and execute scripts/startup.sh. To stop the service, execute scripts/shutdown.sh. + +Remember to set a JVM memory according to the actual environment in scripts/startup.sh. The following are our default settings for reference: + +```bash +export JAVA_OPTS="-server -Xms6144m -Xmx6144m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=4096m -XX:MaxNewSize=4096m -XX:SurvivorRatio=18" +```` + +> Note 1: If you need to modify the JVM parameters, you can modify the `JAVA_OPTS` section of scripts/startup.sh. + +> Note 2: To adjust the log output path of the service, you can modify `LOG_DIR` in scripts/startup.sh and apollo-configservice.conf. + +> Note 3: To adjust the listening port of the service, you can modify the `SERVER_PORT` in scripts/startup.sh. In addition, apollo-configservice also assumes the responsibility of meta server. If you want to modify the port, pay attention to the `eureka.service.url` configuration item in the ApolloConfigDB.ServerConfig table and the meta server information used in apollo-portal and apollo-client. For details, see: [2.2.1.1.2.4 Configuring the meta service information of apollo-portal](en/deployment/distributed-deployment-guide?id=_221124-configuring-apollo-portal39s-meta-service-information) and [1.2.2 Apollo Meta Server](en/usage/java-sdk-user-guide?id=_122-apollo-meta-server). + +> Note 4: If the eureka.service.url of ApolloConfigDB.ServerConfig is only configured with the currently starting machine, the eureka registration failure information will be output in the log during the process of starting apollo-configservice, such as `com.sun.jersey .api.client.ClientHandlerException: java.net.ConnectException: Connection refused`. It should be noted that this is the expected situation, because apollo-configservice needs to register the service with the Meta Server (itself), but because it has not yet woken up during the startup process, it will report this error. The retry action will be performed later, so the registration will be normal after the service is up. + +> Note 5: If you read this, I believe that you must be someone who reads the documentation carefully, and you are a little bit closer to success. Keep going, you should be able to complete the distributed deployment of Apollo soon! But do you feel that Apollo's distributed deployment steps are a bit cumbersome? Do you have any advice you would like to share with the author? If the answer is yes, please move to [#1424](https://github.com/apolloconfig/apollo/issues/1424) and look forward to your suggestions! + +#### 2.2.2.2 Deploy apollo-adminservice + +Upload the `apollo-adminservice-x.x.x-github.zip` of the corresponding environment to the server, decompress it and execute scripts/startup.sh. To stop the service, execute scripts/shutdown.sh. + +Remember to set a JVM memory according to the actual environment in scripts/startup.sh. The following are our default settings for reference: + +```bash +export JAVA_OPTS="-server -Xms2560m -Xmx2560m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1024m -XX:MaxNewSize=1024m -XX:SurvivorRatio=22" +```` + +> Note 1: If you need to modify the JVM parameters, you can modify the `JAVA_OPTS` section of scripts/startup.sh. + +> Note 2: To adjust the log output path of the service, you can modify `LOG_DIR` in scripts/startup.sh and apollo-adminservice.conf. + +> Note 3: To adjust the listening port of the service, you can modify the `SERVER_PORT` in scripts/startup.sh. + +#### 2.2.2.3 Deploy apollo-portal + +Upload `apollo-portal-x.x.x-github.zip` to the server, unzip it and execute scripts/startup.sh. To stop the service, execute scripts/shutdown.sh. + +Remember to set a JVM memory according to the actual environment in startup.sh. The following are our default settings for reference: + +```bash +export JAVA_OPTS="-server -Xms4096m -Xmx4096m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1536m -XX:MaxNewSize=1536m -XX:SurvivorRatio=22" +```` + +> Note 1: If you need to modify the JVM parameters, you can modify the `JAVA_OPTS` section of scripts/startup.sh. + +> Note 2: To adjust the log output path of the service, you can modify `LOG_DIR` in scripts/startup.sh and apollo-portal.conf. + +> Note 3: To adjust the listening port of the service, you can modify the `SERVER_PORT` in scripts/startup.sh. + +### 2.2.3 Replace built-in eureka with another service registry + +#### 2.2.3.1 nacos-discovery + +Enable external nacos service registry to replace built-in eureka + +> Note: need repackage 1. Modify build.sh/build.bat to change the maven build command for config-service and admin-service to @@ -520,7 +580,31 @@ nacos.discovery.namespace= nacos.discovery.context-path= ``` -##### 2.2.1.2.8 Enable external Consul service registry to replace built-in eureka +#### 2.2.3.2 consul-discovery + +Enable external Consul service registry to replace built-in eureka + +##### 2.2.3.2.1 For version 2.1.0 and above + +1. Modify `config/application.properties` after decompression of `apollo-configservice-x.x.x-github.zip` and `apollo-adminservice-x.x.x-github.zip`, uncomment + ```properties + #spring.profiles.active=github,consul-discovery + ``` + + to + + ```properties + spring.profiles.active=github,consul-discovery + ``` + +2. Modify the application-github.properties in the config directory of the apollo-configservice and apollo-adminservice installation packages, respectively, to configure the consul server address + +```properties +spring.cloud.consul.host=127.0.0.1 +spring.cloud.consul.port=8500 +``` + +##### 2.2.3.2.2 For version 2.1.0 below 1. Modify build.sh/build.bat to change the maven build command for config-service and admin-service to @@ -535,13 +619,22 @@ spring.cloud.consul.host=127.0.0.1 spring.cloud.consul.port=8500 ``` -##### 2.2.1.2.9 Enable external Zookeeper service registry to replace built-in eureka +#### 2.2.3.3 zookeeper-discovery -1. Modify build.sh/build.bat to change the maven build command for ``config-service`` and ``admin-service`` to +Enable external Zookeeper service registry to replace built-in eureka -```shell -mvn clean package -Pgithub -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,zookeeper-discovery - Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password -``` +##### 2.2.3.3.1 For version 2.1.0 and above + +1. Modify `config/application.properties` after decompression of `apollo-configservice-x.x.x-github.zip` and `apollo-adminservice-x.x.x-github.zip`, uncomment + ```properties + #spring.profiles.active=github,zookeeper-discovery + ``` + + to + + ```properties + spring.profiles.active=github,zookeeper-discovery + ``` 2. Modify the application-github.properties in the config directory of the apollo-config service and apollo-adminservice installation packages, respectively, to configure the zookeeper server address @@ -561,99 +654,109 @@ admin.enableServer admin.serverPort ``` -##### 2.2.1.2.10 Enable custom-defined-discovery to replace built-in eureka +##### 2.2.3.3.2 For version 2.1.0 below -1. Modify build.sh/build.bat and change the maven compilation commands of `config-service` and `admin-service` to +1. Modify build.sh/build.bat to change the maven build command for ``config-service`` and ``admin-service`` to ```shell -mvn clean package -Pgithub -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,custom-defined-discovery -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password -```` - -2. There are two ways to configure the access addresses of the custom config-service and admin-service: one is to write two pieces of data in the mysql database ApolloConfigDB and the table ServerConfig. - -```sql -INSERT INTO `ApolloConfigDB`.`ServerConfig` (`Key`, `Value`, `Comment`) VALUES ('apollo.config-service.url', 'http://apollo-config-service', 'ConfigService access address '); -INSERT INTO `ApolloConfigDB`.`ServerConfig` (`Key`, `Value`, `Comment`) VALUES ('apollo.admin-service.url', 'http://apollo-admin-service', 'AdminService access address '); -```` +mvn clean package -Pgithub -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,zookeeper-discovery - Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password +``` -Another way to modify application-github.properties in the config directory of the apollo-configservice installation package +2. Modify the application-github.properties in the config directory of the apollo-config service and apollo-adminservice installation packages, respectively, to configure the zookeeper server address -````properties -apollo.config-service.url=http://apollo-config-service -apollo.admin-service.url=http://apollo-admin-service -```` +```properties +spring.cloud.zookeeper.connect-string=127.0.0.1:2181 +``` -##### 2.2.1.2.11 Enable database-discovery to replace built-in eureka +3. Zookeeper version description -> For version 2.1.0 and above -> -> Apollo supports the use of internal database table as registry, without relying on third-party registry. +* Support Zookeeper 3.5.x or higher; +* If apollo-configservice application starts reporting port occupation, please check the following configuration of Zookeeper; -1. Modify build.sh/build.bat and change the maven compilation commands of `config-service` and `admin-service` to -```shell -mvn clean package -Pgithub -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,database-discovery -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password -``` +> Note: Zookeeper 3.5.0 added a built-in [AdminServer](https://zookeeper.apache.org/doc/r3.5.0-alpha/zookeeperAdmin.html#sc_adminserver_config) -2. In multi-cluster deployments, if you want apollo client only read Config Service in the same cluster, -you can add a property in `config/application-github.properties` of the Config Service and Admin Service installation package ```properties -apollo.service.registry.cluster=same name with apollo Cluster +admin.enableServer +admin.serverPort ``` +#### 2.2.3.4 custom-defined-discovery -### 2.2.2 Deploy Apollo server +Enable custom-defined-discovery to replace built-in eureka -#### 2.2.2.1 Deploy apollo-configservice +##### 2.2.3.4.1 For version 2.1.0 and above -Upload the `apollo-configservice-x.x.x-github.zip` of the corresponding environment to the server, decompress it and execute scripts/startup.sh. To stop the service, execute scripts/shutdown.sh. +1. Modify `config/application.properties` after decompression of `apollo-configservice-x.x.x-github.zip` and `apollo-adminservice-x.x.x-github.zip`, uncomment + ```properties + #spring.profiles.active=github,custom-defined-discovery + ``` -Remember to set a JVM memory according to the actual environment in scripts/startup.sh. The following are our default settings for reference: + to -```bash -export JAVA_OPTS="-server -Xms6144m -Xmx6144m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=4096m -XX:MaxNewSize=4096m -XX:SurvivorRatio=18" -```` + ```properties + spring.profiles.active=github,custom-defined-discovery + ``` -> Note 1: If you need to modify the JVM parameters, you can modify the `JAVA_OPTS` section of scripts/startup.sh. +2. There are two ways to configure the access addresses of the custom config-service and admin-service: one is to write two pieces of data in the mysql database ApolloConfigDB and the table ServerConfig. -> Note 2: To adjust the log output path of the service, you can modify `LOG_DIR` in scripts/startup.sh and apollo-configservice.conf. +```sql +INSERT INTO `ApolloConfigDB`.`ServerConfig` (`Key`, `Value`, `Comment`) VALUES ('apollo.config-service.url', 'http://apollo-config-service', 'ConfigService access address '); +INSERT INTO `ApolloConfigDB`.`ServerConfig` (`Key`, `Value`, `Comment`) VALUES ('apollo.admin-service.url', 'http://apollo-admin-service', 'AdminService access address '); +``` -> Note 3: To adjust the listening port of the service, you can modify the `SERVER_PORT` in scripts/startup.sh. In addition, apollo-configservice also assumes the responsibility of meta server. If you want to modify the port, pay attention to the `eureka.service.url` configuration item in the ApolloConfigDB.ServerConfig table and the meta server information used in apollo-portal and apollo-client. For details, see: [2.2.1.1.2.4 Configuring the meta service information of apollo-portal](en/deployment/distributed-deployment-guide?id=_221124-configuring-apollo-portal39s-meta-service-information) and [1.2.2 Apollo Meta Server](en/usage/java-sdk-user-guide?id=_122-apollo-meta-server). +Another way to modify application-github.properties in the config directory of the apollo-configservice installation package -> Note 4: If the eureka.service.url of ApolloConfigDB.ServerConfig is only configured with the currently starting machine, the eureka registration failure information will be output in the log during the process of starting apollo-configservice, such as `com.sun.jersey .api.client.ClientHandlerException: java.net.ConnectException: Connection refused`. It should be noted that this is the expected situation, because apollo-configservice needs to register the service with the Meta Server (itself), but because it has not yet woken up during the startup process, it will report this error. The retry action will be performed later, so the registration will be normal after the service is up. +```properties +apollo.config-service.url=http://apollo-config-service +apollo.admin-service.url=http://apollo-admin-service +``` -> Note 5: If you read this, I believe that you must be someone who reads the documentation carefully, and you are a little bit closer to success. Keep going, you should be able to complete the distributed deployment of Apollo soon! But do you feel that Apollo's distributed deployment steps are a bit cumbersome? Do you have any advice you would like to share with the author? If the answer is yes, please move to [#1424](https://github.com/apolloconfig/apollo/issues/1424) and look forward to your suggestions! +##### 2.2.3.4.2 For version 2.1.0 below -#### 2.2.2.2 Deploy apollo-adminservice +1. Modify build.sh/build.bat and change the maven compilation commands of `config-service` and `admin-service` to -Upload the `apollo-adminservice-x.x.x-github.zip` of the corresponding environment to the server, decompress it and execute scripts/startup.sh. To stop the service, execute scripts/shutdown.sh. +```shell +mvn clean package -Pgithub -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,custom-defined-discovery -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password +``` -Remember to set a JVM memory according to the actual environment in scripts/startup.sh. The following are our default settings for reference: +2. There are two ways to configure the access addresses of the custom config-service and admin-service: one is to write two pieces of data in the mysql database ApolloConfigDB and the table ServerConfig. -```bash -export JAVA_OPTS="-server -Xms2560m -Xmx2560m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1024m -XX:MaxNewSize=1024m -XX:SurvivorRatio=22" -```` +```sql +INSERT INTO `ApolloConfigDB`.`ServerConfig` (`Key`, `Value`, `Comment`) VALUES ('apollo.config-service.url', 'http://apollo-config-service', 'ConfigService access address '); +INSERT INTO `ApolloConfigDB`.`ServerConfig` (`Key`, `Value`, `Comment`) VALUES ('apollo.admin-service.url', 'http://apollo-admin-service', 'AdminService access address '); +``` -> Note 1: If you need to modify the JVM parameters, you can modify the `JAVA_OPTS` section of scripts/startup.sh. +Another way to modify application-github.properties in the config directory of the apollo-configservice installation package -> Note 2: To adjust the log output path of the service, you can modify `LOG_DIR` in scripts/startup.sh and apollo-adminservice.conf. +```properties +apollo.config-service.url=http://apollo-config-service +apollo.admin-service.url=http://apollo-admin-service +``` -> Note 3: To adjust the listening port of the service, you can modify the `SERVER_PORT` in scripts/startup.sh. +#### 2.2.3.5 database-discovery -#### 2.2.2.3 Deploy apollo-portal +> For version 2.1.0 and above -Upload `apollo-portal-x.x.x-github.zip` to the server, unzip it and execute scripts/startup.sh. To stop the service, execute scripts/shutdown.sh. +Enable database-discovery to replace built-in eureka -Remember to set a JVM memory according to the actual environment in startup.sh. The following are our default settings for reference: +Apollo supports the use of internal database table as registry, without relying on third-party registry. -```bash -export JAVA_OPTS="-server -Xms4096m -Xmx4096m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1536m -XX:MaxNewSize=1536m -XX:SurvivorRatio=22" -```` +1. Modify `config/application.properties` after decompression of `apollo-configservice-x.x.x-github.zip` and `apollo-adminservice-x.x.x-github.zip`, uncomment + ```properties + #spring.profiles.active=github,database-discovery + ``` -> Note 1: If you need to modify the JVM parameters, you can modify the `JAVA_OPTS` section of scripts/startup.sh. + to -> Note 2: To adjust the log output path of the service, you can modify `LOG_DIR` in scripts/startup.sh and apollo-portal.conf. + ```properties + spring.profiles.active=github,database-discovery + ``` -> Note 3: To adjust the listening port of the service, you can modify the `SERVER_PORT` in scripts/startup.sh. +2. In multi-cluster deployments, if you want apollo client only read Config Service in the same cluster, +you can add a property in `config/application-github.properties` of the Config Service and Admin Service installation package +```properties +apollo.service.registry.cluster=same name with apollo Cluster +``` ## 2.3 Docker Deployment diff --git a/docs/zh/deployment/distributed-deployment-guide.md b/docs/zh/deployment/distributed-deployment-guide.md index fb328d03029..1bd507befa5 100644 --- a/docs/zh/deployment/distributed-deployment-guide.md +++ b/docs/zh/deployment/distributed-deployment-guide.md @@ -480,7 +480,61 @@ META_SERVERS_OPTS="-Ddev_meta=$dev_meta -Dfat_meta=$fat_meta -Duat_meta=$uat_met 位于`apollo-portal/target/`目录下的`apollo-portal-x.x.x-github.zip` -##### 2.2.1.2.7 启用外部nacos服务注册中心替换内置eureka +### 2.2.2 部署Apollo服务端 + +#### 2.2.2.1 部署apollo-configservice +将对应环境的`apollo-configservice-x.x.x-github.zip`上传到服务器上,解压后执行scripts/startup.sh即可。如需停止服务,执行scripts/shutdown.sh. + +记得在scripts/startup.sh中按照实际的环境设置一个JVM内存,以下是我们的默认设置,供参考: +```bash +export JAVA_OPTS="-server -Xms6144m -Xmx6144m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=4096m -XX:MaxNewSize=4096m -XX:SurvivorRatio=18" +``` + +> 注1:如果需要修改JVM参数,可以修改scripts/startup.sh的`JAVA_OPTS`部分。 + +> 注2:如要调整服务的日志输出路径,可以修改scripts/startup.sh和apollo-configservice.conf中的`LOG_DIR`。 + +> 注3:如要调整服务的监听端口,可以修改scripts/startup.sh中的`SERVER_PORT`。另外apollo-configservice同时承担meta server职责,如果要修改端口,注意要同时ApolloConfigDB.ServerConfig表中的`eureka.service.url`配置项以及apollo-portal和apollo-client中的使用到的meta server信息,详见:[2.2.1.1.2.4 配置apollo-portal的meta service信息](#_221124-配置apollo-portal的meta-service信息)和[1.2.2 Apollo Meta Server](zh/usage/java-sdk-user-guide#_122-apollo-meta-server)。 + +> 注4:如果ApolloConfigDB.ServerConfig的eureka.service.url只配了当前正在启动的机器的话,在启动apollo-configservice的过程中会在日志中输出eureka注册失败的信息,如`com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused`。需要注意的是,这个是预期的情况,因为apollo-configservice需要向Meta Server(它自己)注册服务,但是因为在启动过程中,自己还没起来,所以会报这个错。后面会进行重试的动作,所以等自己服务起来后就会注册正常了。 + +> 注5:如果你看到了这里,相信你一定是一个细心阅读文档的人,而且离成功就差一点点了,继续加油,应该很快就能完成Apollo的分布式部署了!不过你是否有感觉Apollo的分布式部署步骤有点繁琐?是否有啥建议想要和作者说?如果答案是肯定的话,请移步 [#1424](https://github.com/apolloconfig/apollo/issues/1424),期待你的建议! + +#### 2.2.2.2 部署apollo-adminservice +将对应环境的`apollo-adminservice-x.x.x-github.zip`上传到服务器上,解压后执行scripts/startup.sh即可。如需停止服务,执行scripts/shutdown.sh. + +记得在scripts/startup.sh中按照实际的环境设置一个JVM内存,以下是我们的默认设置,供参考: +```bash +export JAVA_OPTS="-server -Xms2560m -Xmx2560m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1024m -XX:MaxNewSize=1024m -XX:SurvivorRatio=22" +``` + +> 注1:如果需要修改JVM参数,可以修改scripts/startup.sh的`JAVA_OPTS`部分。 + +> 注2:如要调整服务的日志输出路径,可以修改scripts/startup.sh和apollo-adminservice.conf中的`LOG_DIR`。 + +> 注3:如要调整服务的监听端口,可以修改scripts/startup.sh中的`SERVER_PORT`。 + +#### 2.2.2.3 部署apollo-portal +将`apollo-portal-x.x.x-github.zip`上传到服务器上,解压后执行scripts/startup.sh即可。如需停止服务,执行scripts/shutdown.sh. + +记得在startup.sh中按照实际的环境设置一个JVM内存,以下是我们的默认设置,供参考: +```bash +export JAVA_OPTS="-server -Xms4096m -Xmx4096m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1536m -XX:MaxNewSize=1536m -XX:SurvivorRatio=22" +``` + +> 注1:如果需要修改JVM参数,可以修改scripts/startup.sh的`JAVA_OPTS`部分。 + +> 注2:如要调整服务的日志输出路径,可以修改scripts/startup.sh和apollo-portal.conf中的`LOG_DIR`。 + +> 注3:如要调整服务的监听端口,可以修改scripts/startup.sh中的`SERVER_PORT`。 + +### 2.2.3 使用其它服务注册中心替换内置eureka + +#### 2.2.3.1 nacos-discovery + +启用外部nacos服务注册中心替换内置eureka + +> 注意:需要重新打包 1. 修改build.sh/build.bat,将config-service和admin-service的maven编译命令更改为 ```shell @@ -499,7 +553,32 @@ nacos.discovery.namespace= nacos.discovery.context-path= ``` -##### 2.2.1.2.8 启用外部Consul服务注册中心替换内置eureka +#### 2.2.3.2 consul-discovery + +启用外部Consul服务注册中心替换内置eureka + +##### 2.2.3.2.1 2.1.0 及以上版本 + +1. 修改`apollo-configservice-x.x.x-github.zip`和`apollo-adminservice-x.x.x-github.zip`解压后的`config/application.properties`,取消注释,把 + ```properties + #spring.profiles.active=github,consul-discovery + ``` + + 变成 + + ```properties + spring.profiles.active=github,consul-discovery + ``` + +2. 分别修改apollo-configservice和apollo-adminservice安装包中config目录下的application-github.properties,配置consul服务器地址 +```properties +spring.cloud.consul.host=127.0.0.1 +spring.cloud.consul.port=8500 +``` + +##### 2.2.3.2.2 2.1.0 之前的版本 + +> 注意:需要重新打包 1. 修改build.sh/build.bat,将config-service和admin-service的maven编译命令更改为 ```shell @@ -512,7 +591,40 @@ spring.cloud.consul.host=127.0.0.1 spring.cloud.consul.port=8500 ``` -##### 2.2.1.2.9 启用外部Zookeeper服务注册中心替换内置eureka +#### 2.2.3.3 zookeeper-discovery + +启用外部Zookeeper服务注册中心替换内置eureka + +##### 2.2.3.3.1 2.1.0 及以上版本 + + + +1. 修改`apollo-configservice-x.x.x-github.zip`和`apollo-adminservice-x.x.x-github.zip`解压后的`config/application.properties`,取消注释,把 + ```properties + #spring.profiles.active=github,zookeeper-discovery + ``` + + 变成 + + ```properties + spring.profiles.active=github,zookeeper-discovery + ``` + +2. 分别修改apollo-configservice和apollo-adminservice安装包中config目录下的application-github.properties,配置zookeeper服务器地址 +```properties +spring.cloud.zookeeper.connect-string=127.0.0.1:2181 +``` +3.Zookeeper版本说明 +* 支持Zookeeper3.5.x以上的版本; +* 如果apollo-configservice应用启动报端口占用,请检查Zookeeper的如下配置; +> 注:Zookeeper3.5.0新增了内置的[AdminServer](https://zookeeper.apache.org/doc/r3.5.0-alpha/zookeeperAdmin.html#sc_adminserver_config) +```properties +admin.enableServer +admin.serverPort +``` + +##### 2.2.3.3.2 2.1.0 之前的版本 + 1. 修改build.sh/build.bat,将`config-service`和`admin-service`的maven编译命令更改为 ```shell mvn clean package -Pgithub -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,zookeeper-discovery -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password @@ -529,11 +641,24 @@ spring.cloud.zookeeper.connect-string=127.0.0.1:2181 admin.enableServer admin.serverPort ``` -##### 2.2.1.2.10 启用custom-defined-discovery替换内置eureka -1. 修改build.sh/build.bat,将`config-service`和`admin-service`的maven编译命令更改为 -```shell -mvn clean package -Pgithub -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,custom-defined-discovery -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password -``` + +#### 2.2.3.4 custom-defined-discovery + +启用custom-defined-discovery替换内置eureka + +##### 2.2.3.4.1 2.1.0 及以上版本 + +1. 修改`apollo-configservice-x.x.x-github.zip`和`apollo-adminservice-x.x.x-github.zip`解压后的`config/application.properties`,取消注释,把 + ```properties + #spring.profiles.active=github,custom-defined-discovery + ``` + + 变成 + + ```properties + spring.profiles.active=github,custom-defined-discovery + ``` + 2. 配置自定义的 config-service 与 admin-service 的访问地址有两种方式:一种在mysql数据库ApolloConfigDB,表ServerConfig当中写入两条数据。 ```sql INSERT INTO `ApolloConfigDB`.`ServerConfig` (`Key`, `Value`, `Comment`) VALUES ('apollo.config-service.url', 'http://apollo-config-service', 'ConfigService 访问地址'); @@ -545,71 +670,52 @@ apollo.config-service.url=http://apollo-config-service apollo.admin-service.url=http://apollo-admin-service ``` -##### 2.2.1.2.11 启用database-discovery替换内置eureka +##### 2.2.3.5.2 2.1.0 之前的版本 -> For version 2.1.0 and above -> -> Apollo支持使用内部的数据库表作为注册中心,不依赖第三方的注册中心 +> 注意:需要重新打包 1. 修改build.sh/build.bat,将`config-service`和`admin-service`的maven编译命令更改为 ```shell -mvn clean package -Pgithub -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,database-discovery -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password +mvn clean package -Pgithub -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github,custom-defined-discovery -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password ``` - -2. 在多机房部署时, -如果你需要apollo客户端只读取同机房内的Config Service, -你可以在Config Service和Admin Service安装包中`config/application-github.properties`新增一条配置 -```properties -apollo.service.registry.cluster=与apollo的Cluster同名 +2. 配置自定义的 config-service 与 admin-service 的访问地址有两种方式:一种在mysql数据库ApolloConfigDB,表ServerConfig当中写入两条数据。 +```sql +INSERT INTO `ApolloConfigDB`.`ServerConfig` (`Key`, `Value`, `Comment`) VALUES ('apollo.config-service.url', 'http://apollo-config-service', 'ConfigService 访问地址'); +INSERT INTO `ApolloConfigDB`.`ServerConfig` (`Key`, `Value`, `Comment`) VALUES ('apollo.admin-service.url', 'http://apollo-admin-service', 'AdminService 访问地址'); ``` - -### 2.2.2 部署Apollo服务端 - -#### 2.2.2.1 部署apollo-configservice -将对应环境的`apollo-configservice-x.x.x-github.zip`上传到服务器上,解压后执行scripts/startup.sh即可。如需停止服务,执行scripts/shutdown.sh. - -记得在scripts/startup.sh中按照实际的环境设置一个JVM内存,以下是我们的默认设置,供参考: -```bash -export JAVA_OPTS="-server -Xms6144m -Xmx6144m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=4096m -XX:MaxNewSize=4096m -XX:SurvivorRatio=18" +另外一种修改apollo-configservice安装包中config目录下的application-github.properties +```properties +apollo.config-service.url=http://apollo-config-service +apollo.admin-service.url=http://apollo-admin-service ``` -> 注1:如果需要修改JVM参数,可以修改scripts/startup.sh的`JAVA_OPTS`部分。 - -> 注2:如要调整服务的日志输出路径,可以修改scripts/startup.sh和apollo-configservice.conf中的`LOG_DIR`。 - -> 注3:如要调整服务的监听端口,可以修改scripts/startup.sh中的`SERVER_PORT`。另外apollo-configservice同时承担meta server职责,如果要修改端口,注意要同时ApolloConfigDB.ServerConfig表中的`eureka.service.url`配置项以及apollo-portal和apollo-client中的使用到的meta server信息,详见:[2.2.1.1.2.4 配置apollo-portal的meta service信息](#_221124-配置apollo-portal的meta-service信息)和[1.2.2 Apollo Meta Server](zh/usage/java-sdk-user-guide#_122-apollo-meta-server)。 - -> 注4:如果ApolloConfigDB.ServerConfig的eureka.service.url只配了当前正在启动的机器的话,在启动apollo-configservice的过程中会在日志中输出eureka注册失败的信息,如`com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused`。需要注意的是,这个是预期的情况,因为apollo-configservice需要向Meta Server(它自己)注册服务,但是因为在启动过程中,自己还没起来,所以会报这个错。后面会进行重试的动作,所以等自己服务起来后就会注册正常了。 - -> 注5:如果你看到了这里,相信你一定是一个细心阅读文档的人,而且离成功就差一点点了,继续加油,应该很快就能完成Apollo的分布式部署了!不过你是否有感觉Apollo的分布式部署步骤有点繁琐?是否有啥建议想要和作者说?如果答案是肯定的话,请移步 [#1424](https://github.com/apolloconfig/apollo/issues/1424),期待你的建议! - -#### 2.2.2.2 部署apollo-adminservice -将对应环境的`apollo-adminservice-x.x.x-github.zip`上传到服务器上,解压后执行scripts/startup.sh即可。如需停止服务,执行scripts/shutdown.sh. -记得在scripts/startup.sh中按照实际的环境设置一个JVM内存,以下是我们的默认设置,供参考: -```bash -export JAVA_OPTS="-server -Xms2560m -Xmx2560m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1024m -XX:MaxNewSize=1024m -XX:SurvivorRatio=22" -``` +#### 2.2.3.5 database-discovery -> 注1:如果需要修改JVM参数,可以修改scripts/startup.sh的`JAVA_OPTS`部分。 +> 仅支持 2.1.0 及以上版本 -> 注2:如要调整服务的日志输出路径,可以修改scripts/startup.sh和apollo-adminservice.conf中的`LOG_DIR`。 +启用database-discovery替换内置eureka -> 注3:如要调整服务的监听端口,可以修改scripts/startup.sh中的`SERVER_PORT`。 +Apollo支持使用内部的数据库表作为注册中心,不依赖第三方的注册中心 -#### 2.2.2.3 部署apollo-portal -将`apollo-portal-x.x.x-github.zip`上传到服务器上,解压后执行scripts/startup.sh即可。如需停止服务,执行scripts/shutdown.sh. +1. 修改`apollo-configservice-x.x.x-github.zip`和`apollo-adminservice-x.x.x-github.zip`解压后的`config/application.properties`,取消注释,把 + ```properties + #spring.profiles.active=github,database-discovery + ``` -记得在startup.sh中按照实际的环境设置一个JVM内存,以下是我们的默认设置,供参考: -```bash -export JAVA_OPTS="-server -Xms4096m -Xmx4096m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1536m -XX:MaxNewSize=1536m -XX:SurvivorRatio=22" -``` + 变成 -> 注1:如果需要修改JVM参数,可以修改scripts/startup.sh的`JAVA_OPTS`部分。 + ```properties + spring.profiles.active=github,database-discovery + ``` -> 注2:如要调整服务的日志输出路径,可以修改scripts/startup.sh和apollo-portal.conf中的`LOG_DIR`。 +2. 在多机房部署时, + 如果你需要apollo客户端只读取同机房内的Config Service, + 你可以在Config Service和Admin Service安装包中`config/application-github.properties`新增一条配置 + ```properties + apollo.service.registry.cluster=与apollo的Cluster同名 + ``` -> 注3:如要调整服务的监听端口,可以修改scripts/startup.sh中的`SERVER_PORT`。 ## 2.3 Docker部署 ### 2.3.1 1.7.0及以上版本