手把手教你编译Apache Doris-1.1.0版本

一。 环境准备 :

  1. 需要下载doris-1.1.0源码,命令如下:
    wget https://dlcdn.apache.org/doris/1.1/1.1.0-rc05/apache-doris-1.1.0-src.tar.gz
  2. 需要下载编译时用到的镜像,命令如下:
    docker pull apache/doris:build-env-for-1.1.0
    这里可以不着急下载,后面也会提到!放在这里只是为了好记

1. 创建存放doris1.1.0版本的目录 :

[las@master ~]$ cd /home/softs/
[las@master softs]$ mkdir doris-1.1.0
[las@master softs]$ cd doris-1.1.0/
[las@master doris-1.1.0]$ ll
total 0
[las@master doris-1.1.0]$

2. 通过镜像下载doris-1.1.0源码

[las@master doris-1.1.0]$ wget https://dlcdn.apache.org/doris/1.1/1.1.0-rc05/apache-doris-1.1.0-src.tar.gz
--2022-07-14 16:25:47--  https://dlcdn.apache.org/doris/1.1/1.1.0-rc05/apache-doris-1.1.0-src.tar.gz
Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 28114525 (27M) [application/x-gzip]
Saving to: ‘apache-doris-1.1.0-src.tar.gz’

100%[===================================================>] 28,114,525  14.9KB/s   in 46m 30s

2022-07-14 17:12:18 (9.84 KB/s) - ‘apache-doris-1.1.0-src.tar.gz’ saved [28114525/28114525]

[las@master doris-1.1.0]$ ll
total 27460
-rw-rw-r-- 1 las las 28114525 Jul 10 22:41 apache-doris-1.1.0-src.tar.gz
[las@master doris-1.1.0]$ 

3. 将tar包解压缩

(docker使用root安装的,所以拉取镜像的时候需要切换成root用户,这里已经切换了)

[root@master doris-1.1.0]# tar -zxvf apache-doris-1.1.0-src.tar.gz 
[root@master doris-1.1.0]# ll
total 27464
drwxrwxr-x 22 root root     4096 Jul 10 21:14 apache-doris-1.1.0-src
-rw-rw-r--  1 las  las  28114525 Jul 10 22:41 apache-doris-1.1.0-src.tar.gz
[root@master doris-1.1.0]# 

4. 通过docker拉去docker-1.1.0对应的镜像版本

[ro[root@master doris-1.1.0]# docker pull apache/doris:build-env-for-1.1.0
Trying to pull repository docker.io/apache/doris ... 
build-env-for-1.1.0: Pulling from docker.io/apache/doris
b3cd9cb980b3: Pull complete 
Digest: sha256:174d1f3106c200625155416d16d1db02939ce3f976808b995e7c381d939209ae
Status: Downloaded newer image for docker.io/apache/doris:build-env-for-1.1.0
[root@master doris-1.1.0]#

5. 查看镜像

[root@master doris-1.1.0]# docker images
REPOSITORY                  TAG                   IMAGE ID            CREATED             SIZE
docker.io/apache/doris      build-env-for-1.1.0   dde1b354e49b        13 days ago         4.41 GB
docker.io/grafana/grafana   latest                72af18398579        2 months ago        286 MB
docker.io/mysql             5.7                   8aa4b5ffb001        2 months ago        462 MB
docker.io/prom/prometheus   v2.35.0               a5bac665ffa2        2 months ago        206 MB
docker.io/docker/compose    1.29.2                32d8a4638cd8        14 months ago       76.2 MB
docker.io/elasticsearch     7.9.3                 1ab13f928dc8        21 months ago       742 MB
docker.io/java              8-jre-alpine          fdc893b19a14        5 years ago         108 MB
[root@master doris-1.1.0]# ll
total 27464
drwxrwxr-x 22 root root     4096 Jul 10 21:14 apache-doris-1.1.0-src
-rw-rw-r--  1 las  las  28114525 Jul 10 22:41 apache-doris-1.1.0-src.tar.gz
[root@master doris-1.1.0]#

二。启动容器,准备编译

1. 需做两个目录映射,一个是maven的repository目录,一个是doris源码目录,避免容器挂了之后之前下载或编译的内容丢失

建议以挂载本地 Doris 源码目录的方式运行镜像,这样编译的产出二进制文件会存储在宿主机中,不会因为镜像退出而消失。同时,建议同时将镜像中 maven 的 .m2 目录挂载到宿主机目录,以防止每次启动镜像编译时,重复下载 maven 的依赖库。使用挂载的方式运行镜像

[root@master doris-1.1.0]#  docker run -it -v /root/.m2:/root/.m2 -v /home/softs/doris-1.1.0/apache-doris-1.1.0-src:/root/doris-1.1.0/apache-doris-1.1.0-src apache/doris:build-env-for-1.1.0
[root@c2cc0e18216d ~]# ll
total 8
-rw------- 1 root root 3416 Nov 13  2020 anaconda-ks.cfg
drwxr-xr-x 3 root root 4096 Jul 15 01:54 doris-1.1.0
[root@c2cc0e18216d ~]#
  1. 在 build-env-for-0.15.0 的docker镜像中,同时包含了 OpenJDK 8 和 OpenJDK 11,并且默认使用 OpenJDK 11 编译。可通过java —version查看jdk版本
[root@c2cc0e18216d ~]# java -version
openjdk version "11.0.15" 2022-04-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.15+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.15+9-LTS, mixed mode, sharing)
[root@c2cc0e18216d ~]# 

