1. 安装docker

详情请参见本人博客

2. 编译doris

详情请参见doris官网文档

3. 在编译好的doris output文件夹下编写两个Dockerfile

3.1  Dockerfile_fe

FROM centos:centos7.5.1804

RUN mkdir /home/palo/run/ -p

# copy jdk and palo binary
COPY jdk1..0_131/ /home/palo/run/jdk1..0_131/
COPY fe/ /home/palo/run/fe/ # set java home
ENV JAVA_HOME /home/palo/run/jdk1..0_131/ # set fe port: http/thrift/mysql/bdbje
EXPOSE # fe log and meta-data
VOLUME ["/home/palo/run/fe/conf" i"/home/palo/run/fe/log" "/home/palo/run/fe/palo-meta"] WORKDIR /home/palo/run/fe/ CMD ["/bin/sh","/home/palo/run/fe/bin/start_fe.sh"]

3.2 Dockerfile_be

Centos 7 be docker file

FROM centos:centos7.5.1804
#FROM ubuntu:18.04 RUN mkdir -p /home/palo/run/ RUN yum -y update \
&& yum install -y binutils-devel \
&& yum -y clean all \
&& rm -rf /var/cache/yum # copy be
COPY be/ /home/palo/run/be/ # set be port: thrift/rpc/http/heartbeat
EXPOSE # be log,conf and data
VOLUME ["/home/palo/run/be/conf", "/home/palo/run/be/log", "/home/palo/run/be/data/"] WORKDIR /home/palo/run/be/
RUN ldd lib/palo_be CMD ["/bin/sh","/home/palo/run/be/bin/start_be.sh"]

Ununtu 18.04 be docker file

FROM ubuntu:18.04

RUN  mkdir -p /home/palo/run/    

RUN apt-get -y update \
&& apt-get install -y libbinutils \
&& apt-get -y clean all \
&& rm -rf /var/cache/yum
#set the shell command from dash (which is the default shell application in ubuntu) to
#bash which doris start command used.
&& ln -sf /bin/bash /bin/sh # copy be
COPY be/ /home/palo/run/be/ # set be port: thrift/rpc/http/heartbeat
EXPOSE # fe log and meta-data
VOLUME ["/home/palo/run/be/conf", "/home/palo/run/be/log", "/home/palo/run/be/data/"] WORKDIR /home/palo/run/be/
RUN ldd lib/palo_be CMD ["/bin/sh","/home/palo/run/be/bin/start_be.sh"]

Note: if build the  binary files of be using ubuntu 18.04, and build  the docker image using centos, because the ubuntu glibc version 2.27 and the centos 7 glibc version is lower than this ( currently, the highest version is 2.17), and this would cause the be process

is unable to start with error message:

start time: Sat Apr  :: CST
/home/palo/run/be/lib/palo_be: error while loading shared libraries: libbfd-2.30-system.so: cannot open shared object file: No such file or directory

so it's nassary to make sure the be build glic version is compatable with the target images os version. And this is why I used two docker file to build  the be docker image.

In summery:

if you build the doris be in centos, it's better to build the docker images in based on centos; and vice, it you build the binary on ubuntu, it's better to build the docker  image based on ubuntu. In order to make glibc version compatable.

4. 制作docker镜像

4.1 下载jdk1.8.0_131.tar.gz到 output文件夹下并解压,具体可以到oracle官网下载

文件准备完成后的目录结构为

[druid@doris output]$ ls -l
total
drwxr-xr-x druid druid Apr : apache_hdfs_broker
drwxr-xr-x druid druid Apr : be
-rw-rw-r-- druid druid Apr : Dockerfile_be
-rw-rw-r-- druid druid Apr : Dockerfile_fe
drwxr-xr-x druid druid Apr : fe
drwxr-xr-x druid druid Mar jdk1..0_131

4.2 制作fe镜像

