Apollo作为成熟的分布式环境的配置中心,比Spring Cloud Config安装复杂很多,而且官方的安装文档因为考虑得特别全面,就写得很啰嗦,不方便我们快速部署。
Apollo主要部署3个组件
Apollo简化架构
下载页:https://github.com/ctripcorp/apollo/releases
wget https://github.com/ctripcorp/apollo/releases/download/v1.3.0/apollo-portal-1.3.0-github.zip
wget https://github.com/ctripcorp/apollo/releases/download/v1.3.0/apollo-adminservice-1.3.0-github.zip
wget https://github.com/ctripcorp/apollo/releases/download/v1.3.0/apollo-configservice-1.3.0-github.zip
wget
wget https://raw.githubusercontent.com/ctripcorp/apollo/master/scripts/db/migration/portaldb/V1.0.0__initialization.sql -O portaldb.sql
wget https://raw.githubusercontent.com/ctripcorp/apollo/master/scripts/db/migration/configdb/V1.0.0__initialization.sql -O configdb.sql
Config Service需要在每个环境都部署一套(DB + Config Service) Config Service需要在每个环境都部署一套(DB + Config Service) Config Service需要在每个环境都部署一套(DB + Config Service)
MySQL: 5.6.5+
source configdb.sql
select `Id`, `Key`, `Value`, `Comment` from `ApolloConfigDB`.`ServerConfig` limit 1;
unzip apollo-configservice-1.3.0-github.zip -d configservice
configservice/config/application-github.properties
# DataSource
spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123456
注意账号、密码后面不要有空格
configservice/scripts/startup.sh
因为日志写到/opt/logs,需要保证该目录的读写权限,或者在startup.sh修改LOG_DIR
Admin Service需要在每个环境都部署一套(DB + Admin Service) Admin Service需要在每个环境都部署一套(DB + Admin Service) Admin Service需要在每个环境都部署一套(DB + Admin Service)
Admin Service与Config Service共用数据库,所以不再需要导入
unzip apollo-adminservice-1.3.0-github.zip -d adminservice
adminservice/config/application-github.properties
# DataSource
spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123456
注意账号、密码后面不要有空格 这里数据库的配置与Config Service的一致
adminservice/srcripts/startup.sh
因为日志写到/opt/logs,需要保证该目录的读写权限,或者在startup.sh修改LOG_DIR
source portaldb.sql
select `Id`, `Key`, `Value`, `Comment` from `ApolloPortalDB`.`ServerConfig` limit 1;
unzip apollo-portal-1.3.0-github.zip -d portal
portal/config/application-github.properties
# DataSource
spring.datasource.url = jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123456
portal/config/apollo-env.properties
local.meta=http://localhost:8080
dev.meta=http://192.168.58.101:8080
pro.meta=http://192.168.58.201:8080
假设Config Service分别部署在192.168.58.101和192.168.58.201上
portal/scripts/startup.sh
http://localhost:8070 默认用户名:apollo 默认密码:admin
初始登录后,Apollo还需要进行一些配置,否则可能出现问题。配置的方式
管理员工具
-> 系统参数
dev,pro
,跟portal/config/apollo-env.properties
保持一致
系统参数修改
[{"orgId":"TEST1","orgName":"样例部门1"},{"orgId":"TEST2","orgName":"样例部门2"}]
scripts/startup.sh
scripts/startup.sh
或apollo-adminservice.conf
, apollo-configservice.conf
DEV
环境
管理工具 - 系统参数
查询参数apollo.portal.envs
后,只有dev
,修改为dev,prod
后保存修改完成后需要重启Portal生效
管理工具 - 系统参数
修改organizations