2020-04-03 13:23:32 +00:00
|
|
|
|
---
|
|
|
|
|
toc_priority: 65
|
2020-07-20 14:29:13 +00:00
|
|
|
|
toc_title: Build on Mac OS X
|
2020-04-03 13:23:32 +00:00
|
|
|
|
---
|
|
|
|
|
|
2021-10-23 04:05:24 +00:00
|
|
|
|
# You don't have to build ClickHouse
|
|
|
|
|
|
|
|
|
|
You can install ClickHouse as follows: https://clickhouse.com/#quick-start
|
|
|
|
|
Choose Mac x86 or M1.
|
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
|
# How to Build ClickHouse on Mac OS X {#how-to-build-clickhouse-on-mac-os-x}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2021-10-23 04:05:24 +00:00
|
|
|
|
Build should work on x86_64 (Intel) and arm64 (Apple Silicon) based macOS 10.15 (Catalina) and higher with Homebrew's vanilla Clang.
|
|
|
|
|
It is always recommended to use `clang` compiler. It is possible to use XCode's `AppleClang` or `gcc` but it's strongly discouraged.
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
|
## Install Homebrew {#install-homebrew}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
|
``` bash
|
2021-04-08 09:17:58 +00:00
|
|
|
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
|
|
|
# ...and follow the printed instructions on any additional steps required to complete the installation.
|
2017-12-28 15:13:23 +00:00
|
|
|
|
```
|
|
|
|
|
|
2021-04-02 13:31:20 +00:00
|
|
|
|
## Install Xcode and Command Line Tools {#install-xcode-and-command-line-tools}
|
|
|
|
|
|
2021-04-02 18:09:12 +00:00
|
|
|
|
Install the latest [Xcode](https://apps.apple.com/am/app/xcode/id497799835?mt=12) from App Store.
|
2021-04-02 13:31:20 +00:00
|
|
|
|
|
|
|
|
|
Open it at least once to accept the end-user license agreement and automatically install the required components.
|
|
|
|
|
|
2021-05-27 19:48:20 +00:00
|
|
|
|
Then, make sure that the latest Command Line Tools are installed and selected in the system:
|
2021-04-02 13:31:20 +00:00
|
|
|
|
|
|
|
|
|
``` bash
|
2021-04-08 09:17:58 +00:00
|
|
|
|
sudo rm -rf /Library/Developer/CommandLineTools
|
|
|
|
|
sudo xcode-select --install
|
2021-04-02 13:31:20 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Reboot.
|
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
|
## Install Required Compilers, Tools, and Libraries {#install-required-compilers-tools-and-libraries}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
|
``` bash
|
2021-04-08 09:17:58 +00:00
|
|
|
|
brew update
|
2021-06-26 13:39:02 +00:00
|
|
|
|
brew install cmake ninja libtool gettext llvm gcc binutils
|
2017-12-28 15:13:23 +00:00
|
|
|
|
```
|
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
|
## Checkout ClickHouse Sources {#checkout-clickhouse-sources}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
|
``` bash
|
2021-04-08 09:17:58 +00:00
|
|
|
|
git clone --recursive git@github.com:ClickHouse/ClickHouse.git
|
|
|
|
|
# ...alternatively, you can use https://github.com/ClickHouse/ClickHouse.git as the repo URL.
|
2019-09-23 15:31:46 +00:00
|
|
|
|
```
|
2020-03-20 10:10:48 +00:00
|
|
|
|
|
2021-04-02 13:31:20 +00:00
|
|
|
|
## Build ClickHouse {#build-clickhouse}
|
|
|
|
|
|
2021-10-23 04:05:24 +00:00
|
|
|
|
To build using Homebrew's vanilla Clang compiler:
|
2020-03-20 10:10:48 +00:00
|
|
|
|
|
|
|
|
|
``` bash
|
2021-04-08 09:17:58 +00:00
|
|
|
|
cd ClickHouse
|
|
|
|
|
rm -rf build
|
|
|
|
|
mkdir build
|
|
|
|
|
cd build
|
2021-10-23 04:05:24 +00:00
|
|
|
|
cmake -DCMAKE_C_COMPILER=$(brew --prefix llvm)/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix llvm)/bin/clang++ -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
|
2021-04-08 09:17:58 +00:00
|
|
|
|
cmake --build . --config RelWithDebInfo
|
|
|
|
|
cd ..
|
2017-12-28 15:13:23 +00:00
|
|
|
|
```
|
|
|
|
|
|
2021-10-23 04:05:24 +00:00
|
|
|
|
To build using Xcode's native AppleClang compiler (this option is strongly not recommended; use the option above):
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2021-04-02 13:31:20 +00:00
|
|
|
|
``` bash
|
2021-04-08 09:17:58 +00:00
|
|
|
|
cd ClickHouse
|
|
|
|
|
rm -rf build
|
|
|
|
|
mkdir build
|
|
|
|
|
cd build
|
2021-10-23 04:05:24 +00:00
|
|
|
|
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
|
2021-04-08 09:17:58 +00:00
|
|
|
|
cmake --build . --config RelWithDebInfo
|
|
|
|
|
cd ..
|
2021-04-02 13:31:20 +00:00
|
|
|
|
```
|
|
|
|
|
|
2021-10-23 04:05:24 +00:00
|
|
|
|
To build using Homebrew's vanilla GCC compiler (this option is absolutely not recommended, I'm wondering why do we ever have it):
|
2020-12-13 08:10:07 +00:00
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
|
``` bash
|
2021-04-08 09:17:58 +00:00
|
|
|
|
cd ClickHouse
|
|
|
|
|
rm -rf build
|
|
|
|
|
mkdir build
|
|
|
|
|
cd build
|
2021-09-08 15:06:15 +00:00
|
|
|
|
cmake -DCMAKE_C_COMPILER=$(brew --prefix gcc)/bin/gcc-11 -DCMAKE_CXX_COMPILER=$(brew --prefix gcc)/bin/g++-11 -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
|
2021-04-08 09:17:58 +00:00
|
|
|
|
cmake --build . --config RelWithDebInfo
|
|
|
|
|
cd ..
|
2017-12-28 15:13:23 +00:00
|
|
|
|
```
|
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
|
## Caveats {#caveats}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-07-20 14:29:13 +00:00
|
|
|
|
If you intend to run `clickhouse-server`, make sure to increase the system’s maxfiles variable.
|
2018-07-18 10:00:53 +00:00
|
|
|
|
|
2018-07-20 17:35:34 +00:00
|
|
|
|
!!! info "Note"
|
2020-03-20 10:10:48 +00:00
|
|
|
|
You’ll need to use sudo.
|
2018-07-18 10:00:53 +00:00
|
|
|
|
|
2020-07-20 14:29:13 +00:00
|
|
|
|
To do so, create the `/Library/LaunchDaemons/limit.maxfiles.plist` file with the following content:
|
2020-03-20 10:10:48 +00:00
|
|
|
|
|
|
|
|
|
``` xml
|
2018-07-18 10:00:53 +00:00
|
|
|
|
<?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>
|
|
|
|
|
```
|
|
|
|
|
|
2021-09-21 15:55:52 +00:00
|
|
|
|
Give the file correct permissions:
|
2020-03-20 10:10:48 +00:00
|
|
|
|
|
|
|
|
|
``` bash
|
2021-04-08 09:17:58 +00:00
|
|
|
|
sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
|
2018-07-18 10:00:53 +00:00
|
|
|
|
```
|
|
|
|
|
|
2021-09-21 15:55:52 +00:00
|
|
|
|
Validate that the file is correct:
|
|
|
|
|
|
|
|
|
|
``` bash
|
|
|
|
|
plutil /Library/LaunchDaemons/limit.maxfiles.plist
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Load the file (or reboot):
|
|
|
|
|
|
|
|
|
|
``` bash
|
|
|
|
|
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
|
|
|
|
|
```
|
2018-07-18 10:00:53 +00:00
|
|
|
|
|
2021-09-21 15:55:52 +00:00
|
|
|
|
To check if it’s working, use the `ulimit -n` or `launchctl limit maxfiles` commands.
|
2018-10-16 10:47:17 +00:00
|
|
|
|
|
2021-05-05 14:35:28 +00:00
|
|
|
|
## Run ClickHouse server:
|
|
|
|
|
|
|
|
|
|
```
|
2021-05-05 14:56:20 +00:00
|
|
|
|
cd ClickHouse
|
|
|
|
|
./build/programs/clickhouse-server --config-file ./programs/server/config.xml
|
2021-05-05 14:35:28 +00:00
|
|
|
|
```
|
|
|
|
|
|
2021-09-19 20:05:54 +00:00
|
|
|
|
[Original article](https://clickhouse.com/docs/en/development/build_osx/) <!--hide-->
|