[容器化技术] 使用docker-compose搭建doris本地测试环境

环境概述

系统 : mac os
芯片 : m2
芯片架构 : arm64 (可以通过uname -a 来查看)
doris版本 : 1.2.2
docker集群的分布

名称ip
doris-fe1-01172.20.80.2
doris-fe1-02172.20.80.3
doris-fe1-03172.20.80.4
doris-be1-01172.20.80.5
doris-fe1-02172.20.80.6
doris-fe1-03172.20.80.7

端口
image.png

编写docker compose文件

mkdir -p ~/docker/doris_3fe_3be
cd ~/docker/doris_3fe_3be
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
version: '3'
services:
  docker-fe-01:
    image: "apache/doris:1.2.2-fe-arm"
    container_name: "doris-fe-01"
    hostname: "fe-01"
    environment:
      - FE_SERVERS=fe1:172.20.80.2:9010,fe2:172.20.80.3:9010,fe3:172.20.80.4:9010
      - FE_ID=1
    ports:
      - 8031:8030
      - 9031:9030
    volumes:
      - ~/docker/doris_3fe_3be/data/fe-01/doris-meta:/opt/apache-doris/fe/doris-meta
      - ~/docker/doris_3fe_3be/data/fe-01/conf:/opt/apache-doris/fe/conf
      - ~/docker/doris_3fe_3be/data/fe-01/log:/opt/apache-doris/fe/log
    networks:
      doris_net:
        ipv4_address: 172.20.80.2
  docker-fe-02:
    image: "apache/doris:1.2.2-fe-arm"
    container_name: "doris-fe-02"
    hostname: "fe-02"
    environment:
      - FE_SERVERS=fe1:172.20.80.2:9010,fe2:172.20.80.3:9010,fe3:172.20.80.4:9010
      - FE_ID=2
    ports:
      - 8032:8030
      - 9032:9030
    volumes:
      - ~/docker/doris_3fe_3be/data/fe-02/doris-meta:/opt/apache-doris/fe/doris-meta
      - ~/docker/doris_3fe_3be/data/fe-02/conf:/opt/apache-doris/fe/conf
      - ~/docker/doris_3fe_3be/data/fe-02/log:/opt/apache-doris/fe/log
    networks:
      doris_net:
        ipv4_address: 172.20.80.3
  docker-fe-03:
    image: "apache/doris:1.2.2-fe-arm"
    container_name: "doris-fe-03"
    hostname: "fe-03"
    environment:
      - FE_SERVERS=fe1:172.20.80.2:9010,fe2:172.20.80.3:9010,fe3:172.20.80.4:9010
      - FE_ID=3
    ports:
      - 8033:8030
      - 9033:9030
    volumes:
      - ~/docker/doris_3fe_3be/data/fe-03/doris-meta:/opt/apache-doris/fe/doris-meta
      - ~/docker/doris_3fe_3be/data/fe-03/conf:/opt/apache-doris/fe/conf
      - ~/docker/doris_3fe_3be/data/fe-03/log:/opt/apache-doris/fe/log
    networks:
      doris_net:
        ipv4_address: 172.20.80.4
  docker-be-01:
    image: "apache/doris:1.2.2-be-arm"
    container_name: "doris-be-01"
    hostname: "be-01"
    depends_on:
      - docker-fe-01
      - docker-fe-02
      - docker-fe-03
    environment:
      - FE_SERVERS=fe1:172.20.80.2:9010,fe2:172.20.80.3:9010,fe3:172.20.80.4:9010
      - BE_ADDR=172.20.80.5:9050
    ports:
      - 8041:8040
    volumes:
      - ~/docker/doris_3fe_3be/data/be-01/storage:/opt/apache-doris/be/storage
      - ~/docker/doris_3fe_3be/data/be-01/conf:/opt/apache-doris/be/conf
      - ~/docker/doris_3fe_3be/data/be-01/script:/docker-entrypoint-initdb.d
      - ~/docker/doris_3fe_3be/data/be-01/log:/opt/apache-doris/be/log
    networks:
      doris_net:
        ipv4_address: 172.20.80.5
  docker-be-02:
    image: "apache/doris:1.2.2-be-arm"
    container_name: "doris-be-02"
    hostname: "be-02"
    depends_on:
      - docker-fe-01
      - docker-fe-02
      - docker-fe-03
    environment:
      - FE_SERVERS=fe1:172.20.80.2:9010,fe2:172.20.80.3:9010,fe3:172.20.80.4:9010
      - BE_ADDR=172.20.80.6:9050
    ports:
      - 8042:8040
    volumes:
      - ~/docker/doris_3fe_3be/data/be-02/storage:/opt/apache-doris/be/storage
      - ~/docker/doris_3fe_3be/data/be-02/conf:/opt/apache-doris/be/conf
      - ~/docker/doris_3fe_3be/data/be-02/script:/docker-entrypoint-initdb.d
      - ~/docker/doris_3fe_3be/data/be-02/log:/opt/apache-doris/be/log
    networks:
      doris_net:
        ipv4_address: 172.20.80.6
  docker-be-03:
    image: "apache/doris:1.2.2-be-arm"
    container_name: "doris-be-03"
    hostname: "be-03"
    depends_on:
      - docker-fe-01
      - docker-fe-02
      - docker-fe-03
    environment:
      - FE_SERVERS=fe1:172.20.80.2:9010,fe2:172.20.80.3:9010,fe3:172.20.80.4:9010
      - BE_ADDR=172.20.80.7:9050
    ports:
      - 8043:8040
    volumes:
      - ~/docker/doris_3fe_3be/data/be-03/storage:/opt/apache-doris/be/storage
      - ~/docker/doris_3fe_3be/data/be-03/conf:/opt/apache-doris/be/conf
      - ~/docker/doris_3fe_3be/data/be-03/script:/docker-entrypoint-initdb.d
      - ~/docker/doris_3fe_3be/data/be-03/log:/opt/apache-doris/be/log
    networks:
      doris_net:
        ipv4_address: 172.20.80.7
