本演示服务器系统为CentOS7,Clickhouse选用版本为19.17.10.1,在安装之前需要准备好环境及离线rpm安装包。
需要下载以下4个安装包文件:
clickhouse-client-19.17.10.1-1.el7.x86_64.rpm
clickhouse-common-static-19.17.10.1-1.el7.x86_64.rpm
clickhouse-server-19.17.10.1-1.el7.x86_64.rpm
clickhouse-server-common-19.17.10.1-1.el7.x86_64.rpm
推荐下载地址:Altinity/clickhouse - Packages · packagecloudhttps://packagecloud.io/altinity/clickhouse
或者:clickhouse-19.17.10.1-1.el7.x86_64.rpm.zip-其它文档类资源-CSDN下载Clickhouse在CentOS下离线安装包更多下载资源、学习资料请访问CSDN下载频道.https://download.csdn.net/download/wang727997856/41865867
关闭防火墙
sudo systemctl stop firewalld.service
禁用开机启动防火墙
sudo systemctl disable firewalld.service
验证服务器的CPU是否支持SSE 4.2指令集,因为向量化执行需要该特性
grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"
需要为本地服务器设置FQDN
hostnamectl --static set-hostname node1.ch.com
验证修改是否生效
hostname -f
node1.ch.com
最后需要配置hosts文件,配置后结果如下:
vim /etc/hosts
192.168.1.7 node1.ch.com node1
将已经下载的四个rpm安装包上传至/chbase/setup路径下,进入该目录
cd /chbase/setup
执行如下命令即可安装rpm文件:
sudo rpm -ivh ./*.rpm
准备中... ( 25%################################# [100%]
正在升级/安装...
1:clickhouse-server-common-19.17.10 ( ################################# [ 25%]
2:clickhouse-common-static-19.17.10 ( ################################# [ 50%]
3:clickhouse-server-19.17.10.1-1.el ( ################################# [ 75%]
Create user clickhouse.clickhouse with datadir /var/lib/clickhouse
4:clickhouse-client-19.17.10.1-1.el ( ################################# [100%]
Create user clickhouse.clickhouse with datadir /var/lib/clickhouse
因为是离线安装,所以安装过程可能出现缺少依赖包情况,需要手动补齐缺失依赖...
sudo service clickhouse-server start
Start clickhouse-server service: Path to data directory in /etc/clickhouse-server/config.xml: /var/lib/clickhouse/
DONE
clickhouse-client
ClickHouse client version 19.17.10.1.
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 19.17.10 revision 54428.
node1.ch.com :)
show databases;
SHOW DATABASES
┌─name────┐
│ default │
│ system │
└─────────┘2 rows in set. Elapsed: 0.010 sec.
到此,单节点的Clickhouse数据库已经安装完成,如果需要安装新的节点,重复上述安装过程即可。在新节点安装完之后,记得在/etc/hosts文件中添加每台服务器节点的FQDN,例如:
# cat /etc/hosts
...
192.168.1.8 node2.ch.com node2
192.168.1.9 node3.ch.com node3
刚安装的数据库中有一个默认用户default,没有密码,可以通过配置文件users.xml新增用户
vim /etc/clickhouse-server/users.xml
在
rocker
::/0
default
default
此时,数据库无法使用其他机器上的客户端连接,首先关闭防火墙或者对外开放8123和9000端口,然后取消/etc/clickhouse-server/config.xml文件中
sudo vim /etc/clickhouse-server/config.xml
sudo /etc/init.d/clickhouse-server restart