ubuntu18.04 docker-compose部署apollo

ubuntu18.04 docker-compose部署apollo

部署环境

apollo版本 v1.8.0
mysql版本 v5.7

一、docker部署mysql5.7

docker run --nam mysql -p 3306:3306 -v /root/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD="123456" -d mysql:5.7

1.apollo压缩包下载

cd /opt
wget http://github.com/apolloconfig/apollo/archive/refs/tags/v1.8.0.tar.gz
tar zxf v1.8.0.tar.gz

2.导入数据库并修改

mysql -uroot -p123456 -h127.0.0.1 < /opt/apollo-1.8.0/scripts/sql/apolloconfigdb.sql
mysql -uroot -p123456 -h127.0.0.1 < /opt/apollo-1.8.0/scripts/sql/apolloportaldb.sql
mysql -uroot -p123456 -h127.0.0.1
> update ApolloConfigDB.ServerConfig set Value = "http://9.x.x.x:8080/eureka/" where Id = 1;  #在数据库中执行此语句

二、创建docker-compose.yaml文件

version: "3"

services:
  apollo-configservice:
    container_name: apollo-configservice
    image: apolloconfig/apollo-configservice:1.8.1
    ports:
      - "8080:8080"
    volumes:
      - "./logs:/opt"
    environment:
      - spring_datasource_url=jdbc:mysql://10.8.0.191:3306/ApolloConfigDB?characterEncoding=utf8
      - spring_datasource_username=root
      - spring_datasource_password=123456
      - eureka.instance.ip-address=10.8.0.191 # 指定注册地址,不然客户端访问的是上面10.0.1.0/24的地址
  apollo-adminservice:
    container_name: apollo-adminservice
    image: apolloconfig/apollo-adminservice:1.8.1
    ports:
      - "8090:8090"
    depends_on:
      - apollo-configservice
    links:
      - apollo-configservice
    volumes:
      - "$PWD/logs/adminservice:/opt/logs/100003172"
    environment:
      - spring_datasource_url=jdbc:mysql://10.8.0.191:3306/ApolloConfigDB?characterEncoding=utf8
      - spring_datasource_username=root
      - spring_datasource_password=123456
      - eureka.instance.ip-address=10.8.0.191 # 指定注册地址,不然客户端访问的是上面10.0.1.0/24的地址
  apolo-portal:
    container_name: apollo-portal
    image: apolloconfig/apollo-portal:1.8.1
    ports:
      - "8070:8070"
    volumes:
      - "./logs:/opt"
    environment:
      - spring_datasource_url=jdbc:mysql://10.8.0.191:3306/ApolloPortalDB?characterEncoding=utf8
      - spring_datasource_username=root
      - spring_datasource_password=123456
      - apollo_portal_envs=dev    # 有多个环境可以支持多个
      - dev_meta=http://10.8.0.191:8080  # 有多个环境可以支持多个

运行

docker-compose up -d

浏览器访问

http://apollo主机IP:8070

ubuntu18.04 docker-compose部署apollo_第1张图片

默认账号密码

apollo
admin

你可能感兴趣的:(docker,spring,cloud,微服务)