环境准备
参考文档?How to Build ClickHouse on Linux | ClickHouse Docs
下载源码
1.git直接下载
git 下载指定分支源码
git clone?--branch 22.4?--recursive git@github.com:ClickHouse/ClickHouse.git
2.git 镜像下载
git clone 代码量巨大,又由于项目以来众多子项目都需要拉取,推荐先clone ck, 然后修改.gitmodules中 项目的github地址
git clone ?--branch 22.4 git@github.com:ClickHouse/ClickHouse.git
cd ClickHouse
# 修改.gitmodules目录里面的url地址
vim .gitmodules
git submodule init
git submodule update
3.源码打包下载
和官方版本一致
wget?https://github.com/ClickHouse/ClickHouse/archive/refs/tags/v22.4.5.9-stable.tar.gz
编译
如下编译运行,这里使用ninja加速编译
cd Clickhouse
rm -rf build
mkdir build
cd build
export CC=clang CXX=clang++
cmake .. \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_CLICKHOUSE_ALL=OFF \
-DENABLE_CLICKHOUSE_SERVER=ON \
-DENABLE_CLICKHOUSE_CLIENT=ON \
-DENABLE_LIBRARIES=OFF \
-DUSE_UNWIND=ON \
-DENABLE_UTILS=OFF \
-DENABLE_TESTS=OFF \
-DENABLE_AVX512=ON
CMake这里配置编译个最小版本,可参考CMake in ClickHouse | ClickHouse Docs。DENABLE_AVX512 表示这里默认开启AVX512优化,需要对应CPU支持。然后运行ninja编译运行如下,-j指定编译并行度:
ninja -j 1 clickhouse-server clickhouse-client
运行
编译产物路径?ClickHouse/<build_dir>/programs/clickhouse
如下运行server
../../build/programs/clickhouse server--config-file ./programs/server/config.xml
如下运行client连接并执行
clickhouse client --host 127.0.0.1
参考?Getting Started Guide for Building ClickHouse | ClickHouse Docs
参考?CentOS 7编译安装ClickHouse
|