[druid@palo output]$ sudo docker build -t lenmom/doris:fe-0.9.0 -f Dockerfile_fe  .
[sudo] password for druid:
Sending build context to Docker daemon .027GB
Step / : FROM centos:centos7.5.1804
---> cf49811e3cdb
Step / : RUN mkdir /home/palo/run/ -p
---> Using cache
---> ffe6e7a05650
Step / : COPY jdk1..0_131/ /home/palo/run/jdk1..0_131/
---> a0b9c437e9f7
Step / : COPY fe/ /home/palo/run/fe/
---> a7706aa9939b
Step / : ENV JAVA_HOME /home/palo/run/jdk1..0_131/
---> Running in bd436cb488d5
Removing intermediate container bd436cb488d5
---> 9e10bc76f4b5
Step / : EXPOSE
---> Running in de0d71ee1f27
Removing intermediate container de0d71ee1f27
---> 16600856447f
Step / : WORKDIR /home/palo/run/fe/
---> Running in 2cfe3e4bc04e
Removing intermediate container 2cfe3e4bc04e
---> fc999dfbc914
Step / : CMD "bin/start_fe.sh"
---> Running in fafb6d98095d
Removing intermediate container fafb6d98095d
---> 62efbd2bbea0
Successfully built 62efbd2bbea0
Successfully tagged doris:fe-0.9.

4.3 制作be镜像

[druid@palo output]$ sudo docker build -t lenmom/doris:be-0.9.0 -f Dockerfile_be  .
Sending build context to Docker daemon .163GB
Step / : FROM centos:centos7.5.1804
---> cf49811e3cdb
Step / : RUN mkdir /home/palo/run/ -p
---> Running in 2ae7543e4f3a
Removing intermediate container 2ae7543e4f3a
---> 635d3dd01e5b
Step / : COPY be/ /home/palo/run/be/
---> 825e46597c07
Step / : EXPOSE
---> Running in 21e7742b6da5
Removing intermediate container 21e7742b6da5
---> c735c437a771
Step / : VOLUME ["/home/palo/run/be/conf", "/home/palo/run/be/log", "/home/palo/run/be/data/"]
---> Running in 456c4f54c79a
Removing intermediate container 456c4f54c79a
---> 392386745a0a
Step / : WORKDIR /home/palo/run/be/
---> Running in eac0b97ffdba
Removing intermediate container eac0b97ffdba
---> a488181610ba
Step / : CMD "bin/start_be.sh"
---> Running in 871bee0625c6
Removing intermediate container 871bee0625c6
---> cf8f3297619a
Successfully built cf8f3297619a
Successfully tagged lenmom/doris:be-0.9.

4.4 查看镜像信息

[druid@palo output]$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
lenmom/doris fe-0.9. ecd903182693 minutes ago 649MB
lenmom/doris be-0.9. cf8f3297619a minutes ago 855MB
centos centos7.5.1804 cf49811e3cdb weeks ago 200MB

5. 导出镜像与上传镜像

5.1 导出镜像到本地

#命令格式:
#docker save -o 要保存的文件名 要保存的镜像
sudo docker save -o doris-fe-0.9.-docker.img lenmom/doris:fe-0.9. #导出fe镜像到本地,默认导出到当前目录,可以指定完整参数
sudo docker save -o doris-be-0.9.-docker.img lenmom/doris:be-0.9. #导出be镜像到本地,默认导出到当前目录,可以指定完整参数

导出后的结果看下图:

5.2 导入镜像

使用5.1中导出的镜像,可以在其他机器的部署环境中,使用load命令导入镜像,直接使用即可

#命令格式:
sudo docker load --input 文件
#或者
sudo docker load < 文件名

针对本例中的两个镜像文件,操作命令为:

sudo docker load --input  doris-be-0.9.-docker.img #导入be镜像
sudo docker load --input doris-fe-0.9.-docker.img #导入fe镜像

5.3 上传镜像

命令格式为:   docker push NAME[:TAG]

注意:如果为个人注册的docker hub账号,一定要在镜像名称前面加上自己的docker hub用户名,否则提交上传会失败,出现类似下面的错误

Error response from daemon: pull access denied for xxx, repository does not exist or may require 'docker login'

上传镜像前,需要使用自己的docker hub账号登陆,然后才可以上传镜像文件,下面来操作一个波次看看

5.1 登陆docker hub

输入sudo docker login,然后输入用户名,密码即可。

[druid@palo output]$ sudo docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: {YOUR-DOCKER-HUB-ID}
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded

5.2 不带用户名的镜像上传会失败

修改lenmom/doris:be-0.9.0镜像名称为doris:be-0.9.0,即去掉签名的用户id,修改之前的镜像列表为

