Apollo(阿波罗)是携程框架部门研发的分布式配置中心,能够集中化管理应用不同环境、不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限、流程治理等特性,适用于微服务配置管理场景。
-
下载apollo-build-scripts或者源码编译,再或者直接下载release
-
使用包说明
-
apollo-adminservice 提供配置的修改、发布等功能,服务对象是Apollo Portal(管理界面)
-
apollo-configservice和Admin Service都是多实例、无状态部署,所以需要将自己注册到Eureka中并保持心跳
-
apollo-portal管理界面
-
-
mysql 5.7安装可以参考docker for mysql
-
ApolloPortalDB和ApolloConfigDB两个库创建 sql
-
修改数据库配置
-
-
启动顺序: apollo-configservice > apollo-adminservice > apollo-portal
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
</dependency>
</dependencies>
@SpringBootApplication
@EnableApolloConfig // 开启apollo
public class SpringApolloServer {
public static void main(String[] args) {
SpringApplication.run(SpringApolloServer.class, args);
}
}
app:
id: spring-boot-apollo # 配置的id
apollo:
meta: http://127.0.0.1:8080 # 拉去配置文件地址
cacheDir: ./apolloconfig # 缓存文件位置
bootstrap:
enabled: true
namespaces: application,application.yml
eagerLoad:
enabled: true # 优先加载
java -jar -Denv=DEV