跳到主要内容
跳到主要内容

在 MacOS 平台上编译

本文介绍如何在 macOS 平台上编译源码。

环境要求

  • macOS 12 (Monterey) 及以上(Intel 和 Apple Silicon 均支持

  • Homebrew

源码编译

1. 使用 Homebrew 安装依赖

brew install automake autoconf libtool pkg-config texinfo coreutils gnu-getopt \
python@3 cmake ninja ccache bison byacc gettext wget pcre maven llvm@16 openjdk@11 npm

在 MacOS 上,由于 brew 没有提供 JDK8 的安装包,所以在这里使用了 JDK11。也可以自己手动下载安装 JDK8。

2. 编译源码

bash build.sh

Doris 源码编译时首先会下载三方库源码进行编译,为了节省编译时间,可以下载社区提供的三方库的预编译版本。参见下面的使用预编译三方库提速构建过程。

启动

1. 调大 file descriptors limit

# 通过 ulimit 命令调大 file descriptors limit 限制大小
ulimit -n 65536
# 查看是否生效
$ ulimit -n

# 将该配置写到到启动脚本中,以便下次打开终端会话时不需要再次设置
# 如果是 bash,执行下面语句
echo 'ulimit -n 65536' ~/.bashrc
# 如果是 zsh,执行下面语句
echo 'ulimit -n 65536' ~/.zshrc

2. 启动 BE

cd output/be/bin
./start_be.sh --daemon

3. 启动 FE

cd output/fe/bin
./start_fe.sh --daemon

使用预编译三方库进行提速

可以在 Apache Doris Third Party Prebuilt 页面直接下载预编译好的第三方库,省去编译第三方库的过程,参考下面的命令。

cd thirdparty
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

运行protocthrift的时候可能会遇到无法打开,因为无法验证开发者的问题,可以到前往安全性与隐私。点按通用面板中的仍要打开按钮,以确认打算打开该二进制。参考 https://support.apple.com/zh-cn/HT202491。