$sudo docker tag lenmom/doris:be-0.9. doris:be-0.9.    #创建不带用户id的镜像别名
$sudo docker rmi lenmom/doris:be-0.9. #删除带用户id的镜像
Untagged: lenmom/doris:be-0.9.
$sudo docker images #查看镜像列表,带用户id的be镜像应该消失了
REPOSITORY TAG IMAGE ID CREATED SIZE
lenmom/doris fe-0.9. ecd903182693 minutes ago 649MB
doris be-0.9. cf8f3297619a About an hour ago 855MB
centos centos7.5.1804 cf49811e3cdb weeks ago 200MB

现在上传该镜像,上传应该会失败

$sudo docker push  doris:be-0.9.
Error response from daemon: pull access denied for doris, repository does not exist or may require 'docker login'

失败的原因是定位仓库的时候发现没有doris仓库,如果镜像带有用户id,那么默认的仓库是/id/tagname。

5.3 上传带用户id的镜像

[druid@palo194 output]$ sudo docker tag doris:be-0.9. lenmom/doris:0.9.  #添加带用户id的镜像名称
[sudo] password for druid:
[druid@palo194 output]$ sudo docker rmi doris:be-0.9. #删除不带用户id的镜像名称
Untagged: doris:be-0.9.
[druid@palo194 output]$ sudo docker images #查看镜像列表
REPOSITORY TAG IMAGE ID CREATED SIZE
lenmom/doris fe-0.9. ecd903182693 About an hour ago 649MB
lenmom/doris be-0.9. cf8f3297619a About an hour ago 855MB
centos centos7.5.1804 cf49811e3cdb weeks ago 200MB
[druid@palo194 output]$ sudo docker push lenmom/doris:be-0.9.0 #上传带用户id的镜像,上传成功
The push refers to repository [docker.io/lenmom/doris]
270d8b1169bb: Preparing
1d301fa1efc4: Preparing
4826cdadf1ef: Preparing

能够上传成功关键在docker.io/lenmom/doris,docker就是靠用户id来定位仓库地址的!!

6. 通过docker来使用制作好的镜像

6.1 启动fe容器

sudo docker run  --name doris-fe -p : -p : -p : -p : \
-v /home/lenmom/workspace/software/doris-docker-master/fe/log:/home/palo/run/fe/log \
-v /home/lenmom/workspace/software/doris-docker-master/fe/palo-meta:/home/palo/run/fe/palo-meta \
-v /home/lenmom/workspace/software/doris-docker-master/fe/conf:/home/palo/run/fe/conf/ \
--link doris-be \
-v /etc/localtime:/etc/localtime:ro lenmom/doris:fe-0.9.

Note:  this create a docker container named doris-fe, after the start up ,we can see the results in the directory, and if we want to operate the be node to setup a cluster, we should start up the be node first, because to set up a cluster, the fe node need to know the be's ip address and vice not(because the fe would send the it's address to be during the hearbeat process. This is why we add the -link to container instance of doris-be!

and you can start a mysql container with a link to the doris-fe container  just started to operate the  fe instance.

sudo docker run -it  --name mysql  --link doris-fe  mysql:5.7  /bin/bash

when the mysql container started, we can login the  doris-fe in inside the mysql container:

root@d4df95bc2460:/# mysql -h doris-fe -P  -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.1. Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
row in set (0.03 sec) mysql> clear
mysql> exit
Bye
root@d4df95bc2460:/# exit

6.2 启动be容器

sudo docker run  -d --name doris-be -p : -p : -p : -p : \
-v /home/lenmom/workspace/software/doris-docker-master/be/log:/home/palo/run/be/log \
-v /home/lenmom/workspace/software/doris-docker-master/be/storage:/home/palo/run/be/data \
-v /home/lenmom/workspace/software/doris-docker-master/be/conf:/home/palo/run/be/conf/ \
-v /etc/localtime:/etc/localtime:ro \
lenmom/doris:be-0.9.0

and if we can go into the doris-be container using command

sudo docker exec -it doris-be bash

after enter  the container, we can see the be instance has been launched now.

6.3 set up cluster

sudo docker run -it  --name mysql  --link doris-fe  mysql:5.7  /bin/bash

after the mysql instance started, we would enter the shell terminal, then login doris-fe using mysql-client

