在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
    3. # Intel 芯片
    4. curl -L https://github.com/apache/doris-thirdparty/releases/download/automation/doris-thirdparty-prebuilt-darwin-x86_64.tar.xz \
    5. -o - | tar -Jxf -
    6. # Apple Silicon 芯片
    7. curl -L https://github.com/apache/doris-thirdparty/releases/download/automation/doris-thirdparty-prebuilt-darwin-arm64.tar.xz \
    8. -o - | tar -Jxf -
    9. # 保证protoc和thrift能够正常运行
    10. cd installed/bin
    11. ./protoc --version
    12. ./thrift --version
  3. 运行protocthrift的时候可能会遇到无法打开,因为无法验证开发者的问题,可以到前往安全性与隐私。点按通用面板中的仍要打开按钮,以确认打算打开该二进制。参考https://support.apple.com/zh-cn/HT202491

启动

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

    1. ulimit -n 65536

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

    1. # bash
    2. echo 'ulimit -n 65536' >>~/.bashrc
    3. # zsh
    4. 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。