技术交流QQ群:①185473046   ②190706903   ③203744115   网站地图
登录

下次自动登录
现在的位置: 首页clickhouse>正文
Linux下ClickHouse单节点安装部署
2023年05月02日 clickhouse 暂无评论 ⁄ 被围观 2,532次+

ClickHouse是一个用于联机分析(OLAP)的列式数据库管理系统(DBMS)。

官方网站:https://clickhouse.com/

官方文档:https://clickhouse.com/docs/zh

下载地址:https://packages.clickhouse.com/rpm/stable/ #稳定版本

或者:https://packages.clickhouse.com/rpm/lts/ #长期支持版

1、关闭selinux

sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config

setenforce 0

2、关闭防火墙

ClickHouse提供两个网络端口: TCP 默认9000,HTTP 默认8123,建议在内网环境下部署ClickHouse,关闭服务器防火墙。

CentOS-7.x默认使用的是firewall作为防火墙,关闭

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

systemctl mask firewalld

systemctl stop firewalld

yum remove firewalld

3、配置系统文件句柄数量

vi /etc/security/limits.d/clickhouse.conf #文件句柄数量的配置

clickhouse soft nofile 1048576

clickhouse hard nofile 1048576

:wq! #保存退出

4、安装ClickHouse

4.1、安装ClickHouse所需的依赖包

yum install -y libtool  *unixODBC*

4.2、分别下载client,static,static-dbg,keeper-dbg和server五个安装包,五个包的版本要一致,这里以23.3.2.37版本为例。

clickhouse-client-23.3.2.37.x86_64.rpm

clickhouse-common-static-23.3.2.37.x86_64.rpm

clickhouse-common-static-dbg-23.3.2.37.x86_64.rpm

clickhouse-server-23.3.2.37.x86_64.rpm

clickhouse-keeper-dbg-23.3.2.37.x86_64.rpm

把下载的五个包放到一个空的文件夹下,比如:/usr/local/src 进入该目录下,执行rpm -ivh *.rpm命令安装,默认回车

rpm -ivh *.rpm   #安装过程中会提示输入密码,直接回车不设置密码,密码后面我们在配置文件中设置。

4.3、目录说明

/etc/clickhouse-server:服务端的配置文件目录,包括全局配置config.xml和用户配置users.xml等

/etc/clickhouse-client:客户端配置,包括conf.d文件夹和config.xml文件

/var/lib/clickhouse:默认的数据存储目录,建议修改路径到大容量磁盘

/var/log/clickhouse-server:默认保存日志的目录,建议修改路径到大容量磁盘

4.4、新建存储目录

mkdir -p /data/server/clickhouse   #数据存储目录

mkdir -p /data/server/clickhouse/log  #日志存放目录

修改目录权限:

chown clickhouse:clickhouse  /data/server/clickhouse  -R

chown clickhouse:clickhouse  /data/server/clickhouse/log  -R

chmod 755 /data/server/clickhouse -R

chmod 755 /data/server/clickhouse/log  -R

4.5、编辑config.xml配置文件,添加如下内容

cp /etc/clickhouse-server/config.xml   /etc/clickhouse-server/config.xml.bak

vi /etc/clickhouse-server/config.xml

<timezone>Asia/Shanghai</timezone>  #修改时区

<listen_host>::</listen_host> #开启外部访问

<path>/data/server/clickhouse/</path> #修改数据存放路径,默认是<path>/var/lib/clickhouse</path>

<level>none</level> #不记录日志

<!-- <log>/data/server/clickhouse/log/clickhouse-server.log</log> --> #不记录日志

<!-- <errorlog>/data/server/clickhouse/log/clickhouse-server.err.log</errorlog> --> #不记录日志

<max_open_files>1048576</max_open_files> #文件句柄数量的配置

<http_port>8123</http_port>  #http默认端口

<tcp_port>9000</tcp_port>  #tcp默认端口

<max_concurrent_queries>4096</max_concurrent_queries> #限制的是活跃查询的数量,是对正在执行或排队等待执行的查询进行限制

<max_connections>4096</max_connections> #限制的是客户端连接的数量,是对同时与 ClickHouse 建立的连接进行限制

:wq! #保存退出

4.6、设置数据库密码,默认用户名是:default

cp /etc/clickhouse-server/users.xml /etc/clickhouse-server/users.xml.bak

vi /etc/clickhouse-server/users.xml

<password>Abcd123456++</password>

:wq! #保存退出

#启动clickhouse

systemctl start clickhouse-server

systemctl status clickhouse-server

systemctl stop clickhouse-server

systemctl restart clickhouse-server

systemctl enable clickhouse-server

#如果启动报错,请再次检查设置权限

chown -R clickhouse:clickhouse /var/lib/clickhouse

chown -R clickhouse:clickhouse /var/log/clickhouse-server

chown -R clickhouse:clickhouse /etc/clickhouse-server

chown -R clickhouse:clickhouse /etc/clickhouse-client

chmod 755 /var/lib/clickhouse -R

chmod 755 /var/log/clickhouse-server -R

chmod 755 /etc/clickhouse-server -R

chmod 755 /etc/clickhouse-client -R

4.7、进入客户端,输入之前设置的密码

clickhouse-client --password

show databases;   #查看数据库

exit;  #退出控制台

4.8、查看clickhouse相关信息

#查看端口

netstat -tunlpa | grep 9000 #yum install -y net-tools

#查看日志

journalctl -xe | grep clickhouse-server

#命令行后台启动

nohup sudo -u "clickhouse" /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml &

#看看进程

lsof -i:8123

ps -ef | grep clickhouse-server

#卸载ClickHouse

rpm -qa | grep clickhouse

clickhouse-client-23.3.2.37-1.x86_64

clickhouse-keeper-dbg-23.3.2.37-1.x86_64

clickhouse-common-static-23.3.2.37-1.x86_64

clickhouse-server-23.3.2.37-1.x86_64

clickhouse-common-static-dbg-23.3.2.37-1.x86_64

#执行卸载命令

rpm -e clickhouse-client-23.3.2.37-1.x86_64

rpm -e clickhouse-keeper-dbg-23.3.2.37-1.x86_64

rpm -e clickhouse-server-23.3.2.37-1.x86_64

rpm -e clickhouse-common-static-dbg-23.3.2.37-1.x86_64

rpm -e clickhouse-common-static-23.3.2.37-1.x86_64

至此,Linux下ClickHouse单节点安装部署完成。

     

  系统运维技术交流QQ群:①185473046 系统运维技术交流□Ⅰ ②190706903 系统运维技术交流™Ⅱ ③203744115 系统运维技术交流™Ⅲ

给我留言

您必须 [ 登录 ] 才能发表留言!



Copyright© 2011-2024 系统运维 All rights reserved
版权声明:本站所有文章均为作者原创内容,如需转载,请注明出处及原文链接
陕ICP备11001040号-3