centos7下编译clickhouse

Centos7 编译安装Clickhouse

  1. 检查是否支持SSE4.2
  2. 安装依赖项
  3. 安装高版本 gcc
  4. 安装cmake 3
  5. 源码安装Clickhouse
  6. 启动服务

 

 

1、检查是否支持SSE4.2

grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"

 

2、安装依赖项

yum install git cmake ninja-build libicu-devel clang libicu-devel readline-devel mysql-devel openssl-devel unixODBC_devel bzip2 -y

 

3、安装高版本 gcc

wget ftp://gnu.mirror.iweb.com/gcc/gcc-7.5.0/gcc-8.2.0.tar.xz

 

tar xvf gcc-8.2.0.tar.xz

 

cd gcc-8.2.0

./contrib/download_prerequisites

mkdir build

cd build

../configure --prefix=/opt/gcc8 --enable-languages=c,c++   --disable-multilib

export THREADS=$(grep -c ^processor /proc/cpuinfo)

make -j $THREADS

make install

 

添加软连接,不改变系统默认的值

cd /opt/gcc8/bin/

ln -s gcc cc

ln -s g++ g++-8

ln -s gcc gcc-8

ln -s /opt/gcc8/bin/* /usr/local/bin/

 

添加环境变量

vim ~/.bashrc

export GCC7_HOME=/opt/gcc8

export PATH=$GCC8_HOME/bin:$PATH

export CC=gcc-8

export CXX=g++-8

source ~/.bashrc

 

验证版本:

 

 

4、安装cmake 3,保留替换系统默认的

准备软件

wget https://cmake.org/files/v3.14/cmake-3.14.5-Linux-x86_64.tar.gz

tar zxvf cmake-3.14.5-Linux-x86_64.tar.gz -C /opt

ln -s cmake-3.14.5-Linux-x86_64 cmake

 

添加环境变量

vim /etc/profile

export CMAKE_HOME=/opt/cmake

export PATH=$CMAKE_HOME/bin:$PATH

source /etc/profile

 

5、安装ninja

wget https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-linux.zip

unzip ninja-linux.zip -d /usr/local/bin/

 

测试版本:

# ninja --version

1.9.0

 

6、源码安装Clickhouse

#clone 源码

git clone https://github.com/ClickHouse/ClickHouse

cd ClickHouse

git submodule sync

git submodule update --init --recursive #这个过程会比较长,需要下载很多依赖包

 

切换分支

git tag -l

git checkout master

 

mkdir build

cd build

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/clickhouse ../

ninja clickhouse

 

注意:

这里编译安装后,并没有在指定路径下生产clickhouse目录

 

编译成功,显示如下:

 

 

#将配置文件copy 到/usr/local/clickhouse/etc

 

mkdir -p /usr/local/clickhouse/etc

cd ../dbms/programs/server

cp config.xml /usr/local/clickhouse/etc

cp users.xml /usr/local/clickhouse/etc

 

#将clickhouse执行文件copy 到/usr/local/clickhouse/bin

mkdir -p /usr/local/clickhouse/bin

cp dbms/programs/clickhouse /usr/local/clickhouse/bin

 

查看clickhouse命令帮助

 

 

7、启动服务

启动clickhouse-server

clickhouse server --config-file=/usr/local/clickhouse/etc/config.xml

  

启动客户端

clickhouse client

clickhouse client --host=example.com

clickhouse client -m #多线程

posted on 2019-11-30 09:20  gentleman_hai  阅读(3413)  评论(0编辑  收藏  举报

导航