一.链接
官网:https://github.com/apolloconfig/apollo
中文文档:https://www.apolloconfig.com/#/zh/README
java客户端使用指南: https://www.apolloconfig.com/#/zh/usage/java-sdk-user-guide
二. 在线功能了解:
http://81.68.181.139/ apollo/admin
三.快速部署(本地试用):
git clone https://github.com/apolloconfig/apollo-quick-start.git
四.启动
端口不能被占用:
lsof -i:8070 --- Potal管理界面
lsof -i:8080 --- Config service+Eureka Server + Meta Server
lsof -i:8090 --- Admin Service
docker-compose up
Portal访问: http://Ip:8070 apollo/admin
五.试用
步骤:创建项目-》选择环境-》添加/修改配置=》发布 (name, spring.application.name)
六.客户端读取配置:
- application.yml
app:
id: apollo_client
apollo:
bootstrap:
enabled: true
namespaces: application,test
meta: http://192.168.1.155:8080
config-service: http://192.168.1.155:8080
- pom.xml
<!-- https://mvnrepository.com/artifact/com.ctrip.framework.apollo/apollo-client -->
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client-config-data</artifactId>
<version>1.9.0</version>
</dependency>
3.测试代码
Config appConfig = ConfigService.getAppConfig();
String property = appConfig.getProperty("name", "aaa");
String property1 = appConfig.getProperty("spring.application.name", "aaa");
System.out.println(property + "=name===spring.application.name=" + property1);
// 启动加参数-Denv=DEV
七.核心组成部分
https://mp.weixin.qq.com/s/-hUaQPzfsl9Lm3IqQW3VDQ (4+3 七个模块)
应用-》环境=》集群=》命名空间
Config Service: 提供配置的读取推送等功能-----Apollo客户端
Admin Service: 提供配置的修改,发布等功能-----Apollo Portal
Eureka提供服务注册和发现,Eureka与config service在一个JVM进程中
Eureka之上架了一层Meta Server 用于封装Eureka的服务发现接口
特点:
配置热更新(管理后台改完发布后,客户端不用重启能获得最新配置)
灰度发布
多环境,多集群配置管理
版本管理,支持回滚
权限管理、发布审核、操作审计
客户端配置信息监控 等
八.源码学习
git clone https://github.com/apolloconfig/apollo.git
//todo