ClickHouse 安装部署
1、前置环境准备
1.1、查看是否存在旧版本ClickHouse
[hui@hadoop201 ~]$ rpm -qa |grep clickhouse
如果存在安装数据可以卸载
yum remove -y clickhouse-common-static yum remove -y clickhouse-server-common rm -rf /var/lib/clickhouse rm -rf /etc/clickhouse-* rm -rf /var/log/clickhouse-server
注意:安装卸载使用root用户
1.2、关闭防火墙
systemctl stop firewalld
systemctl disable firewalld.service
1.3、CentOS设置打开文件数限制
查看限制
[hui@hadoop201 ~]$ ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 63372 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 65536 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 131072 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
sudo vim /etc/security/limits.conf文件的末尾加入以下内容
[hui@hadoop201 ~]$ sudo vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
sudo vim /etc/security/limits.d/20-nproc.conf文件的末尾加入以下内容
[hui@hadoop201 ~]$ sudo vim /etc/security/limits.d/20-nproc.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
参数说明:
- 第一列表示用户组,* 表示所有用户所有组,hui@hui 表示hui的组下的hui用户;
- 第二列:软限制和隐限制,soft 要小于 hard
- 第三列:nofile 打开的文件数 nproc 进程数
- 第四列:具体数
以上配置完毕无需重启,重新登录系统即生效。
1.4、安装依赖
[hui@hadoop201 ~]$ sudo yum install -y libtool
[hui@hadoop201 ~]$ sudo yum install -y *unixODBC*
1.5、CentOS取消SELINUX
修改/etc/selinux/config中的SELINUX=disabled
[hui@hadoop201 ~]$ sudo vim /etc/selinux/config
SELINUX=disabled
设置完毕 SELINUX 如果不方便重启机器可以使其临时生效;
setenforce 0
2、安装 ClickHouse
2.1、上传安装文件
[hui@hadoop201 clickhouse]$ ll total 938164 -rw-rw-r-- 1 hui hui 78074 Jul 27 2021 clickhouse-client-21.7.3.14-2.noarch.rpm -rw-rw-r-- 1 hui hui 174283244 Jul 27 2021 clickhouse-common-static-21.7.3.14-2.x86_64.rpm -rw-rw-r-- 1 hui hui 786208040 Jul 27 2021 clickhouse-common-static-dbg-21.7.3.14-2.x86_64.rpm -rw-rw-r-- 1 hui hui 101969 Jul 27 2021 clickhouse-server-21.7.3.14-2.noarch.rpm
2.2、安装 rpm 文件
[root@hadoop201 clickhouse]# rpm -ivh *.rpm
2.3、配置
配置其它主机可以访问clickhouse服务——远程访问
[hui@hadoop201 software]$ sudo vim /etc/clickhouse-server/config.xml
把 <listen_host>::</listen_host> 的注释打开,这样的话才能让ClickHouse被除本机以外的服务器访问
安装后路径说明
bin/ ==> /usr/bin/ conf/ ==> /etc/clickhouse-server/ lib/ ==> /var/lib/clickhouse/ lib 也存放数据 log/ ==> /var/log/clickhouse/
config.xml 一些配置说明
<listen_host>::</listen_host> #远程主机可防问当前clickhouse服务 <!-- Path to data directory, with trailing slash. 数据目录 --> <path>/var/lib/clickhouse/</path> <log>/var/log/clickhouse-server/clickhouse-server.log</log> 日志 <errorlog>/var/log/clickhouse-server/clickhouse-server.err.log</errorlog> 错误日志
配置文件说明
[root@hadoop201 clickhouse-server]# pwd
/etc/clickhouse-server
[root@hadoop201 clickhouse-server]# ll
total 64
dr-x------ 2 clickhouse clickhouse 6 Aug 2 08:35 config.d 默认配置
-r-------- 1 clickhouse clickhouse 56004 Aug 6 16:40 config.xml 服务端配置
dr-x------ 2 clickhouse clickhouse 6 Aug 2 08:24 users.d 用户密码权限CPU内存在这里配置
-r-------- 1 clickhouse clickhouse 6053 Jul 14 2021 users.xml 默认配置
2.4、启动
[root@hadoop201 clickhouse]# clickhouse start chown --recursive clickhouse '/var/run/clickhouse-server/' Will run su -s /bin/sh 'clickhouse' -c '/usr/bin/clickhouse-server --config-file /etc/clickhouse-server/config.xml --pid-file /var/run/clickhouse-server/clickhouse-server.pid --daemon' Waiting for server to start Waiting for server to start Server started
此时ClickHouse 已经启动
[root@hadoop201 clickhouse]# clickhouse status /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 3154. The process with pid = 3154 is running.
clickhouse 默认端口 9000,如和现有端口冲突,建议修改。配置文件在 /etc/clickhouse-server/config.xml
2.5、连接测试
[root@hadoop201 clickhouse]# clickhouse-client -m ClickHouse client version 21.7.3.14 (official build). Connecting to localhost:9000 as user default. Connected to ClickHouse server version 21.7.3 revision 54449. hadoop201 :) show databases; SHOW DATABASES Query id: f052da3a-a091-4bf5-95cd-e6045db2f6cb ┌─name────┐ │ default │ │ system │ └─────────┘ 2 rows in set. Elapsed: 0.005 sec.
至此,CLickHouse 安装完毕。