ClickHouse 可在 macOS x86_64 (Intel) 和 arm64 (Apple Silicon) 上编译,需使用 macOS 10.15 (Catalina) 或更高版本。
编译器仅支持通过 Homebrew 安装的 Clang。
安装前置条件
首先,请参阅通用的前置条件文档。
接下来,安装 Homebrew 并运行
然后运行:
brew update
brew install ccache cmake ninja libtool gettext llvm lld binutils grep findutils nasm bash rust rustup构建 ClickHouse
构建时必须使用 Homebrew 的 Clang 编译器:
cd ClickHouse
mkdir build
export PATH=$(brew --prefix llvm)/bin:$PATH
cmake -S . -B build
cmake --build build
# 生成的二进制文件将位于:build/programs/clickhouse注意事项
如果你打算运行 clickhouse-server,请务必提高系统的 maxfiles 变量值。
为此,请使用以下内容创建 /Library/LaunchDaemons/limit.maxfiles.plist 文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>524288</string>
<string>524288</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>为该文件设置正确的权限:
sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist验证文件是否正确:
plutil /Library/LaunchDaemons/limit.maxfiles.plist重新加载该文件 (或重启) :
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist要检查是否生效,请使用 ulimit -n 或 launchctl limit maxfiles 命令。