apollo单环境安装,分布式安装,可参考https://github.com/ctripcorp/apollo/wiki/%E5%88%86%E5%B8%83%E5%BC%8F%E9%83%A8%E7%BD%B2%E6%8C%87%E5%8D%97#2-apolloportalmetaservers—%E5%90%84%E7%8E%AF%E5%A2%83meta-service%E5%88%97%E8%A1%A8
实验环境说明
两个环境 dev 和 prod
IP | 环境 | 安装组件 |
---|---|---|
192.168.11.210 | dev | configservice \ adminservice \ portal \ mysql(configdb,portaldb) |
192.168.11.211 | prod | configservice \ adminservice \ mysql (configdb) |
一、安装前准备
下载相关的docker images
docker pull mysql:5.7
docker pull apolloconfig/apollo-configservice:1.7.1
docker pull apolloconfig/apollo-adminservice:1.7.1
docker pull apolloconfig/apollo-portal:1.7.1
#下载初始化sql
mkdir /data/apollo/sql -p
cd /data/apollo/sql
wget https://raw.githubusercontent.com/ctripcorp/apollo/master/scripts/sql/apolloconfigdb.sql
wget https://raw.githubusercontent.com/ctripcorp/apollo/master/scripts/sql/apolloportaldb.sql
以下是192.168.11.211的服务器上操作(生产环境)
1、安装mysql 5.7
mkdir -p /data/apollo/
#!/bin/bash
docker run --name apollo-mysql-server -t \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD="password" \
-v /data/apollo/mysql/data:/var/lib/mysql \
-v /etc/localtime:/etc/localtime:ro \
--restart=always \
-d mysql:5.7 \
--character-set-server=utf8 \
--collation-server=utf8_bin
授权
docker exec -it apollo-mysql-server mysql -uroot -ppassword
grant all privileges on ApolloConfigDB.* to 'ApolloConfigDB'@'%' identified by 'ApolloConfigDB';
grant all privileges on ApolloPortalDB.* to 'ApolloPortalDB'@'%' identified by 'ApolloPortalDB';
flush privileges;
source apolloconfigdb.sql
source apolloportaldb.sql
2、 apollo-configservice 安装
docker run \
-p 18080:8080 \
--network host \
--restart=always \
-v /etc/localtime:/etc/localtime:ro \
-e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.11.211:3306/ApolloConfigDB?characterEncoding=utf8" \
-e SPRING_DATASOURCE_USERNAME=ApolloConfigDB -e SPRING_DATASOURCE_PASSWORD=ApolloConfigDB \
-d -v /data/apollo/configservice-logs:/opt/logs --name apollo-configservice apolloconfig/apollo-configservice:1.7.1
3、apollo-adminservice 安装
docker run \
-p 8090:8090 \
--network host \
-e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.11.211:3306/ApolloConfigDB?characterEncoding=utf8" \
-e SPRING_DATASOURCE_USERNAME=ApolloConfigDB -e SPRING_DATASOURCE_PASSWORD=ApolloConfigDB \
-d -v /data/apollo/adminservice-logs:/opt/logs --name apollo-adminservice apolloconfig/apollo-adminservice:1.7.1
4、pollo-portal安装
docker run \
-p 8070:8070 \
--network host \
-e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.11.211:3306/ApolloPortalDB?characterEncoding=utf8" \
-e SPRING_DATASOURCE_USERNAME=ApolloPortalDB -e SPRING_DATASOURCE_PASSWORD=ApolloPortalDB \
-e APOLLO_PORTAL_ENVS=dev,pro \
-e DEV_META=http://192.168.11.210:8080 -e PRO_META=http://192.168.11.211:8080 \
-d -v /data/apollo/portal-logs:/opt/logs --name apollo-portal apolloconfig/apollo-portal:1.7.1
以下的192.168.11.210的操作(开发环境)
1、安装mysql 5.7
mkdir -p /data/apollo/
#!/bin/bash
docker run --name apollo-mysql-server -t \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD="password" \
-v /data/apollo/mysql/data:/var/lib/mysql \
-v /etc/localtime:/etc/localtime:ro \
--restart=always \
-d mysql:5.7 \
--character-set-server=utf8 \
--collation-server=utf8_bin
授权
docker exec -it apollo-mysql-server mysql -uroot -ppassword
grant all privileges on ApolloConfigDB.* to 'ApolloConfigDB'@'%' identified by 'ApolloConfigDB';
flush privileges;
source apolloconfigdb.sql
2、 apollo-configservice 安装
docker run \
-p 18080:8080 \
--network host \
--restart=always \
-v /etc/localtime:/etc/localtime:ro \
-e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.11.210:3306/ApolloConfigDB?characterEncoding=utf8" \
-e SPRING_DATASOURCE_USERNAME=ApolloConfigDB -e SPRING_DATASOURCE_PASSWORD=ApolloConfigDB \
-d -v /data/apollo/configservice-logs:/opt/logs --name apollo-configservice apolloconfig/apollo-configservice:1.7.1
3、apollo-adminservice 安装
docker run \
-p 8090:8090 \
--network host \
-e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.11.210:3306/ApolloConfigDB?characterEncoding=utf8" \
-e SPRING_DATASOURCE_USERNAME=ApolloConfigDB -e SPRING_DATASOURCE_PASSWORD=ApolloConfigDB \
-d -v /data/apollo/adminservice-logs:/opt/logs --name apollo-adminservice apolloconfig/apollo-adminservice:1.7.1
三、验证安装
http://192.168.11.211:8070
帐号:apollo 密码:admin
四、使用
修改部门名称
管理员工具–>系统参数
查询:organizations
[{“orgId”:“JG”,“orgName”:“总体架构部”},{“orgId”:“CY”,“orgName”:“产品研发部”}]