注意 :请确保编译使用的 JDK 版本和运行时使用的 JDK 版本一致,否则会导致非预期的运行错误。你可以使用在进入编译镜像的容器后,使用以下命令切换默认 JDK 版本:

切换到 JDK 8:
alternatives --set java java-1.8.0-openjdk.x86_64 
alternatives --set javac java-1.8.0-openjdk.x86_64
export JAVA_HOME=/usr/lib/jvm/java-1.8.0

切换到 JDK 11:
alternatives --set java java-11-openjdk.x86_64
alternatives --set javac java-11-openjdk.x86_64
export JAVA_HOME=/usr/lib/jvm/java-11

3. 由于我们的运行时为JDK 8,因此切换到JDK 8环境。

[root@c2cc0e18216d ~]# alternatives --set java java-1.8.0-openjdk.x86_64
[root@c2cc0e18216d ~]# alternatives --set javac java-1.8.0-openjdk.x86_64
[root@c2cc0e18216d ~]# export JAVA_HOME=/usr/lib/jvm/java-1.8.0
[root@c2cc0e18216d ~]# java -version
openjdk version "1.8.0_332"
OpenJDK Runtime Environment (build 1.8.0_332-b09)
OpenJDK 64-Bit Server VM (build 25.332-b09, mixed mode)
[root@c2cc0e18216d ~]# 

4. 进入到doris-1.1.0目录中

[root@c2cc0e18216d ~]# cd doris-1.1.0/apache-doris-1.1.0-src/
[root@c2cc0e18216d apache-doris-1.1.0-src]# ls
CODE_OF_CONDUCT.md  LICENSE.txt  be             build.sh        contrib  docs       fe          gensrc           run-fe-ut.sh            thirdparty         ui
CONTRIBUTING.md     NOTICE.txt   bin            build_plugin.sh  dist     env.sh     fe_plugins  regression-test  run-regression-test.sh  tools              webroot
CONTRIBUTING_CN.md  README.md    build-support  conf             docker   extension  fs_brokers  run-be-ut.sh     samples                 tsan_suppressions
[root@c2cc0e18216d apache-doris-1.1.0-src]# 

5. 开始编译,执行 # sh build.sh

[root@c2cc0e18216d apache-doris-1.1.0-src]# sh build.sh 
经历长达一个多小时的等待....
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  06:27 min
[INFO] Finished at: 2022-07-15T03:37:40Z
[INFO] ------------------------------------------------------------------------
Install broker...
Finished
***************************************
Successfully build Doris
***************************************
[root@c2cc0e18216d apache-doris-1.1.0-src]# 


看到这里。我们已经编译完成,剩下的就是检验文件的真实性了

6. 在查看一下目录,发现多了一个output目录,这个目录就是我们最终想要得到的

[root@c2cc0e18216d apache-doris-1.1.0-src]# ls
CODE_OF_CONDUCT.md  LICENSE.txt  be             build.sh         contrib  docs       fe          gensrc           run-be-ut.sh            samples     tsan_suppressions
CONTRIBUTING.md     NOTICE.txt   bin            build_plugin.sh  dist     env.sh     fe_plugins  output           run-fe-ut.sh            thirdparty  ui
CONTRIBUTING_CN.md  README.md    build-support  conf             docker   extension  fs_brokers  regression-test  run-regression-test.sh  tools       webroot
[root@c2cc0e18216d apache-doris-1.1.0-src]# 
[root@c2cc0e18216d apache-doris-1.1.0-src]# cd output/
[root@c2cc0e18216d output]# ll
total 16
drwxr-xr-x 5 root root 4096 Jul 15 03:37 apache_hdfs_broker
drwxr-xr-x 8 root root 4096 Jul 15 03:31 be
drwxr-xr-x 9 root root 4096 Jul 15 03:31 fe
drwxr-xr-x 4 root root 4096 Jul 15 03:31 udf
[root@c2cc0e18216d output]#

