1.1准备工作
1.1.1 确定防火墙处于关闭状态
[root@dn3 ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
1.1.2 CentOS取消打开文件数限制
1)在dn3的 /etc/security/limits.conf文件的末尾加入以下内容
注意:以下操作会修改 Linux 系统配置,如果操作不当可能导致虚拟机无法启动,建议在执行以下操作之前给三台虚拟机分别打个快照。(快照拍摄需要在关机状态下执行)
[bigdata_admin@dn3~]$ sudo vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
2)在dn3的/etc/security/limits.d/20-nproc.conf文件的末尾加入以下内容
[bigdata_admin@dn3~]$ sudo vim /etc/security/limits.d/20-nproc.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
3)执行同步操作
[bigdata_admin@dn3~]$ sudo /home/bigdata_admin/bin/xsync /etc/security/limits.conf
[bigdata_admin@dn3~]$ sudo /home/bigdata_admin/bin/xsync /etc/security/limits.d/20-nproc.conf
1.1.3 安装依赖
[bigdata_admin@dn3~]$ sudo yum install -y libtool
[bigdata_admin@dn3~]$ sudo yum install -y *unixODBC*
在dn4、dn5上执行以上操作
1.1.4 CentOS取消SELINUX
1)修改/etc/selinux/config中的SELINUX=disabled
[bigdata_admin@dn3~]$ sudo vim /etc/selinux/config
SELINUX=disabled
注意:别改错了
2)执行同步操作
[bigdata_admin@dn3~]$ sudo /home/bigdata_admin/bin/xsync /etc/selinux/config
3)重启三台服务器
[bigdata_admin@dn3~]$ sudo reboot
1.2单机安装
官网:https://clickhouse.yandex/
下载地址:https://repo.clickhouse.tech/rpm/stable/x86_64/
1.2.1 在dn3的/opt/software下创建clickhouse目录
[bigdata_admin@dn3~]$ cd /opt/software/
[bigdata_admin@dn3software]$ mkdir clickhouse
1.2.2 将4个rpm安装文件上传到dn3的/opt/software/clickhouse目录下
[bigdata_admin@dn3clickhouse]$ ll
总用量 1262276
-rw-rw-r-- 1 bigdata_admin bigdata_admin 56708 4月 7 12:42 clickhouse-client-20.4.5.36-2.noarch.rpm
-rw-rw-r-- 1 bigdata_admin bigdata_admin 117222435 4月 7 12:42 clickhouse-common-static-20.4.5.36-2.x86_64.rpm
-rw-rw-r-- 1 bigdata_admin bigdata_admin 1175204526 4月 7 12:42 clickhouse-common-static-dbg-20.4.5.36-2.x86_64.rpm
-rw-rw-r-- 1 bigdata_admin bigdata_admin 78318 4月 7 12:42 clickhouse-server-20.4.5.36-2.noarch.rpm
1.2.3 将安装文件同步到dn4、dn5
[bigdata_admin@dn3 software]$ xsync clickhouse/
1.2.4 分别在三台机子上安装这4个rpm文件
[bigdata_admin@dn3 clickhouse]$ sudo rpm -ivh *.rpm
警告:clickhouse-client-20.4.5.36-2.noarch.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID e0c56bd4: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:clickhouse-common-static-20.4.5.3################################# [ 25%]
2:clickhouse-client-20.4.5.36-2 ################################# [ 50%]
3:clickhouse-server-20.4.5.36-2 ################################# [ 75%]
Created symlink from /etc/systemd/system/multi-user.target.wants/clickhouse-server.service to /etc/systemd/system/clickhouse-server.service.
Path to data directory in /etc/clickhouse-server/config.xml: /var/lib/clickhouse/
4:clickhouse-common-static-dbg-20.4################################# [100%]
查看安装情况
[bigdata_admin@dn3 clickhouse]$ sudo rpm -qa|grep clickhouse
clickhouse-client-20.4.5.36-2.noarch
clickhouse-common-static-20.4.5.36-2.x86_64
clickhouse-server-20.4.5.36-2.noarch
clickhouse-common-static-dbg-20.4.5.36-2.x86_64
1.2.5 修改配置文件
[bigdata_admin@dn3 clickhouse]$ sudo vim /etc/clickhouse-server/config.xml
1)配置允许被外部节点访问
把 <listen_host>::</listen_host>
的注释打开,这样的话才能让ClickHouse被除本机以外的服务器访问
2)分发配置文件
[bigdata_admin@dn3 clickhouse]$ sudo /home/bigdata_admin/bin/xsync /etc/clickhouse-server/config.xml
在这个文件中,有ClickHouse的一些默认路径配置,比较重要的
- 数据文件路径:
/var/lib/clickhouse/ - 日志文件路径:/var/log/clickhouse-server/clickhouse-server.log
1.2.6 启动ClickServer
[root@dn3 clickhouse]# systemctl status clickhouse-server.service
● clickhouse-server.service - ClickHouse Server (analytic DBMS for big data)
Loaded: loaded (/etc/systemd/system/clickhouse-server.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2022-07-20 00:35:58 CST; 11s ago
Main PID: 14326 (clickhouse-serv)
Memory: 154.9M
CGroup: /system.slice/clickhouse-server.service
└─14326 /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/run/cl...
Jul 20 00:35:58 dn3 clickhouse-server[14326]: Include not found: clickhouse_compression
Jul 20 00:35:58 dn3 clickhouse-server[14326]: Logging trace to /var/log/clickhouse-server/clickhouse...log
Jul 20 00:35:58 dn3 clickhouse-server[14326]: Logging errors to /var/log/clickhouse-server/clickhous...log
Jul 20 00:35:59 dn3 clickhouse-server[14326]: Processing configuration file '/etc/clickhouse-server/...l'.
Jul 20 00:35:59 dn3 clickhouse-server[14326]: Include not found: networks
Jul 20 00:35:59 dn3 clickhouse-server[14326]: Saved preprocessed configuration to '/var/lib/clickhou...l'.
Jul 20 00:36:01 dn3 clickhouse-server[14326]: Processing configuration file '/etc/clickhouse-server/...l'.
Jul 20 00:36:01 dn3 clickhouse-server[14326]: Include not found: clickhouse_remote_servers
Jul 20 00:36:01 dn3 clickhouse-server[14326]: Include not found: clickhouse_compression
Jul 20 00:36:01 dn3 clickhouse-server[14326]: Saved preprocessed configuration to '/var/lib/clickhou...l'.
Hint: Some lines were ellipsized, use -l to show in full.
注意:如果安装过zabbix,需要禁用一些服务的开机自启
1.2.7 三台机器上关闭开机自启
[bigdata_admin@dn3 clickhouse]$ sudo systemctl disable clickhouse-server
1.2.8 使用client连接server
[bigdata_admin@dn3 clickhouse]$ clickhouse-client -m
ClickHouse client version 20.4.5.36 (official build).
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 20.4.5 revision 54434.
dn3 :) show databases;
SHOW DATABASES
┌─name───────────────────────────┐
│ _temporary_and_external_tables │
│ default │
│ system │
└────────────────────────────────┘
3 rows in set. Elapsed: 0.002 sec.
dn3 :)
说明:
-m :可以在命令窗口输入多行命令
注意:
如果连接的是设置过密码的CK服务器,请使用如下命令如:
clickhouse-client -h localhost -d default -m -u default --password default
参数说明:
-h:主机名
-d:数据库名
-m:支持命令多行形式
-u:用户名
--password:密码