networks:
  doris_net:
    ipam:
      config:
        - subnet: 172.20.80.0/16

使用

在docker-compose.yaml同级目录下使用命令启动容器

docker-compose up -d

通过浏览器访问 : 127.0.0.1:9031 账号root 密码为空直接回车即可
以下是容器对宿主机映射出来的端口,通过这些端口可以访问到容器内
image.png
也可以使用命令行访问,such as

mysql -h 127.0.0.1 -P 9031 -uroot

注意

启动前必须修改的一个环境参数

MacOS 由于内部实现容器的方式不同,在部署时宿主机直接修改 max_map_count 值可能无法成功,需要先创建以下容器:

docker run -it --privileged --pid=host --name=change_count debian nsenter -t 1 -m -u -n -i sh

容器创建成功执行以下命令:
sysctl -w vm.max_map_count=2000000
然后 exit 退出,创建 Doris Docker 集群。
这里是官网的描述 : https://doris.apache.org/zh-CN/docs/dev/install/construct-docker/run-docker-cluster

docker 宿主机ping不通容器

我们在代码中开发过程中可能会用到容器的ip地址,例如上面的172.20.80.0/24这个网段,但是你会发现你是ping不通的,这里设计到了一些docker网络的一些知识,可以在网上看一下资料,这里只给出解决方法
安装路由转发镜像

# 现在连接器
brew install wenjunxiao/brew/docker-connector
# 加入路由
docker network ls --filter driver=bridge --format "{{.ID}}" | xargs docker network inspect --format "route {{range .IPAM.Config}}{{.Subnet}}{{end}}" >> /opt/homebrew/etc/docker-connector.conf
# 启动路由器
sudo /opt/homebrew/opt/docker-connector/bin/docker-connector -config /opt/homebrew/etc/docker-connector.conf
# 启动镜像
docker run -it -d --restart always --net host --cap-add NET_ADMIN --name connector wenjunxiao/mac-docker-connector

如果还是ping不通就重启一下上面的转发容器

参考文章

doris 官网 : https://doris.apache.org/
docker 宿主机ping不通容器 : https://www.haoyizebo.com/posts/fd0b9bd8/#docker-connector
docker


欢迎大家添加我的个人微信,有关大数据的问题一起讨论
微信号:AntgCode

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Antgeek

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值