ClickHouse installation

1.1 Preparations

1.1.1 Make sure the firewall is turned off

[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 cancels the limit on the number of open files

1) Add the following content at the end of the /etc/security/limits.conf file of dn3

注意:以下操作会修改 Linux 系统配置,如果操作不当可能导致虚拟机无法启动,建议在执行以下操作之前给三台虚拟机分别打个快照。(快照拍摄需要在关机状态下执行)
[bigdata_admin@dn3~]$ sudo vim /etc/security/limits.conf
* soft nofile 65536 
* hard nofile 65536 
* soft nproc 131072 
* hard nproc 131072

2) Add the following at the end of the /etc/security/limits.d/20-nproc.conf file of dn3

[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) Perform synchronous operations

[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 Installation dependencies

[bigdata_admin@dn3~]$ sudo yum install -y libtool

insert image description here

[bigdata_admin@dn3~]$ sudo yum install -y *unixODBC*	

insert image description here

Execute the above operations on dn4 and dn5

1.1.4 CentOS cancels SELINUX

1) Modify SELINUX=disabled in /etc/selinux/config

[bigdata_admin@dn3~]$ sudo vim /etc/selinux/config 
SELINUX=disabled

Note: don't make a mistake

2) Perform synchronous operations

[bigdata_admin@dn3~]$ sudo /home/bigdata_admin/bin/xsync /etc/selinux/config

3) Restart the three servers

[bigdata_admin@dn3~]$ sudo reboot

1.2 Stand-alone installation

Official website: https://clickhouse.yandex/
Download address: https://repo.clickhouse.tech/rpm/stable/x86_64/

1.2.1 Create clickhouse directory under /opt/software of dn3

[bigdata_admin@dn3~]$ cd /opt/software/
[bigdata_admin@dn3software]$ mkdir clickhouse

1.2.2 Upload the 4 rpm installation files to the /opt/software/clickhouse directory of dn3

[bigdata_admin@dn3clickhouse]$ ll
总用量 1262276
-rw-rw-r-- 1 bigdata_admin bigdata_admin 56708 47 12:42 clickhouse-client-20.4.5.36-2.noarch.rpm
-rw-rw-r-- 1 bigdata_admin bigdata_admin 117222435 47 12:42 clickhouse-common-static-20.4.5.36-2.x86_64.rpm
-rw-rw-r-- 1 bigdata_admin bigdata_admin 1175204526 47 12:42 clickhouse-common-static-dbg-20.4.5.36-2.x86_64.rpm
-rw-rw-r-- 1 bigdata_admin bigdata_admin 78318 47 12:42 clickhouse-server-20.4.5.36-2.noarch.rpm

1.2.3 Synchronize the installation files to dn4, dn5

[bigdata_admin@dn3 software]$ xsync clickhouse/

1.2.4 Install the 4 rpm files on the three machines respectively

[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 Modify configuration file

[bigdata_admin@dn3 clickhouse]$ sudo vim /etc/clickhouse-server/config.xml

1) The configuration allows access by external nodes

Open <listen_host>::</listen_host>the comment, so that ClickHouse can be accessed by servers other than this machine
insert image description here

2) Distribution configuration file

[bigdata_admin@dn3 clickhouse]$ sudo /home/bigdata_admin/bin/xsync /etc/clickhouse-server/config.xml

In this file, there are some default path configurations of ClickHouse, which are more important

  • Data file path: /var/lib/clickhouse/
  • Log file path: /var/log/clickhouse-server/clickhouse-server.log

1.2.6 Start 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.

Note: If you have installed zabbix, you need to disable the startup of some services

1.2.7 Turn off autostart on boot on the three machines

[bigdata_admin@dn3 clickhouse]$ sudo systemctl disable clickhouse-server 

1.2.8 Use the client to connect to the 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 :)

illustrate:

-m : You can enter multi-line commands in the command window

注意:
If you are connecting to the CK server with a password set, please use the following command such as:

clickhouse-client -h localhost -d default -m -u default --password default

参数说明: 
	-h:主机名
	-d:数据库名
	-m:支持命令多行形式
	-u:用户名
	--password:密码 

Guess you like

Origin blog.csdn.net/liuwei0376/article/details/125871406