一.介绍
Apollo(阿波罗)是携程框架部门研发的分布式配置中心,能够集中化管理应用不同环境、不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限、流程治理等特性,适用于微服务配置管理场景。
服务端基于Spring Boot和Spring Cloud开发,打包后可以直接运行,不需要额外安装Tomcat等应用容器。
Java客户端不依赖任何框架,能够运行于所有Java运行时环境,同时对Spring/Spring Boot环境也有较好的支持。
.Net客户端不依赖任何框架,能够运行于所有.Net运行时环境。
二.安装
1.创建ApolloPortalDB
下载地址:https://github.com/ctripcorp/apollo/blob/master/scripts/sql/apolloportaldb.sql
2.创建ApolloConfigDB
下载地址:https://github.com/ctripcorp/apollo/blob/master/scripts/sql/apolloconfigdb.sql
创建完之后
3.下载安装包
下载:apollo-adminservice-1.7.1-github.zip,apollo-configservice-1.7.1-github.zip,apollo-portal-1.7.1-github.zip
下载地址:https://github.com/ctripcorp/apollo/releases
4.Linux下解压运行
执行命令:
mkdir admin portal config
解压:
unzip apollo-configservice-1.7.1-github.zip -d config/ unzip apollo-adminservice-1.7.1-github.zip -d admin/ unzip apollo-portal-1.7.1-github.zip -d portal/
创建config日志文件:
[root@VM-0-8-centos apollo-start]# cd config/ [root@VM-0-8-centos config]# ls apollo-configservice-1.7.1.jar apollo-configservice.conf apollo-configservice_usrlocalapplicationapolloapollo-startconfig.pid scripts apollo-configservice-1.7.1-sources.jar apollo-configservice.jar config [root@VM-0-8-centos config]# cat apollo-configservice.conf MODE=service PID_FOLDER=. LOG_FOLDER=/opt/logs/100003171/[root@VM-0-8-centos config]# mkdir /opt/logs/100003171/
进入config文件夹,修改配置,具体配置如下:
[root@VM-0-8-centos config]# cd config/ [root@VM-0-8-centos config]# ls application-github.properties app.properties [root@VM-0-8-centos config]# cat application-github.properties # DataSource spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8 spring.datasource.username =username spring.datasource.password =password [root@VM-0-8-centos config]#
启动config-service:
[root@VM-0-8-centos config]# cd ../ [root@VM-0-8-centos config]# cd scripts/ [root@VM-0-8-centos scripts]# ls shutdown.sh startup.sh [root@VM-0-8-centos scripts]# sh startup.sh
admin-service和这个操作一样,就不演示了
portal操作:
[root@VM-0-8-centos apollo-start]# cd portal/ [root@VM-0-8-centos portal]# ls apollo-portal-1.7.1.jar apollo-portal-1.7.1-sources.jar apollo-portal.conf apollo-portal.jar apollo-portal_usrlocalapplicationapolloapollo-startportal.pid config scripts [root@VM-0-8-centos portal]# cat apollo-portal.conf MODE=service PID_FOLDER=. LOG_FOLDER=/opt/logs/100003173/[root@VM-0-8-centos portal]# cd config/ [root@VM-0-8-centos config]# ls apollo-env.properties application-github.properties app.properties [root@VM-0-8-centos config]# cat apollo-env.properties local.meta=http://localhost:8080 dev.meta=http://localhost:8080 #fat.meta=http://fill-in-fat-meta-server:8080 #uat.meta=http://fill-in-uat-meta-server:8080 #lpt.meta=${lpt_meta} #pro.meta=http://fill-in-pro-meta-server:8080 [root@VM-0-8-centos config]# cat application-github.properties # DataSource spring.datasource.url = jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8 spring.datasource.username = username spring.datasource.password =password
之后进去scripts文件夹启动
[root@VM-0-8-centos config]# cd ../ [root@VM-0-8-centos portal]# cd scripts/ [root@VM-0-8-centos scripts]# ls shutdown.sh startup.sh [root@VM-0-8-centos scripts]# sh startup.sh
5.Docker运行
运行apollo-configservice:
docker run -p 8080:8080 -e SPRING_DATASOURCE_URL="jdbc:mysql://localhost:3306/ApolloConfigDB_DEV?characterEncoding=utf8" -e SPRING_DATASOURCE_USERNAME=username -e SPRING_DATASOURCE_PASSWORD=password -d -v /tmp/logs:/opt/logs --name apollo-configservice apolloconfig/apollo-configservice
运行apollo-adminservice:
docker run -p 8090:8090 -e SPRING_DATASOURCE_URL="jdbc:mysql://localhost:3306/ApolloConfigDB_DEV?characterEncoding=utf8" -e SPRING_DATASOURCE_USERNAME=username -e SPRING_DATASOURCE_PASSWORD=password -d -v /tmp/logs:/opt/logs --name apollo-adminservice apolloconfig/apollo-adminservice
运行apollo-partal:
docker run -p 8070:8070 -e SPRING_DATASOURCE_URL="jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8" -e SPRING_DATASOURCE_USERNAME=username -e SPRING_DATASOURCE_PASSWORD=password -e APOLLO_PORTAL_ENVS=dev -e DEV_META=http://localhost:8070 -e -d -v /tmp/logs:/opt/logs --name apollo-portal apolloconfig/apollo-portal