CentOS7 linux系统多种方式安装ClickHouse数据库

  clickhouse是由俄罗斯Yandex公司开发的列式存储数据库,于2016年开源,clickhouse的定位是快速的数据分析,对于处理海量数据的情况性能非常好,在网上也有很多测试的案例,在大数据的情况下性能远超过其他数据库,并且不依赖于hadoop的生态系统,都是独立使用,在大数据存储业务上还是可以考虑的.

  clickhouse官网地址:https://clickhouse.yandex/,文档地址:https://clickhouse.yandex/docs/en/

    另外推荐单页文档,更方便:https://clickhouse.yandex/docs/en/single

下面开始安装

  安装依赖项

  安装过程需要curl下载包。此外,ClickHouse测试包在EPEL中有一些依赖关系,因此epel-release必须安装,以防您想要安装ClicKhouse测试包确保curl安装在系统上

sudo yum install -y curl
 #如果安装了测试包,添加epel-release 
sudo yum install -y epel-release 

让我们下载并运行packagecloud.io提供的安装shell脚本

对于CentOS 6和7

curl -s https://packagecloud.io/install/repositories/altinity/clickhouse/script.rpm.sh | sudo bash

脚本后安装包

首先,确保我们有可用于安装的ClickHouse软件包

sudo yum list 'clickhouse*'

ClickHouse包应该列为可用,如下所示:

#可用包组
clickhouse-client.x86_64 18.1.0-1.el7 Altinity_clickhouse
clickhouse-common-static.x86_64 18.1.0-1.el7 Altinity_clickhouse
clickhouse-compressor.x86_64 1.1.54336-3.el7 Altinity_clickhouse
clickhouse-debuginfo.x86_64 18.1.0-1.el7 Altinity_clickhouse
clickhouse-mysql.noarch 0.0.20180319-1 Altinity_clickhouse
clickhouse-server.x86_64 18.1.0-1.el7 Altinity_clickhouse
clickhouse-server-common.x86_64 18.1.0-1.el7 Altinity_clickhouse
clickhouse-test.x86_64 18.1.0-1.el7 Altinity_clickhouse

  

有多个软件包可用(新版本和旧工具),其中一些已经弃用,因此无需安装所有可用的RPM。

现在让我们安装ClickHouse主要部件 - 服务器和客户端应用程序。

sudo yum install -y clickhouse-server clickhouse-client

 并验证它是否已列为已安装

 sudo yum list installed 'clickhouse*'

  ClickHouse软件包应列为已安装,如下所示:

Installed Packages
clickhouse-client.x86_64                 18.1.0-1.el7           @Altinity_clickhouse
clickhouse-common-static.x86_64          18.1.0-1.el7           @Altinity_clickhouse
clickhouse-server.x86_64                 18.1.0-1.el7           @Altinity_clickhouse
clickhouse-server-common.x86_64          18.1.0-1.el7           @Altinity_clickhouse

  确保ClickHouse服务器正在运行

sudo /etc/init.d/clickhouse-server restart

  然后连接到它 clickhouse-client

clickhouse-client

  ClickHouse服务器应该响应,如下所示:

ClickHouse客户端版本18.1.0。
连接到localhost:9000作为用户默认值。
连接到ClickHouse服务器版本18.1.54396。

:)

  

 

 

第二种方式手动安装:

让我们手动添加Altinity的repo

安装所需的包

我们需要在beforehands之前安装以下软件包:

  • pygpgme - 帮助处理gpg签名
  • yum-utils - 包含用于处理源RPM的工具
  • coreutils- 包含核心工具,我们稍后需要tee命令
  • epel-release - 包含ClickHouse测试包依赖项
  • sudo yum install -y pygpgme yum-utils coreutils epel-release

     

  • 现在让我们创建yum存储库配置文件:/etc/yum.repos.d/altinity_clickhouse.repo根据您运行的CentOS版本,您可能需要EL 6或7版本的文件

EL6 repo file

cat <<"EOF" | sudo tee /etc/yum.repos.d/altinity_clickhouse.repo
[altinity_clickhouse]
name=altinity_clickhouse
baseurl=https://packagecloud.io/altinity/clickhouse/el/6/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/altinity/clickhouse/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

[altinity_clickhouse-source]
name=altinity_clickhouse-source
baseurl=https://packagecloud.io/altinity/clickhouse/el/6/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/altinity/clickhouse/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOF

  

EL7 repo file

cat <<"EOF" | sudo tee /etc/yum.repos.d/altinity_clickhouse.repo
[altinity_clickhouse]
name=altinity_clickhouse
baseurl=https://packagecloud.io/altinity/clickhouse/el/7/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/altinity/clickhouse/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

[altinity_clickhouse-source]
name=altinity_clickhouse-source
baseurl=https://packagecloud.io/altinity/clickhouse/el/7/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/altinity/clickhouse/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

  

更新缓存

创建repo文件后,让我们yum使用新添加的altinity_clickhouserepo中的包更新缓存

sudo yum -q makecache -y --disablerepo = ' * ' - enablerepo = ' altinity_clickhouse '

  安装到此结束:)

 

 

第三种方法为离线安装:

查看系统版本为CentOS7.6

执行命令查看是否支持安装: 

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

  

然后下载ClickHouse所需的离线安装包,下载地址:http://repo.red-soft.biz/repos/clickhouse/stable/el7/

wget http://repo.red-soft.biz/repos/clickhouse/stable/el7/clickhouse-client-1.1.54236-4.el7.x86_64.rpm
wget http://repo.red-soft.biz/repos/clickhouse/stable/el7/clickhouse-compressor-1.1.54236-4.el7.x86_64.rpm
wget http://repo.red-soft.biz/repos/clickhouse/stable/el7/clickhouse-debuginfo-1.1.54236-4.el7.x86_64.rpm
wget http://repo.red-soft.biz/repos/clickhouse/stable/el7/clickhouse-server-1.1.54236-4.el7.x86_64.rpm
wget http://repo.red-soft.biz/repos/clickhouse/stable/el7/clickhouse-server-common-1.1.54236-4.el7.x86_64.rpm

  下载完毕开始安装

    rpm -ivh clickhouse-server-common-1.1.54236-4.el7.x86_64.rpm
    rpm -ivh clickhouse-server-1.1.54236-4.el7.x86_64.rpm
  报错:错误:依赖检测失败:libodbc.so.2()(64bit) 被 clickhouse-server-1.1.54236-4.el7.x86_64 需要
  解决办法:yum install *ODBC*
    rpm -ivh clickhouse-debuginfo-1.1.54236-4.el7.x86_64.rpm
    rpm -ivh clickhouse-compressor-1.1.54236-4.el7.x86_64.rpm
    rpm -ivh clickhouse-client-1.1.54236-4.el7.x86_64.rpm  

 安装完成后关闭防火墙和Selinux

systemctl stop firewalld.service #停止firewall 
systemctl disable firewalld.service #禁止firewall开机启动
setenforce 0 #关闭selinux

 启动clickhouse服务端 

service clickhouse-server start

  通过客户端连接 

clickhouse-client –m 

  

出现笑脸代表成功:)

posted @ 2019-06-19 09:51  Rich七哥  阅读(3728)  评论(0编辑  收藏  举报