# 2. ClickHouse 安装
CentOS7
# 2.1 准备工作
关闭防火墙
systemctl disable firewalld
取消打开文件数限制
sudo vim /etc/security/limits.conf sudo vim /etc/security/limits.d/20-nproc.conf
分别在文件末尾添加:
* soft nofile 65536 * hard nofile 65536 * soft nproc 131072 * hard nproc 131072
安装 libtoll 和 unixODBC 依赖
sudo yum install -y libtool sudo yum install -y *unixODBC*
取消 SELINUX
sudo vim /etc/selinux/config
将 SELINUX 修改为 disabled
重启
reboot
# 2.2 单机安装
创建 clickhouse 目录
mkdir -p /opt/software/clickhouse
进入 clickhouse 目录
cd /opt/software/clickhouse
下载安装包
在该网站 https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/ 中找到想要下载的版本的安装包,总共需要 4 个:
- clickhouse-client
- clickhouse-common-static
- clickhouse-common-static-dbg
- clickhouse-server
本次使用的版本为:21.7.3.14
wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-client-21.7.3.14-2.noarch.rpm wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-common-static-21.7.3.14-2.x86_64.rpm wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-common-static-dbg-21.7.3.14-2.x86_64.rpm wget https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-server-21.7.3.14-2.noarch.rpm
安装
sudo rpm -ivh *.rpm
安装后,常用的默认路径:
- bin -> /usr/bin/
- conf -> /etc/clickhouse-server/
- lib -> /var/lib/clickhouse/
- log -> /var/log/clickhouse/
修改配置文件,支持远程访问
sudo vim /etc/clickhouse-server/config.xml
查找 listen,将下面这一行的注释打开:
# 2.3 测试结果
启动 clickhouse-server
sudo systemctl start clickhouse-server #或者:sudo clickhouse start
使用客户端连接
clickhouse-client -m
-m
: 可以在命令窗口输入多行命令,用分号来识别结尾;
输出:(默认端口:9000)
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. localhost :)
执行命令
localhost :) show databases; SHOW DATABASES Query id: 2559789d-835a-4806-9cb3-cff05f14c25f ┌─name────┐ │ default │ │ system │ └─────────┘ 2 rows in set. Elapsed: 0.004 sec.
测试完毕,安装成功。