简单的 Clickhouse 单机版安装教程, 适合新手上手体验;
安装准备
- curl 工具,
yum install -y curl
; yum-utils 工具,yum install -y yum-utils
; - CentOS Linux 8 系统
- 检查系统是否支持安装 clickhouse
grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported."
- 取消打开文件数限制(需要重启服务器生效)
- 取消 SELINUX;
- 关闭防火墙
安装流程
- 添加 clickhouse 的 yum 镜像
curl -s https://packagecloud.io/install/repositories/altinity/clickhouse/script.rpm.sh | sudo bash
执行情况如下:
[root@centosvm ~]# curl -s https://packagecloud.io/install/repositories/altinity/clickhouse/script.rpm.sh | sudo bash
Detected operating system as centos/8.
Checking for curl...
Detected curl...
Downloading repository file: https://packagecloud.io/install/repositories/Altinity/clickhouse/config_file.repo?os=centos&dist=8&source=script
done.
Installing yum-utils...
Altinity_clickhouse-source 53 B/s | 819 B 00:15
Altinity_clickhouse-source 652 B/s | 3.9 kB 00:06
导入 GPG 公钥 0x0F6E36F6:
Userid: "https://packagecloud.io/altinity/clickhouse (https://packagecloud.io/docs#gpg_signing) <support@packagecloud.io>"
指纹: 7001 38A9 6A20 6B22 BF28 3C06 ED26 58F3 0F6E 36F6
来自: https://packagecloud.io/Altinity/clickhouse/gpgkey
Altinity_clickhouse-source 14 B/s | 296 B 00:21
依赖关系解决。
==============================================================================================================================================================================================================================================================================
软件包 架构 版本 仓库 大小
==============================================================================================================================================================================================================================================================================
安装:
yum-utils noarch 4.0.17-5.el8 baseos 68 k
事务概要
==============================================================================================================================================================================================================================================================================
安装 1 软件包
总下载:68 k
安装大小:20 k
下载软件包:
yum-utils-4.0.17-5.el8.noarch.rpm 31 kB/s | 68 kB 00:02
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 6.8 kB/s | 68 kB 00:10
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
安装 : yum-utils-4.0.17-5.el8.noarch 1/1
运行脚本: yum-utils-4.0.17-5.el8.noarch 1/1
验证 : yum-utils-4.0.17-5.el8.noarch 1/1
已安装:
yum-utils-4.0.17-5.el8.noarch
完毕!
Generating yum cache for Altinity_clickhouse...
导入 GPG 公钥 0x0F6E36F6:
Userid: "https://packagecloud.io/altinity/clickhouse (https://packagecloud.io/docs#gpg_signing) <support@packagecloud.io>"
指纹: 7001 38A9 6A20 6B22 BF28 3C06 ED26 58F3 0F6E 36F6
来自: https://packagecloud.io/Altinity/clickhouse/gpgkey
Generating yum cache for Altinity_clickhouse-source...
The repository is setup! You can now install packages.
执行完成之后, 会在 /etc/yum.repos.d
目录下创建一个 clickhouse 的仓库, 名为 Altinity_clickhouse.repo
;
- 查看镜像情况
yum list | grep clickhouse
注意
如果按照第一步设置之后, 第二步查找不到 clickhouse 安装包的话, 可以执行以下配置:
rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG
yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/clickhouse.repo
yum makecache
如果在线安装很慢, 也可以自行下载 rpm 包进行安装: https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/
注意要保持 rpm 的版本一致:
clickhouse-client-21.2.4.6-2.noarch.rpm
clickhouse-server-21.2.4.6-2.noarch.rpm
clickhouse-common-static-21.2.4.6-2.x86_64.rpm
- 安装 clickhouse 服务端
yum 方式安装: yum -y install clickhouse-server clickhouse-client
rpm 方式安装:
rpm -ivh clickhouse-common-static-21.2.4.6-2.x86_64.rpm
rpm -ivh clickhouse-server-21.2.4.6-2.noarch.rpm
rpm -ivh clickhouse-client-21.2.4.6-2.noarch.rpm
启动服务
[root@centosvm clickhouse]# systemctl start clickhouse-server
[root@centosvm clickhouse]# 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 2021-02-27 16:17:00 CST; 6s ago
Main PID: 22067 (clckhouse-watch)
Tasks: 3 (limit: 12332)
Memory: 56.4M
CGroup: /system.slice/clickhouse-server.service
├─22067 clickhouse-watchdog --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-server.pid
└─22068 /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-server.pid
2月 27 16:17:00 centosvm systemd[1]: Started ClickHouse Server (analytic DBMS for big data).
2月 27 16:17:00 centosvm clickhouse-server[22067]: Processing configuration file '/etc/clickhouse-server/config.xml'.
2月 27 16:17:00 centosvm clickhouse-server[22067]: Logging trace to /var/log/clickhouse-server/clickhouse-server.log
2月 27 16:17:00 centosvm clickhouse-server[22067]: Logging errors to /var/log/clickhouse-server/clickhouse-server.err.log
启动客户端验证
[root@centosvm clickhouse]# clickhouse-client
ClickHouse client version 21.2.4.6 (official build).
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 21.2.4 revision 54447.
centosvm :) show databases;
SHOW DATABASES
Query id: b753394b-7c78-4761-85df-39429143eba5
┌─name────┐
│ default │
│ system │
└─────────┘
2 rows in set. Elapsed: 0.002 sec.
centosvm :) quit;
Bye.
参考资料
- CentOS7.5 安装 ClickHouse 20.8.3.18单机版
- ClickHouse专业中文社区
- Clickhouse最佳实战之ClickHouse单机部署及运维指南
- ClickHouse单机模式,集群模式部署
Welcome to the clickhouse’s world!