?
文章目录
-
- 环境准备
- 安装docker
- 单机
-
- 安装docker-compose
- 获取代码
- 启动
- 高可用
-
- 安装mysql
- 创建数据库
- 调整服务端配置
- 配置/etc/hosts
- 部署Apollo Config Service
- 部署Apollo Admin Service
- 部署Apollo Portal
?
环境准备
节点名称 | ip地址 |
---|---|
node1 | 192.168.130.19 |
node2 | 192.168.130.21 |
安装docker
略
单机
安装docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
获取代码
yum install git -y
git clone https://github.com/ctripcorp/apollo.git
cd apollo
git checkout 1.7.1
启动
cd scripts/docker-quick-start/
docker-compose up
高可用
安装mysql
参考xx
创建数据库
创建ApolloConfigDB和ApolloPortalDB数据库,如果有多个环境需创建多套ApolloConfigDB,这里只创建一套开发环境。不管有几套环境ApolloPortalDB只需要一套。
config sql脚本:https://raw.githubusercontent.com/ctripcorp/apollo/1.7.1/scripts/sql/apolloconfigdb.sql
portal sql脚本:https://raw.githubusercontent.com/ctripcorp/apollo/1.7.1/scripts/sql/apolloportaldb.sql
调整服务端配置
- ApolloPortalDB.ServerConfig表
apollo.portal.envs - 可支持的环境列表
value内容修改为dev - ApolloConfigDB.ServerConfig表
eureka.service.url - Eureka服务Url
value内容修改为http://apollo-node1:18080/eureka/,http://apollo-node2:18080/eureka/
配置/etc/hosts
192.168.130.19 kont002ecs rq-node2 apollo-node1
192.168.130.21 kont003ecs rq-node3 apollo-node2
部署Apollo Config Service
node1 node2
mkdir -p /root/apollo/configservice/logs
node1
docker rm -f apollo-configservice-node1
docker run -d --name apollo-configservice-node1 --add-host apollo-node1:192.168.130.20 --add-host apollo-node2:192.168.130.19 -p 18080:8080 -e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.130.22:3306/ApolloConfigDB?characterEncoding=utf8" -e SPRING_DATASOURCE_USERNAME=root -e SPRING_DATASOURCE_PASSWORD=kont -e eureka.instance.home-page-url=http://apollo-node1:18080 -v /root/apollo/configservice/logs:/opt/logs apolloconfig/apollo-configservice:1.7.1
node2
docker rm -f apollo-configservice-node2
docker run -d --name apollo-configservice-node2 --add-host apollo-node1:192.168.130.20 --add-host apollo-node2:192.168.130.19 -p 18080:8080 -e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.130.22:3306/ApolloConfigDB?characterEncoding=utf8" -e SPRING_DATASOURCE_USERNAME=root -e SPRING_DATASOURCE_PASSWORD=kont -e eureka.instance.home-page-url=http://apollo-node2:18080 -v /root/apollo/configservice/logs:/opt/logs apolloconfig/apollo-configservice:1.7.1
部署Apollo Admin Service
node1 node2
mkdir -p /root/apollo/adminservice/logs
node1
docker rm -f apollo-adminservice-node1
docker run -d --name apollo-adminservice-node1 --add-host apollo-node1:192.168.130.20 --add-host apollo-node2:192.168.130.19 -p 18090:8090 -e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.130.22:3306/ApolloConfigDB?characterEncoding=utf8" -e SPRING_DATASOURCE_USERNAME=root -e SPRING_DATASOURCE_PASSWORD=kont -e eureka.instance.home-page-url=http://apollo-node1:18090 -v /root/apollo/configservice/logs:/opt/logs apolloconfig/apollo-adminservice:1.7.1
node2
docker rm -f apollo-adminservice-node2
docker run -d --name apollo-adminservice-node2 --add-host apollo-node1:192.168.130.20 --add-host apollo-node2:192.168.130.19 -p 18090:8090 -e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.130.22:3306/ApolloConfigDB?characterEncoding=utf8" -e SPRING_DATASOURCE_USERNAME=root -e SPRING_DATASOURCE_PASSWORD=kont -e eureka.instance.home-page-url=http://apollo-node2:18090 -v /root/apollo/configservice/logs:/opt/logs apolloconfig/apollo-adminservice:1.7.1
部署Apollo Portal
node1 、node2
mkdir -p /root/apollo/portal/logs
node1
docker rm -f apollo-portal-node1
docker run -d --name apollo-portal-node1 --add-host apollo-node1:192.168.130.20 --add-host apollo-node2:192.168.130.19 -p 8070:8070 -e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.130.22:3306/ApolloPortalDB?characterEncoding=utf8" -e SPRING_DATASOURCE_USERNAME=root -e SPRING_DATASOURCE_PASSWORD=kont -e APOLLO_PORTAL_ENVS=dev -e DEV_META=http://apollo-node1:18080,http://apollo-node2:18080 -v /root/apollo/portal/logs:/opt/logs apolloconfig/apollo-portal:1.7.1
node2
docker rm -f apollo-portal-node2
docker run -d --name apollo-portal-node2 --add-host apollo-node1:192.168.130.20 --add-host apollo-node2:192.168.130.19 -p 8070:8070 -e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.130.22:3306/ApolloPortalDB?characterEncoding=utf8" -e SPRING_DATASOURCE_USERNAME=root -e SPRING_DATASOURCE_PASSWORD=kont -e APOLLO_PORTAL_ENVS=dev -e DEV_META=http://apollo-node1:18080,http://apollo-node2:18080 -v /root/apollo/portal/logs:/opt/logs apolloconfig/apollo-portal:1.7.1
可以在前面再加个lb做负载
?