脚本宝典收集整理的这篇文章主要介绍了第1.1章:StarRocks部署--源码编译,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
在部署StarRocks前,我们可能会纠结使用哪个版本合适。StarRocks在gIThub上打包有各版本的源码包,在官网上也发布有基于x86架构编译的适用于CentOS 7+的Release版二进制包,版本的选择我们不妨遵循以下几个原则F1a;
具体的版本功能差异可以关注官方论坛的Release Note,例如1.19的版本信息地址为:
StarRocks-1.19 Release Notes - Release Notes - StarRocks数据库论坛StarRocks version 1.19.0发布日期:2021年10月25日 New Feature实现Global Runtime Filter,可以支持对shuffle join实现Runtime filter。默认开启C…https://forum.starrocks.COM/t/topic/552下面我们以从StarRocks github main分支中拉取的最新代码为例,使用官方提供的Docker镜像进行编译。
为方便演示,我们使用虚拟机下的CentOS 7.6执行编译,虚拟机的配置建议在2核4G以上,内存过小编译过程中可能会出错,CPU核数过少则可能会导致编译时间较长。同时,编译过程中还务必保持网络畅通。
在root用户下使用yum安装Docker:
[root@localhost ~]# yum -y install docker
[root@localhost ~]# Systemctl start docker
[root@localhost ~]# systemctl enable docker
Created syMLink From /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
2db29710123e: Pull complete
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
status: Downloaded newer image for docker.io/hello-world:latest
Hello from Docker!
This message shows that your installation apPEars to be working correctly.
………………
由于网络原因,下载一个Docker官方镜像可能会需要很长的时间,甚至下载失败。为此,阿里云容器镜像服务ACR提供了官方的镜像站点,从而加速官方镜像的下载。具体配置方法参考阿里云文档:
官方镜像加速 - 容器镜像服务 ACR - 阿里云https://help.aliyun.com/document_detail/60750.html
配置加速后,镜像拉取速度较快,我们等待拉取完成:
[root@localhost ~]# docker pull starrocks/dev-env:main
Trying to pull repository docker.io/starrocks/dev-env ...
main: Pulling from docker.io/starrocks/dev-env
5ad559c5ae16: Pull complete
2bad2b236a9a: Pull complete
f6d22315d484: Pull complete
c416e97f8271: Pull complete
7d8b91bb0c99: Pull complete
425e6901bb98: Pull complete
a5688ad2be15: Pull complete
3223710ac544: Pull complete
19884eca2d12: Pull complete
463267783751: Pull complete
Digest: sha256:ab44decbdc2eaaa98cdc4647380a492299b175a35b165d50e30f183495090123
Status: Downloaded newer image for docker.io/starrocks/dev-env:main
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/starrocks/dev-env main 95d18ca637fd 5 weeks ago 8.65 GB
docker.io/hello-world latest feb5d9fea6a5 8 weeks ago 13.3 kB
[root@localhost ~]# git clone https://github.com/StarRocks/starrocks.git
Cloning into 'starrocks'...
fatal: unable to access 'https://github.com/StarRocks/starrocks.git/': encountered end of file
因国内网络原因,这种方式有时可能拉取不下来。我们可以从github上直接下载代码包,下载地址为:
GitHub - StarRocks/starrocks: StarRocks is a next-gen sub-second MPP database for full analysis scenarios, including multi-dimensional Analytics, real-time analytics and ad-hoc query.https://github.com/StarRocks/starrocks
若需要获取Release版本的代码包,获取地址为:
https://github.com/StarRocks/starrocks/tagshttps://github.com/StarRocks/starrocks/tags
以从main分支下下载的最新代码为例,我们下载后得到源码包starrocks-main.zip,将其上传至CentOS中,文件路径为/root/starrocks-main.zip:
[root@localhost ~]# ls
starrocks-main.zip
执行解压:
[root@localhost ~]# unzip starrocks-main.zip
得到:/root/starrocks-main
[root@localhost ~]# ls
starrocks-main starrocks-main.zip
[root@localhost ~]# docker run -it -v /root/.m2:/root/.m2 -v /root/starrocks-main:/root/starrocks-main --name starrocks-image --PRivileged=true -d starrocks/dev-env:main
6ebc6a124fDF9d2c28b6eb2543e570775b2f3eabb7716120a3cefe8506ee9d2f
[root@localhost ~]# docker ps
[root@localhost ~]# docker exec -it starrocks-image /bin/bash
[root@ed39d436e75c local]# [这里注意看主机名,确认已进入容器]
[root@ed39d436e75c local]# cd /root/starrocks-main
[root@ed39d436e75c starrocks-main]#
[root@ed39d436e75c starrocks-main]# ./build.sh
这一步会下载较多依赖并执行编译,会非常耗时。运行容器时我们挂载本地.m2目录即是为了首次编译下载的依赖后面再编译时可以复用。这一步只要不报错,我们慢慢等待即可。编译完成后,产出文件在output/目录中:
[root@docker starrocks-main]# cd output/
[root@docker output]# ll
total 1992
drwxr-xr-x 6 root root 51 Nov 2 00:20 be
drwxr-xr-x 7 root root 72 Nov 2 00:20 fe
-rw-r--r-- 1 root root 3858 Nov 1 11:20 LICENSE.txt
-rw-r--r-- 1 root root 2032787 Nov 2 00:20 NOTICE.txt
drwxr-xr-x 4 root root 32 Nov 2 00:20 udf
若我们编译不需要AVX2支持的StarRocks,我们需要修改build.sh文件:
[root@ed39d436e75c starrocks-main]# vi build.sh
………………
WITH_HDFS=ON
if [[ -z ${USE_AVX2} ]]; then
USE_AVX2=ON
Fi
………………
将USE_AVX2=ON 修改为USE_AVX2=OFF。
保存退出后,再执行build.sh进行编译。再次提醒,这种方案只能保证StarRocks能够在没有AVX2指令集的机器上运行,并没有经过完整的测试来确保没有其他问题。
执行编译时,我们也可以指定参数只编译部分组件,例如:
usage: build.sh <options>
Optional options:
--be build Backend
--fe build Frontend and Spark Dpp application
--spark-dpp build Spark DPP application
--clean clean and build target
--with-gcov build Backend with gcov, has an impact on performance
--without-gcov build Backend without gcov(default)
--with-hdfs enable hdfs support
--without-hdfs disable hdfs support
前面的操作不会编译Broker,我们需要单独编译:
[root@ed39d436e75c starrocks-main]# cd fs_brokers/apache_hdfs_broker/ && sh build.sh
编译后,产出文件在fs_brokers/apache_hdfs_broker/output目录中:
[root@docker output]# ll
total 0
drwxr-xr-x 5 root root 40 Nov 2 00:33 apache_hdfs_broker
在启动容器时我们已将starrocks-main目录挂载到了镜像中,所以上面编译生成的二进制文件也存在于本地。所以完成编译后,我们可以直接退出容器:
[root@ed39d436e75c starrocks-main]# exit
后面若还需要启动容器,执行:
[root@localhost ~]# docker start starrocks-image
启动后再登入容器:
[root@localhost ~]# docker exec -it starrocks-image /bin/bash
备注:
目前官方的Docker镜像还不能在ARM架构下执行编译,首先缺少ARM架构可用的jdk,其次@R_383_1512@等依赖也与x86架构下有差异。我们可以等待官方后续推出适用于ARM架构的镜像,或者,手动编译,依据报错提示逐步进行。
以上是脚本宝典为你收集整理的第1.1章:StarRocks部署--源码编译全部内容,希望文章能够帮你解决第1.1章:StarRocks部署--源码编译所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。