以docker-compose方式部署apollo。最新版本:1.7.1
- 主机说明:
系统:CentOS 7.8 Meta Server/Config Service/Admin Service/Portal Server/MySQL 192.168.30.131
- 数据库准备:
首先部署mysql,创建用户并设置密码,这里是root
/123456789
。
cd /softwaregit clone https://github.com/ctripcorp/apollo.git mysql -uroot -p123456789 < apollo/scripts/sql/apolloportaldb.sql mysql -uroot -p123456789 < apollo/scripts/sql/apolloconfigdb.sql
- 部署:
vim docker-compose.yaml
version: '3.7'services: apollo-configservice: container_name: apollo-configservice image: apolloconfig/apollo-configservice volumes: - type: volume source: logs target: /opt/logs ports: - "8080" environment: - SPRING_DATASOURCE_URL=jdbc:mysql://192.168.30.131:3306/ApolloConfigDB?characterEncoding=utf8 - SPRING_DATASOURCE_USERNAME=root - SPRING_DATASOURCE_PASSWORD=123456789 restart: always network_mode: host apollo-adminservice: depends_on: - apollo-configservice container_name: apollo-adminservice image: apolloconfig/apollo-adminservice volumes: - type: volume source: logs target: /opt/logs ports: - "8090" environment: - SPRING_DATASOURCE_URL=jdbc:mysql://192.168.30.131:3306/ApolloConfigDB?characterEncoding=utf8 - SPRING_DATASOURCE_USERNAME=root - SPRING_DATASOURCE_PASSWORD=123456789 restart: always network_mode: host apollo-portal: depends_on: - apollo-adminservice container_name: apollo-portal image: apolloconfig/apollo-portal volumes: - type: volume source: logs target: /opt/logs ports: - "8070" environment: - SPRING_DATASOURCE_URL=jdbc:mysql://192.168.30.131:3306/ApolloPortalDB?characterEncoding=utf8 - SPRING_DATASOURCE_USERNAME=root - SPRING_DATASOURCE_PASSWORD=123456789 - APOLLO_PORTAL_ENVS=dev - DEV_META=http://192.168.30.131:8080 restart: always network_mode: hostvolumes: logs: driver: local driver_opts: type: none o: bind device: /tmp/logs
参数说明:
SPRING_DATASOURCE_URL: 对应环境ApolloPortalDB的地址 SPRING_DATASOURCE_USERNAME: 对应环境ApolloPortalDB的用户名 SPRING_DATASOURCE_PASSWORD: 对应环境ApolloPortalDB的密码 APOLLO_PORTAL_ENVS(可选): 对应ApolloPortalDB中的apollo.portal.envs配置项,如果没有在数据库中配置的话,可以通过此环境参数配置 DEV_META/PRO_META(可选): 配置对应环境的Meta Service地址,以${ENV}_META命名,如果ApolloPortalDB中配置了apollo.portal.meta.servers,则以apollo.portal.meta.servers中的配置为准
docker-compose up -d docker-compose ps Name Command State Ports -------------------------------------------------------------------------------------- apollo-adminservice /apollo-adminservice/scrip ... Up 0.0.0.0:8090->8090/tcp apollo-configservice /apollo-configservice/scri ... Up 0.0.0.0:8080->8080/tcp apollo-portal /apollo-portal/scripts/sta ... Up 0.0.0.0:8070->8070/tcp
- 访问ui:
访问192.168.30.131:8070
,账号/密码:apollo
/admin
。
docker-compose方式部署apollo完成。已存放至个人github:docker-compose