clickhouse源码编译(详细)

gcc10安装

# base centos 7
yum update
yum install -y gcc gcc-c++
yum install -y bzip2
wget -P /home https://mirrors.aliyun.com/gnu/gcc/gcc-10.2.0/gcc-10.2.0.tar.gz
cd /home && tar -xzvf /home/gcc-10.2.0.tar.gz
cd /home/gcc-10.2.0 && ./contrib/download_prerequisites
#这一步看网速,需要挺久的
mkdir /usr/lib/gcc/x86_64-redhat-linux/10.2.0
mkdir /home/gcc-build-10.2.0
cd /home/gcc-build-10.2.0
../gcc-10.2.0/configure --prefix=/usr/lib/gcc/x86_64-redhat-linux/10.2.0/ --enable-checking=release --enable-languages=c,c++ --disable-multilib
make && make install
mv /usr/bin/gcc /usr/bin/gcc-4.8.5
mv /usr/bin/g++ /usr/bin/g++-4.8.5
alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8.5 88 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8.5
alternatives --install /usr/bin/gcc gcc /usr/lib/gcc/x86_64-redhat-linux/10.2.0/bin/x86_64-pc-linux-gnu-gcc 99 --slave /usr/bin/g++ g++ /usr/lib/gcc/x86_64-redhat-linux/10.2.0/bin/x86_64-pc-linux-gnu-g++
alternatives --config gcc
#输入2回车

安装re2c和ninja

# 安装re2c
yum -y install git automake libtool
git clone https://github.com.cnpmjs.org/skvadrik/re2c.git re2c
cd re2c
mkdir -p m4
./autogen.sh && ./configure --prefix=/usr && make
make install
# 安装ninja
## 编译安装cmake3.15以上,此教程举例安装3.21
yum install -y openssl-devel
wget https://cmake.org/files/v3.21/cmake-3.21.0-rc1.tar.gz
 tar -zxvf cmake-3.21.0-rc1.tar.gz
cd cmake-3.21.0-rc1/
./bootstrap
gmake
gamke install
## 安装ninja
git clone https://github.com/ninja-build/ninja.git ninja
cd ninja
cmake -Bbuild-cmake -H.
cmake --build build-cmake
cp ninja /usr/bin/
ninja --version

安装python3

yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel
yum -y install python-pip
yum install libffi-devel -y
mv /usr/bin/python /usr/bin/python.bak
wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
tar -zxvf Python-3.7.9.tgz
./configure prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python

#修改yum配置
vi /usr/bin/yum
把#! /usr/bin/python修改为#! /usr/bin/python2

#
vi /usr/libexec/urlgrabber-ext-down
把#! /usr/bin/python修改为#! /usr/bin/python2


安装clickhouse

# 替换github的源(因为墙的原因)
git config --global url."https://hub.fastgit.org".insteadOf https://github.com
git clone https://github.com/ClickHouse/ClickHouse
cd ClickHouse
# 切换到指定版本
git tag -l
git checkout -b v21.7.5.29-stable

git submodule sync
git submodule update --init --recursive #等吧

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/clickhouse ../
ninja clickhouse #也是需要等很久,最好用screen 

你可能感兴趣的:(clickhouse源码编译(详细))