
最近在学习Doris FE源码,按照Doris官网开发者手册下载源码时,出现了很多问题,比如Jar包无法加载、编译项目报错、Thrift 插件无法引用等等,导致卡壳时间太久,所以总结如下经验分享给大家,避免大家在同样问题花大量时间去解决。
Apache Doris官方文档:
https://doris.apache.org/zh-CN/developer-guide/fe-idea-dev.html#_4-%E8%AE%BE%E7%BD%AE%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F
二、环境
- 电脑配置:Macbook Pro(Inter i5,Mac OS版本:12.2.1)
- JDK:1.8
- Maven:3.6.1
- Idea:2021.03.03
- Scala:2.12.2
- Thrift:0.13.0
- Doris:1.0.0
Doris官网提供多种方式编译,Idea、Eclipse、Vscode等等,下面我们采用Idea来运行源码。
我们可以通过GitHub或者Idea VCS两种方式下载源码。
(1)GitHub下载源码
Doris GitHub 链接:https://github.com/apache/incubator-doris
-
通过浏览器打开链接
-
下载源码
源码下载完成之后,把源码解压到Idea的workspace即可。
(2)Idea VCS下载源码 -
打开Idea
-
点击右上角 “从VCS获取” 按钮
-
输入Doris Git地址
Doris Git地址:
https://github.com/apache/incubator-doris.git
2、安装Thrift等待Idea从GitHub获取完整代码。
- 查看电脑是否安装Thrift
在Mac终端输入命令: brew info Thrift@0.13.0 (PS:如果没有安装brew命令,可以自行百度如何安装)
安装
thrift0.13.0 版本(注意:Doris0.15 以上 和最新的版本基于thrift0.13.0 构建, 之前的版本依然使用thrift0.9.3 构建)
- 安装Thrift 0.13.0
输入命令:brew install thrift@0.13.0
注:MacOS执行
brew install thrift@0.13.0可能会报找不到版本的错误,解决方法如下,在终端执行:
1.brew tap-new $USER/local-tap
2.brew extract --version='0.13.0' thrift $USER/local-tap
3.brew install thrift@0.13.0注:留意Thrift安装的位置!!!!
- 验证Thrift安装
输入命令:thrift -version
(1)Idea打开Doris源码,等待Maven加载pom文件依赖
注:我这是使用的是IDEA默认的maven仓库,很多JAR包都加载不出来。
(2)将Thrift文件复制到Doris源码目录下的thirdparty文件夹
-
首先在thirdparty文件夹下创建/installed/bin
-
找到Thrift安装位置,复制文件到 Doris源码/thirdparty/installed/bin,执行命令:
cp /usr/local/Cellar/thrift\@0.13.0/0.13.0/bin/thrift /Users/apple/Workspaces/Doris源码_1.0.0/thirdparty/installed/bin/
-
查看文件是否复制
-
设置 maven 配置或者系统环境变量
(1)maven 配置
左上角 IntelliJ IDEA ==> Perferences
设置doris.thrift变量值
(2)系统环境配置
-
终端输入命令:
sudo vi ~/.bash_profile -
添加 DORIS_THRIFT 变量,value是thirdparty文件夹绝对路径
-
编辑完成之后保存文件
-
终端输入命令:
source ~/.bash_profile
-
先编译fe-common 项目
-
解决报错:Unable to find: checkstyle-apache-header.txt
-
再次 install fe-common项目,又遇见报错:
Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.6:sign (sign-release-artifacts) on project fe-common: Unable to execute gpg command: Error while executing process. Cannot run program "gpg": error=2, No such file or directory -> [Help 1]
解决方式:在fe-common.pom加入org.apache.maven.plugins依赖:
org.apache.maven.plugins
maven-gpg-plugin
1.6
true
-
继续编译fe-common项目
-
编译spark-dpp 项目
如果出现该报错:
Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.6:sign (sign-release-artifacts) on project fe-common: Unable to execute gpg command: Error while executing process. Cannot run program "gpg": error=2, No such file or directory -> [Help 1]
在spark-dpp.pom 文件添加 org.apache.maven.plugins依赖:
org.apache.maven.plugins
maven-gpg-plugin
1.6
true
- 编译 fe项目
编译fe项目的目的是生成 fe-core target文件,不能直接编译fe-core,因为fe-core依赖fe部分文件,所以我们需要先编译fe项目
- 创建文件夹logs、webroot、logs、doris-meta
- 设置fe-core启动类变量
变量设置:
JAVA_OPTS=-Xmx1024m;
DORIS_HOME=/Users/apple/Workspaces/Doris源码_1.0.0;
PID_DIR=/Users/apple/Workspaces/Doris源码_1.0.0/fe;
LOG_DIR=/Users/apple/Workspaces/Doris源码_1.0.0/fe/logs
- 启动 fe-core
使用IDEA编译Apache Doris FE源码过程中,出现了很多报错,我进行了总结:
Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.6:sign (sign-release-artifacts) on project fe-common: Unable to execute gpg command: Error while executing process. Cannot run program "gpg": error=2, No such file or directory -> [Help 1]
解决方式:缺少maven-gpg-plugin依赖,在pom文件添加即可,配置文件如下:
org.apache.maven.plugins
maven-gpg-plugin
1.6
true
Unable to find: checkstyle-apache-header.txt
解决方式:checkstyle-apache-header.txt文件的路径不对,如下图:
thrift did not exit cleanly. Review output for more information.
解决方式:thrift文件的路径不对,请看Maven环境配置章节!
Module 'fe-core' production : java.lang.OutOfMemoryError: GC overhead limit exceeded
解决方式:Maven的编译器内存不够,添加内存即可,如图
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)