lenmom@M1701:~/workspace/software/doris-docker-master/fe$ sudo docker run -it  --rm --name mysql  -p :  -e MYSQL_ROOT_PASSWORD=root \
> -v /home/lenmom/workspace/software/mysql:/var/lib/mysql \
> -v /home/lenmom/workspace/software/mysql/mysql-conf/mysql:/etc/mysql \
> --link doris-fe \
> mysql:5.7 bash
[sudo] password for lenmom:
root@dcc6e94ab15b:/# mysql -h doris-fe -P -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.1. Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show frontends;
+-------------------------------+------------+-------------+----------+-----------+---------+----------+----------+------------+------+-------+-------------------+---------------------+----------+--------+
| Name | IP | EditLogPort | HttpPort | QueryPort | RpcPort | Role | IsMaster | ClusterId | Join | Alive | ReplayedJournalId | LastHeartbeat | IsHelper | ErrMsg |
+-------------------------------+------------+-------------+----------+-----------+---------+----------+----------+------------+------+-------+-------------------+---------------------+----------+--------+
| 172.17..3_9010_1555911447430 | 172.17.0.3 | | | | | FOLLOWER | true | | true | true | | -- :: | true | |
+-------------------------------+------------+-------------+----------+-----------+---------+----------+----------+------------+------+-------+-------------------+---------------------+----------+--------+
row in set (0.03 sec) mysql> show backends;
Empty set (0.01 sec) mysql> alter system add backend 'doris-be:9050';
Query OK, rows affected (0.02 sec) mysql> show backends;
+-----------+-----------------+------------+---------------+--------+----------+----------+---------------------+---------------------+-------+----------------------+-----------------------+-----------+------------------+---------------+---------------+---------+--------+
| BackendId | Cluster | IP | HeartbeatPort | BePort | HttpPort | BrpcPort | LastStartTime | LastHeartbeat | Alive | SystemDecommissioned | ClusterDecommissioned | TabletNum | DataUsedCapacity | AvailCapacity | TotalCapacity | UsedPct | ErrMsg |
+-----------+-----------------+------------+---------------+--------+----------+----------+---------------------+---------------------+-------+----------------------+-----------------------+-----------+------------------+---------------+---------------+---------+--------+
| | default_cluster | 172.17.0.2 | | | | | -- :: | -- :: | true | false | false | | . | 22.826 GB | 70.115 GB | 67.45 % | |
+-----------+-----------------+------------+---------------+--------+----------+----------+---------------------+---------------------+-------+----------------------+-----------------------+-----------+------------------+---------------+---------------+---------+--------+
row in set (0.00 sec) mysql>

Here, we have set up a cluster using the doris-fe and doris-be container instance which has just launched and you can can docker-compose or docker-swarm to set up more instacnes of nodes and setting up clusters based on docker.

Notes: if we want to login  fe docker container in the host machine using mysql-client, we should make sure the mysql client is less than 8.*, or else ,we may get the error message when login 127.0.0.1 on  the docker host via mysql-client.

mysql -h 127.0.0.1 -P  -uroot -p
Enter password:
ERROR (): Access denied for user 'root' (using password: YES)

notes:

a). we can launch multiple be instance to set multiple be instance cluster using docker container.

b). Do make sure the host mahine's mysql-client version is less than 8.0* if we want to login the fe docker instance via mysql-client on the docker host machine.

c). The be docker instance should be launched before the  fe docker instance, because when set up cluster via fe,the fe need to be aware of the existance of the be docker instacne.

d)  when launch the fe docker instance, all the be docker instance should be linked by the fe docker instance. 

Have fun with doris!

