How to Build ClickHouse on Mac OS X

Build should work on Mac OS X 10.15 (Catalina).

Install Homebrew

  1. $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install Required Compilers, Tools, and Libraries

  1. $ brew install cmake ninja libtool gettext llvm

Checkout ClickHouse Sources

  1. $ git clone --recursive [email protected]:ClickHouse/ClickHouse.git

or

  1. $ git clone --recursive https://github.com/ClickHouse/ClickHouse.git
  2. $ cd ClickHouse

Build ClickHouse

Please note: ClickHouse doesn’t support build with native Apple Clang compiler, we need use clang from LLVM.

  1. $ mkdir build
  2. $ cd build
  3. $ cmake .. -DCMAKE_C_COMPILER=`brew --prefix llvm`/bin/clang -DCMAKE_CXX_COMPILER=`brew --prefix llvm`/bin/clang++ -DCMAKE_PREFIX_PATH=`brew --prefix llvm`
  4. $ ninja
  5. $ cd ..

Caveats

If you intend to run clickhouse-server, make sure to increase the system’s maxfiles variable.

Note

You’ll need to use sudo.

To do so, create the /Library/LaunchDaemons/limit.maxfiles.plist file with the following content:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  3. "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  4. <plist version="1.0">
  5. <dict>
  6. <key>Label</key>
  7. <string>limit.maxfiles</string>
  8. <key>ProgramArguments</key>
  9. <array>
  10. <string>launchctl</string>
  11. <string>limit</string>
  12. <string>maxfiles</string>
  13. <string>524288</string>
  14. <string>524288</string>
  15. </array>
  16. <key>RunAtLoad</key>
  17. <true/>
  18. <key>ServiceIPC</key>
  19. <false/>
  20. </dict>
  21. </plist>

Execute the following command:

  1. $ sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist

Reboot.

To check if it’s working, you can use ulimit -n command.

Original article