SpringCloud微服务 Apollo分布式配置中心实现(三)
前言
本小结将 学习一下如何fork Apollo并做定制开发与部署。
案例
成功运行本小结案例需要准备环境和DB数据,具体参考前文,这里不做赘述。
-
Fork Latest Apollo Version-传送门 并导入IDE(我的是STS)
-
修改配置文件
-
apollo-configservice.
-
configservice.properties
#Used for apollo-assembly spring.application.name= apollo-configservice ctrip.appid= 100003171 server.port= 8080 logging.file= /opt/logs/100003171/apollo-configservice.log spring.jmx.default-domain = apollo-configservice # DataSource spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB?useUnicode=true&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8 spring.datasource.username = root spring.datasource.password = root
-
-
apollo-adminservice
-
adminservice.properties
#Used for apollo-assembly spring.application.name= apollo-adminservice ctrip.appid= 100003172 server.port= 8090 logging.file= /opt/logs/100003172/apollo-adminservice.log spring.jmx.default-domain = apollo-adminservice # DataSource spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB?useUnicode=true&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=GMT%2B8 spring.datasource.username = root spring.datasource.password = root
-
-
apollo-portal
-
application.yml(修改profile,实现登录功能)
spring: application: name: apollo-portal profiles: active: github,auth jpa: properties: hibernate: query: plan_cache_max_size: 192 # limit query plan cache max size server: port: 8070 compression: enabled: true tomcat: use-relative-redirects: true logging: file: /opt/logs/100003173/apollo-portal.log management: health: status: order: DOWN, OUT_OF_SERVICE, UNKNOWN, UP
-
apollo-env.properties
local.meta=http://localhost:8080 dev.meta=http://localhost:8080 fat.meta=http://localhost:8080 uat.meta=http://localhost:8080 lpt.meta=${lpt_meta} pro.meta=http://localhost:8080
-
classpath下新建application-github.properties抑或修改src/main/source下修改application-github.properties(推荐)
# DataSource spring.datasource.url=jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8 spring.datasource.username=root spring.datasource.password=root
-
-
-
分别运行apollo-configservice、apollo-adminservice、apollo-portal
-
-
使用apollo/admin Token登录
小结
-
本小结总结了使用携程Apollo源码开发以实现定制化开发,要想成功运行本小结案例需要对Apollo有更高的了解。
-
本节实现本部署方式问定制化,强烈推荐使用本节方法对Apollo做定制开发。、
-
定制化开发部署步骤:
- Fork源码(请一定要从Github上Fork,Gitee上已经很久没有更新了…)
- 修改各项配置
- 运行
- 体验
-
另外需要特殊申明:本小结结合了Spring Security实现了Portal端的用户登录,是的定制开发更深度也更完善。