在macOS平台上编译

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

环境要求

  1. macOS 12 (Monterey) 及以上(Intel和Apple Silicon均支持)
  2. Apple Clang 13及以上(最好使用最新版本)
  3. Homebrew

编译步骤

  1. 使用Homebrew安装依赖

1. brew install automake autoconf libtool pkg-config texinfo coreutils gnu-getopt \ 2. python cmake ninja ccache bison byacc gettext wget pcre maven openjdk@11 npm 2. 编译源码

1. bash build.sh

第三方库

  1. Apache Doris Third Party Prebuilt页面有所有第三方库的源码,可以直接下载doris-thirdparty-source.tgz获得。
  2. 可以在Apache Doris Third Party Prebuilt页面直接下载预编译好的第三方库,省去编译第三方库的过程,参考下面的命令。

``` 1. cd thirdparty 2. rm -rf installed

  1. Intel 芯片

  2. curl -L https://github.com/apache/doris-thirdparty/releases/download/automation/doris-thirdparty-prebuilt-darwin-x86_64.tar.xz \
  3. -o - | tar -Jxf -

  4. Apple Silicon 芯片

  5. curl -L https://github.com/apache/doris-thirdparty/releases/download/automation/doris-thirdparty-prebuilt-darwin-arm64.tar.xz \
  6. -o - | tar -Jxf -

  7. 保证protoc和thrift能够正常运行

  8. cd installed/bin

  9. ./protoc --version

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

启动

  1. 通过命令设置好file descriptors(注意:关闭当前终端会话后需要重新设置)。

1. ulimit -n 65536

也可以将该配置写到到启动脚本中,以便下次打开终端会话时不需要再次设置。

``` 1. # bash 2. echo 'ulimit -n 65536' >>~/.bashrc

  1. zsh

  2. 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。

Java版本

推荐使用Java 11。