7. 因为我们是通过挂载本地文件方式启动的,所以并不需要将文件从dokcer容器中拉取到本地,直接退出容器或者换一个session窗口打开目录即可,我这里直接换了一个session窗口打开的

[las@master ~]$ /home/softs/doris-1.1.0
[las@master doris-1.1.0]$ ll
total 27464
drwxrwxr-x 23 root root     4096 Jul 15 11:30 apache-doris-1.1.0-src
-rw-rw-r--  1 las  las  28114525 Jul 10 22:41 apache-doris-1.1.0-src.tar.gz
[las@master doris-1.1.0]$ cd apache-doris-1.1.0-src
[las@master apache-doris-1.1.0-src]$ ll
total 200
drwxrwxr-x 6 root root  4096 Jul 15 10:56 be
drwxrwxr-x 2 root root  4096 Jul 10 21:14 bin
-rwxrwxr-x 1 root root  2747 Jul 10 21:14 build_plugin.sh
-rwxrwxr-x 1 root root 12690 Jul 10 21:14 build.sh
drwxrwxr-x 2 root root  4096 Jul 10 21:14 build-support
-rw-rw-r-- 1 root root  4118 Jul 10 21:14 CODE_OF_CONDUCT.md
drwxrwxr-x 2 root root  4096 Jul 10 21:14 conf
drwxrwxr-x 3 root root  4096 Jul 10 21:14 contrib
-rw-rw-r-- 1 root root  4888 Jul 10 21:14 CONTRIBUTING_CN.md
-rw-rw-r-- 1 root root  5145 Jul 10 21:14 CONTRIBUTING.md
drwxrwxr-x 4 root root  4096 Jul 10 21:14 dist
drwxrwxr-x 2 root root  4096 Jul 10 21:14 docker
drwxrwxr-x 7 root root  4096 Jul 15 10:57 docs
-rwxrwxr-x 1 root root  5707 Jul 10 21:14 env.sh
drwxrwxr-x 4 root root  4096 Jul 10 21:14 extension
drwxrwxr-x 7 root root  4096 Jul 10 21:14 fe
drwxrwxr-x 4 root root  4096 Jul 10 21:14 fe_plugins
drwxrwxr-x 3 root root  4096 Jul 10 21:14 fs_brokers
drwxrwxr-x 6 root root  4096 Jul 15 09:41 gensrc
-rw-rw-r-- 1 root root 30573 Jul 10 21:14 LICENSE.txt
-rw-rw-r-- 1 root root  1948 Jul 10 21:14 NOTICE.txt
drwxr-xr-x 6 root root  4096 Jul 15 11:31 output
-rw-rw-r-- 1 root root  5120 Jul 10 21:14 README.md
drwxrwxr-x 7 root root  4096 Jul 10 21:14 regression-test
-rwxrwxr-x 1 root root  5500 Jul 10 21:14 run-be-ut.sh
-rwxrwxr-x 1 root root  2546 Jul 10 21:14 run-fe-ut.sh
-rwxrwxr-x 1 root root  5386 Jul 10 21:14 run-regression-test.sh
drwxrwxr-x 7 root root  4096 Jul 10 21:14 samples
drwxrwxr-x 3 root root  4096 Jul 10 21:14 thirdparty
drwxrwxr-x 7 root root  4096 Jul 10 21:14 tools
-rw-rw-r-- 1 root root  1387 Jul 10 21:14 tsan_suppressions
drwxrwxr-x 7 root root  4096 Jul 15 10:58 ui
drwxrwxr-x 4 root root  4096 Jul 10 21:14 webroot
[las@master apache-doris-1.1.0-src]$ cd output/
[las@master output]$ ll
total 16
drwxr-xr-x 5 root root 4096 Jul 15 11:37 apache_hdfs_broker
drwxr-xr-x 8 root root 4096 Jul 15 11:31 be
drwxr-xr-x 9 root root 4096 Jul 15 11:31 fe
drwxr-xr-x 4 root root 4096 Jul 15 11:31 udf
[las@master output]$ pwd
/home/softs/doris-1.1.0/apache-doris-1.1.0-src/output
[las@master output]$ 

到此编译完成!!!

你可能感兴趣的:(大数据,Linux,docker,容器,apache)