在 MacOS 平台上编译
本文介绍如何在 macOS 平台上编译源码。
环境要求
- macOS 12 (Monterey) 及以上(Intel和Apple Silicon均支持)
- Homebrew
编译步骤
- 使用Homebrew安装依赖
1. brew install automake autoconf libtool pkg-config texinfo coreutils gnu-getopt \
2. python@3 cmake ninja ccache bison byacc gettext wget pcre maven llvm@16 openjdk@11 npm
提示
使用 brew 安装的 jdk 版本为 11,因为在 macOS上,arm64 版本的 brew 默认没有 8 版本的 jdk
- 编译源码
1. bash build.sh
第三方库
- Apache Doris Third Party Prebuilt页面有所有第三方库的源码,可以直接下载doris-thirdparty-source.tgz获得。
- 可以在Apache Doris Third Party Prebuilt页面直接下载预编译好的第三方库,省去编译第三方库的过程,参考下面的命令。
``` 1. cd thirdparty 2. rm -rf installed
-
Intel 芯片
- curl -L https://github.com/apache/doris-thirdparty/releases/download/automation/doris-thirdparty-prebuilt-darwin-x86_64.tar.xz \
-
-o - | tar -Jxf -
-
Apple Silicon 芯片
- curl -L https://github.com/apache/doris-thirdparty/releases/download/automation/doris-thirdparty-prebuilt-darwin-arm64.tar.xz \
-
-o - | tar -Jxf -
-
保证protoc和thrift能够正常运行
-
cd installed/bin
-
./protoc --version
- ./thrift --version ```
- 运行
protoc和thrift的时候可能会遇到无法打开,因为无法验证开发者的问题,可以到前往安全性与隐私。点按通用面板中的仍要打开按钮,以确认打算打开该二进制。参考<https://support.apple.com/zh-cn/HT202491>。
启动
- 通过命令设置好
file descriptors(注意:关闭当前终端会话后需要重新设置)。
1. ulimit -n 65536
也可以将该配置写到到启动脚本中,以便下次打开终端会话时不需要再次设置。
``` 1. # bash 2. echo 'ulimit -n 65536' >>~/.bashrc
-
zsh
- echo 'ulimit -n 65536' >>~/.zshrc ```
执行以下命令,查看设置是否生效。
1. $ ulimit -n
2. 65536
2. 启动BE
1. cd output/be/bin
2. ./start_be.sh --daemon
3. 启动FE
1. cd output/fe/bin
2. ./start_fe.sh --daemon
常见问题
- 启动BE失败,日志显示错误
fail to open StorageEngine, res=file descriptors limit is too small
参考前面提到的设置file descriptors。
2. Java版本
使用 brew 安装的 jdk 版本为 11,因为在 macOS上,arm64 版本的 brew 默认没有 8 版本的 jdk,也可以自行下载 jdk 的安装包进行安装
