ApacheDoris2.0rc4 使用docker快速部署

参照官方文档,使用docker-compose来启动。

官方文档:Build Docker Image – Apache Doris

步骤1:分别构建 FE、BE的docker镜像

由于新版 Doris2.0.0 下载地址将 FE、BE、Broker 等打包为一个文件,所以需下载后解压重新将各自文件进行打包即可。期待官网的文档更新

apache-doris-2.0.0-bin-x64
├── be
├── extensions
└── fe

创建 docker-build 目录用于编译镜像,目录结构参照官网如下:

docker-build/
├── be
│   ├── Dockerfile
│   └── resource
│       ├── be.tar.gz
│       └── init_be.sh
└── fe
    ├── Dockerfile
    └── resource
        ├── fe.tar.gz
        └── init_fe.sh

FE 的 Dockerfile 如下:

# 选择基础镜像
FROM openjdk:8u342-jdk

# 设置环境变量
ENV JAVA_HOME="/usr/local/openjdk-8/" \
    PATH="/opt/apache-doris/fe/bin:$PATH"

# 下载软件至镜像内,可根据需要替换
# apache-doris-2.0.0-bin-x64.tar.gz
ADD ./resource/fe.tar.gz /opt/

RUN apt-get update && \
    apt-get install -y default-mysql-client && \
    apt-get clean && \
    mkdir /opt/apache-doris && \
    cd /opt && \
    mv /opt/fe /opt/apache-doris/fe && \
    rm -rf /opt/fe.tar.gz

ADD ./resource/init_fe.sh /opt/apache-doris/fe/bin
RUN chmod 755 /opt/apache-doris/fe/bin/init_fe.sh

ENTRYPOINT ["/opt/apache-doris/fe/bin/init_fe.sh"]

其中 init_fe.sh 脚本内容:https://github.com/apache/doris/tree/master/docker/runtime/fe/resource/init_fe.sh

BE 的 Dockerfile 如下:

# Select the base image
FROM openjdk:8u342-jdk

# Set environment variables
ENV JAVA_HOME="/usr/local/openjdk-8/" \
    PATH="/opt/apache-doris/be/bin:$PATH"

# Download the software into the image (you can modify based on your own needs)
ADD ./resource/be.tar.gz /opt/

RUN apt-get update && \
    apt-get install -y default-mysql-client && \
    apt-get clean && \
    mkdir /opt/apache-doris && \
    cd /opt && \
    mv /opt/be /opt/apache-doris/be && \
    rm -rf /opt/be.tar.gz

ADD ./resource/init_be.sh /opt/apache-doris/be/bin
RUN chmod 755 /opt/apache-doris/be/bin/init_be.sh

ENTRYPOINT ["/opt/apache-doris/be/bin/init_be.sh"]

其中 init_be.sh 脚本内容:https://github.com/apache/doris/tree/master/docker/runtime/be/resource/init_be.sh

文件准备好后分别构建镜像

将如下${fe-tagName}替换为你喜欢的镜像名

# 构建 fe
cd ./docker-build/fe
docker build . -t ${fe-tagName}

# 构建 be
cd ./docker-build/be
docker build . -t ${be-tagName}

构建完成后,可以通过 docker images来查看

步骤2:使用docker-compose定义网络并启动

由于 Doris 需要指定网络ip进行关联,所以需要自定义docker网络。需要注意的是自定义的IP段不与本地IP段冲突即可。

docker-compose.yml 如下,可根据需要自己调整IP段及地址、目录挂载等

version: "3"
services:
  fe:
    image: doris-fe
    hostname: doris-fe
    container_name: "doris-fe"
    ports:
      - 8030:8030
      - 9030:9030
    environment:
      - FE_SERVERS=fe1:172.30.80.2:9010
      - FE_ID=1
    volumes:
      - /data/doris/fe_data/doris-meta:/opt/apache-doris/fe/doris-meta
      - /data/doris/fe_data/log:/opt/apache-doris/fe/log
    networks:
      doris_net:
        ipv4_address: 172.30.80.2
  be:
    image: doris-be
    hostname: doris-be
    container_name: "doris-be"
    ports:
      - 8040:8040
    environment:
      - MASTER_FE_IP=172.30.80.2
      - CURRENT_BE_IP=172.30.80.3
      - CURRENT_BE_PORT=9050
      - FE_SERVERS=fe1:172.30.80.2:9010
      - BE_ADDR=172.30.80.3:9050
      - PRIORITY_NETWORKS=172.30.80.0/24
    volumes:
      - /data/doris/be_data/storage:/opt/apache-doris/be/storage
      - /data/doris/be_data/log:/opt/apache-doris/be/log
      - /data/doris/be_data/script:/docker-entrypoint-initdb.d
     #- /data/doris/be/be.conf:/opt/apache-doris/be/conf/be.conf
    depends_on:
      - fe
    networks:
      doris_net:
        ipv4_address: 172.30.80.3
networks:
  doris_net:
    ipam:
      config:
      - subnet: "172.30.80.0/16"
Author: thinkwei

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注