安装Clickhouse集群
[toc]
# 基础环境信息
服务器:172.16.24.174、172.16.24.175、172.16.24.176
# 准备工作
# 关闭防火墙
# 查看是否关闭
systemctl status firewalld
# 关闭防火墙
systemctl disable firewalld
1
2
3
4
2
3
4
# 取消打开文件数限制
在所有节点
/etc/security/limits.conf
文件的末尾加入以下内容* soft nofile 65536 * hard nofile 65536 * soft nproc 131072 * hard nproc 131072
1
2
3
4在所有节点
vim /etc/security/limits.d/20-nproc.conf
文件的末尾加入以下内容* soft nofile 65536 * hard nofile 65536 * soft nproc 131072 * hard nproc 131072
1
2
3
4
# 安装依赖
在所有节点执行
yum install -y libtool
1在所有节点执行
yum install -y *unixODBC*
1
# 取消SELINUX
在所有节点执行
# vim /etc/selinux/config SELINUX=disabled
1
2
# 下载安装
# 下载地址
https://packages.clickhouse.com/rpm/stable/
1
下载一下四个rpm文件
-rw-rw-r-- 1 admin admin 78074 Nov 11 17:37 clickhouse-client-21.7.3.14-2.noarch.rpm
-rw-rw-r-- 1 admin admin 174283244 Nov 11 17:38 clickhouse-common-static-21.7.3.14-2.x86_64.rpm
-rw-rw-r-- 1 admin admin 786208040 Nov 11 17:42 clickhouse-common-static-dbg-21.7.3.14-2.x86_64.rpm
-rw-rw-r-- 1 admin admin 101969 Nov 11 17:42 clickhouse-server-21.7.3.14-2.noarch.rpm
1
2
3
4
2
3
4
23.9.5.29版本下载
https://packages.clickhouse.com/rpm/stable/clickhouse-common-static-dbg-23.9.5.29.x86_64.rpm https://packages.clickhouse.com/rpm/stable/clickhouse-server-23.9.5.29.x86_64.rpm https://packages.clickhouse.com/rpm/stable/clickhouse-client-23.9.5.29.x86_64.rpm https://packages.clickhouse.com/rpm/stable/clickhouse-common-static-23.9.5.29.x86_64.rpm
1
2
3
4
# 单机安装
# 在所有机器安装rpm
rpm -ivh *.rpm
1
安装过程中会提示Enter password for default user:
输入default默认密码,可以先不设置,后续再进行设置
查看安装情况
rpm -qa|grep clickhouse
1
# 修改配置文件
/etc/clickhouse-server/config.xml
把
<listen_host>::</listen_host>
的注释打开,这样的话才能让 ClickHouse 被除本机以外的服务器访问156 <listen_host>::</listen_host> 157 158 <!-- Same for hosts without support for IPv6: --> 159 <!-- <listen_host>0.0.0.0</listen_host> -->
1
2
3
4
在这个文件中,有 ClickHouse 的一些默认路径配置,比较重要的
数据文件路径:
/var/lib/clickhouse/ 日志文件路径:
/var/log/clickhouse-server/clickhouse-server.log 错误日志文件路径:
/var/log/clickhouse-server/clickhouse-server.err.log
# 设置免密
生成密码
echo -n <需要加密的密码> | sha256sum | tr -d '-'
# echo -n o0iyoL35#DnNpucqv | sha256sum | tr -d '-'
# 5a1a3048757d518b58c5578a315f76532df1701d1aed29d252de88734c432e52
1
2
3
2
3
在 /etc/clickhouse-server/users.xml
中添加
<password_sha256_hex>5a1a3048757d518b58c5578a315f76532df1701d1aed29d252de88734c432e52</password_sha256_hex>
1
# 启动服务
systemctl start clickhouse-server
1
查看服务状态
# systemctl status clickhouse-server
● clickhouse-server.service - ClickHouse Server (analytic DBMS for big data)
Loaded: loaded (/etc/systemd/system/clickhouse-server.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2022-11-12 13:43:23 CST; 24s ago
Main PID: 4109 (clckhouse-watch)
CGroup: /system.slice/clickhouse-server.service
├─4109 clickhouse-watchdog --config=/etc/clickhouse-server/config.xml --pid-file=/run/cl...
└─4119 /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=...
Nov 12 13:43:23 dev-bigdata-24-174 systemd[1]: Started ClickHouse Server (analytic DBMS for big data).
Nov 12 13:43:23 dev-bigdata-24-174 clickhouse-server[4109]: Processing configuration file '/etc/c...'.
Nov 12 13:43:23 dev-bigdata-24-174 clickhouse-server[4109]: Logging trace to /var/log/clickhouse-...og
Nov 12 13:43:23 dev-bigdata-24-174 clickhouse-server[4109]: Logging errors to /var/log/clickhouse...og
Nov 12 13:43:23 dev-bigdata-24-174 clickhouse-server[4109]: Processing configuration file '/etc/c...'.
Nov 12 13:43:23 dev-bigdata-24-174 clickhouse-server[4109]: Saved preprocessed configuration to '...'.
Nov 12 13:43:23 dev-bigdata-24-174 clickhouse-server[4109]: Processing configuration file '/etc/c...'.
Nov 12 13:43:23 dev-bigdata-24-174 clickhouse-server[4109]: Saved preprocessed configuration to '...'.
Hint: Some lines were ellipsized, use -l to show in full.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 使用Client连接Server
# 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.
dev-bigdata-24-174 :) show databases;
SHOW DATABASES
Query id: a89d4402-8d03-4656-962b-87bb5738734a
┌─name────┐
│ default │
│ system │
└─────────┘
2 rows in set. Elapsed: 0.003 sec.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
-m :可以在命令窗口输入多行命令
# 在DBeaver中连接
点击测试连接
上次更新: 2024/04/08, 15:59:58