doris 0.9.0版本docker镜像制作与使用的更多相关文章

  1. MySQL、MongoDB、Redis数据库Docker镜像制作

    MySQL.MongoDB.Redis数据库Docker镜像制作 在多台主机上进行数据库部署时,如果使用传统的MySQL的交互式的安装方式将会重复很多遍.如果做成镜像,那么我们只需要make once ...

  2. 《Docekr入门学习篇》——Docker镜像制作

    Docker镜像制作 Docker镜像的构建分为两种,一种是手动构建,一种是dockerfile(自动构建) 手动构建 基于centos镜像进行构建制作Nginx镜像 [root@rbtnode1 ~ ...

  3. Docker 镜像制作教程:针对不同语言的精简策略

    本系列文章将分为三个部分: 第一部分着重介绍多阶段构建(multi-stage builds),因为这是镜像精简之路至关重要的一环.在这部分内容中,我会解释静态链接和动态链接的区别,它们对镜像带来的影 ...

  4. docker研究-4 docker镜像制作

    这次实验以centos镜像为基础镜像进行相关docker镜像制作. 1. 下载centos镜像 [root@localhost ~]# docker pull centosUsing default ...

  5. Nginx+PHP7.3.9 Docker镜像制作

    最近因项目需要制作了多个版本的php docker镜像,制作过程可谓是一波三折,因基于yum的方式安装php的方式在安装扩展插件时很不方便,不容易找到插件对应的yum源,所以PHP在docker镜像中 ...

  6. docker镜像制作必备技能

    正文 使用过docker的都知道dockerfile,其用于定义制作镜像的流程,由一系列命令和参数构成的脚本,这些命令应用于基础镜像并最终创建一个新的镜像.可参考往期文章学习:docker基础知识整理 ...

  7. 实战【docker 镜像制作与使用】

    一.制作docker 镜像 使用spring boot 构建一个简单的web 项目,返回 “Hello,World ”字符串,使用 Maven 打成 jar 包,使用的Linux 环境是 Centos ...

  8. Docker 镜像制作 CentOS+JDK+Tomcat

    [root@localhost createImages]# ls apache-tomcat-.tar.gz server-jre-8u121-linux-x64.tar.gz [root@loca ...

  9. presto-gateway 试用以及docker 镜像制作

    presto-gateway 是 lyft 团队开源 的prestodb 的工具.以下是一个简单的试用,以及碰到问题的解决 还有就是docker 镜像的制作 Dockerfile 很简单,本地构建然后 ...

随机推荐

  1. Win10系列:C#应用控件基础18

    WebView控件 使用WebView控件可以在应用中添加一个简易的网页浏览器窗口,将指定地址的网页内容显示出来,并可以通过WebView控件所提供的方法.属性及事件,实现如页面导航.HTML文本解析 ...

  2. python-面向对象:类与类之间的关系和特殊成员

    # class Person: # def play(self, tools): # 通过参数的传递把另外一个类的对象传递进来 # tools.run() # print("很开心, 我能玩 ...

  3. Qt中的Q_D宏和d指针

    _ZTS7QObject 一.Q_D的在文件中的提法 Q_D的设置意在方便地获取私有类指针,文件为qglobal.h.下面的##是宏定义的连字符.假设类名是A,那么A##Private翻译过来就是AP ...

  4. IO调度算法的理解(转载)

    IO调度器(IO Scheduler)是操作系统用来决定块设备上IO操作提交顺序的方法.存在的目的有两个,一是提高IO吞吐量,二是降低IO响应时间.然而IO吞吐量和IO响应时间往往是矛盾的,为了尽量平 ...

  5. cut语法2

    linux每日一命令--cut--按文件大小排序 显示前100行 显示后五列 ll -Sh|head -n 100|cut -d ' ' -f 5- 一.基本语法cut是一个选取命令,以行为单位,用指 ...

  6. window.location.href webkit不兼容

    window.event.returnValue=false; 在location.href后加上后修复 来自为知笔记(Wiz)

  7. Gym - 101617F :Move Away (圆的交点)

    pro:给定N个圆,求离原点最远的点,满足它在N个圆里.输出这个距离.N<50; sol:关键点一定是圆与圆的交点. 圆与 圆心到原点的直线 的交点. 然后去验证这些关键点是否在N个圆内. 实际 ...

  8. spring boot 之 spring task(定时任务)

    cron:通过表达式来配置任务执行时间cron表达式详解 一个cron表达式有至少6个(也可能7个)有空格分隔的时间元素.按顺序依次为: 秒(0~59)分钟(0~59)3 小时(0~23)4  天(0 ...

  9. js初识1

    JavaScript 1.定义:可以嵌入HTML文档,载体是浏览器,解释型脚本语言 基于对象和事件驱动 2.注释方式 1.// 2./**/ 3./** */文档注释,API就是这么生成的. 3.引入 ...

  10. 关于ajax跨域的一些解决方案

    1.JSONP方式解决跨域问题 jsonp解决跨域问题是一个比较古老的方案(实际中不推荐使用),当然,在实际项目中如果要使用JSONP,一般会使用JQ等对JSONP进行了封装的类库来进行ajax请求 ...