下一代实时数据库:Apache Doris 【二】编译与安装

第 2 章 编译与安装

安装 Doris,需要先通过源码编译,主要有两种方式:使用 Docker 开发镜像编译(推荐)、直接编译。
直接编译的方式,可以参考官网:https://doris.apache.org/zh-CN/installing/compilation.html

2.1 安装 Docker 环境

  1. Docker 要求 CentOS 系统的内核版本高于 3.10 ,首先查看系统内核版本是否满足

  2. 使用 root 权限登录系统,确保 yum 包更新到最新

  3. 假如安装过旧版本, 先卸载旧版本
    sudo yum remove docker docker-common docker-selinux docker-engine

  4. 安装 yum-util 工具包和 devicemapper 驱动依赖
    sudo yum install -y yum-utils device-mapper-persistent-data lvm2

  5. 设置 yum 源(加速 yum 下载速度)

如果连接超时, 可以使用 alibaba 的镜像源:

  1. 查看所有仓库中所有 docker 版本, 并选择特定版本安装,一般可直接安装最新版

  2. 安装 docker
    (1) 安装最新稳定版本的方式:
    sudo yum install docker-ce -y #安装的是最新稳定版本,因为 repo 中默认只

(2) 安装指定版本的方式:

  1. 启动并加入开机启动

  2. 查看 Version,验证是否安装成功

若出现 Client 和 Server 两部分内容, 则证明安装成功。

2.2 使用 Docker 开发镜像编译

  1. 下载源码并解压
    通过 wget 下载(或者手动上传下载好的压缩包) 。
wget

https://dist.apache.org/repos/dist/dev/incubator/doris/0.15/0.15. 0-rc04/apache-doris-0.15.0-incubating-src.tar.gz

解压到/opt/software/

tar -zxvf apache-doris-0.15.0-incubating-src.tar.gz -C /opt/software

2)下载 Docker 镜像

docker pull apache/incubator-doris:build-env-for-0.15.0

可以通过以下命令查看镜像是否下载完成。

docker images

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

docker run -it \
-v /opt/software/.m2:/root/.m2 \
-v /opt/software/apache-doris-0.15.0-incubating-src/:/root/apache- doris-0.15.0-incubating-src/ \
apache/incubator-doris:build-env-for-0.15.0
  1. 切换到 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
    
  1. 准备 Maven 依赖
    编译过程会下载很多依赖,可以将我们准备好的 doris-repo.tar.gz 解压到 Docker 挂载的对应目录, 来避免下载依赖的过程, 加速编译。

tar -zxvf doris-repo.tar.gz -C /opt/software

也可以通过指定阿里云镜像仓库来加速下载:
vim /opt/software/apache-doris-0.15.0-incubating-src/fe/pom.xml 在标签下添加:

<repository>                                                       	
<id>aliyun</id>                                                	<url>http://maven.aliyun.com/nexus/content/groups/public/</url> 
</repository>                                                      

vim /opt/software/apache-doris-0.15.0-incubating-src/be/pom.xml 在标签下添加:

<repository>                                                       	
<id>aliyun</id>                                                	<url>http://maven.aliyun.com/nexus/content/groups/public/</url> 
</repository> 

6)编译 Doris

sh build.sh

如果是第一次使用 build-env-for-0.15.0 或之后的版本, 第一次编译的时候要使用如下命令:

sh build.sh --clean --be --fe --ui

因为 build-env-for-0.15.0 版本镜像升级了 thrift(0.9 -> 0. 13),需要通过–clean 命令强制 使用新版本的 thrift 生成代码文件,否则会出现不兼容的代码。

猜你喜欢

转载自blog.csdn.net/xianyu120/article/details/132165702