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

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

  1. $ mkdir build
  2. $ cd build
  3. $ cmake .. -DCMAKE_CXX_COMPILER=`which clang++` -DCMAKE_C_COMPILER=`which clang`
  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 following file:

/Library/LaunchDaemons/limit.maxfiles.plist:

  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.