diff --git a/apollo-adminservice/src/main/resources/application-custom-defined-discovery.properties b/apollo-adminservice/src/main/resources/application-custom-defined-discovery.properties new file mode 100644 index 00000000000..7b5359247fc --- /dev/null +++ b/apollo-adminservice/src/main/resources/application-custom-defined-discovery.properties @@ -0,0 +1,17 @@ +# +# 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. +# +eureka.client.enabled=false +spring.cloud.discovery.enabled=false diff --git a/apollo-configservice/src/main/java/com/ctrip/framework/apollo/metaservice/service/DefaultDiscoveryService.java b/apollo-configservice/src/main/java/com/ctrip/framework/apollo/metaservice/service/DefaultDiscoveryService.java index b4de56b601f..ed10ce6b387 100644 --- a/apollo-configservice/src/main/java/com/ctrip/framework/apollo/metaservice/service/DefaultDiscoveryService.java +++ b/apollo-configservice/src/main/java/com/ctrip/framework/apollo/metaservice/service/DefaultDiscoveryService.java @@ -33,7 +33,7 @@ * Default discovery service for Eureka */ @Service -@ConditionalOnMissingProfile({"kubernetes", "nacos-discovery", "consul-discovery", "zookeeper-discovery"}) +@ConditionalOnMissingProfile({"kubernetes", "nacos-discovery", "consul-discovery", "zookeeper-discovery", "custom-defined-discovery"}) public class DefaultDiscoveryService implements DiscoveryService { private final EurekaClient eurekaClient; diff --git a/apollo-configservice/src/main/java/com/ctrip/framework/apollo/metaservice/service/KubernetesDiscoveryService.java b/apollo-configservice/src/main/java/com/ctrip/framework/apollo/metaservice/service/KubernetesDiscoveryService.java index f8c733b9829..b633688f53b 100644 --- a/apollo-configservice/src/main/java/com/ctrip/framework/apollo/metaservice/service/KubernetesDiscoveryService.java +++ b/apollo-configservice/src/main/java/com/ctrip/framework/apollo/metaservice/service/KubernetesDiscoveryService.java @@ -38,7 +38,7 @@ * */ @Service -@Profile({"kubernetes"}) +@Profile({"kubernetes", "custom-defined-discovery"}) public class KubernetesDiscoveryService implements DiscoveryService { private static final Splitter COMMA_SPLITTER = Splitter.on(",").omitEmptyStrings().trimResults(); private static final Map SERVICE_ID_TO_CONFIG_NAME = ImmutableMap diff --git a/apollo-configservice/src/main/resources/application-custom-defined-discovery.properties b/apollo-configservice/src/main/resources/application-custom-defined-discovery.properties new file mode 100644 index 00000000000..919d8dbea8b --- /dev/null +++ b/apollo-configservice/src/main/resources/application-custom-defined-discovery.properties @@ -0,0 +1,18 @@ +# +# 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. +# +apollo.eureka.server.enabled=false +eureka.client.enabled=false +spring.cloud.discovery.enabled=false diff --git a/docs/zh/deployment/distributed-deployment-guide.md b/docs/zh/deployment/distributed-deployment-guide.md index 106405039c9..cc91d1200ca 100644 --- a/docs/zh/deployment/distributed-deployment-guide.md +++ b/docs/zh/deployment/distributed-deployment-guide.md @@ -529,7 +529,21 @@ 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. 配置自定义的 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 访问地址'); +``` +另外一种修改apollo-configservice安装包中config目录下的application-github.properties +```properties +apollo.config-service.url=http://apollo-config-service +apollo.admin-service.url=http://apollo-admin-service +``` ### 2.2.2 部署Apollo服务端 #### 2.2.2.1 部署apollo-configservice