Clickhouse 单机版安装

click house单机安装

https://clickhouse.tech/docs/en/getting-started/install/
参考官方文档安装方法

系统要求
ClickHouse可以在具有x86_64,AArch64或PowerPC64LE CPU体系结构的任何Linux,FreeBSD或Mac OS X上运行。

帮助文档有DEB包、RPM包、TGZ包、Docker安装。

本文以rpm安装方式为例


1、首先检查CPU是否支持SSE 4.2的命令:

[root@host101 mysql]# grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"
SSE 4.2 supported ---是支持的

2、调整本地运行环境
修改Linux文件打开数限制
在 /etc/security/limits.conf 这个文件的末尾加入一下内容:

vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072

在 /etc/security/limits.d/90-nproc.conf 这个文件的末尾加入一下内容:

vi /etc/security/limits.d/90-nproc.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072

重启服务器之后生效,用 ulimit -n 或者 ulimit -a 查看设置结果

ulimit -n
ulimit -a

关闭selinux
修改 /etc/selinux/config 中的 SELINUX=disabled 后重启

vim /etc/selinux/config
SELINUX=disabled


关闭防火墙
CentOS-6 如何操作:

service iptables stop
service ip6tables stop

CentOS-7 如何操作:

systemctl status firewalld.service
systemctl stop firewalld.service
systemctl start firewalld.service

3、安装

yum install yum-util -y
rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG
yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64
yum install clickhouse-server clickhouse-client -y

因为网络的原因,yum安装网络一直失败,
可以选择离线安装,先手动下载rpm包,下载到本地再上传到服务器
下载地址:

https://repo.clickhouse.tech/rpm/stable/x86_64

下载这三个文件
clickhouse-server-20.5.4.40-2.noarch.rpm 
clickhouse-common-static-20.5.4.40-2.x86_64.rpm 
clickhouse-client-20.5.4.40-2.noarch.rpm

安装

[root@host101 tmp]# rpm -ivh clickhouse-common-static-20.5.4.40-2.x86_64.rpm 
Preparing... ################################# [100%]
Updating / installing...
1:clickhouse-common-static-20.5.4.4################################# [100%]
[root@host101 tmp]# rpm -ivh clickhouse-client-20.5.4.40-2.noarch.rpm 
Preparing... ################################# [100%]
Updating / installing...
1:clickhouse-client-20.5.4.40-2 ################################# [100%]
[root@host101 tmp]# rpm -ivh clickhouse-server-20.5.4.40-2.noarch.rpm 
Preparing... ################################# [100%]
Updating / installing...
1:clickhouse-server-20.5.4.40-2 ################################# [100%]
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/
[root@host101 tmp]#

[root@host101 tmp]# service clickhouse-server start
Start clickhouse-server service: Path to data directory in /etc/clickhouse-server/config.xml: /var/lib/clickhouse/
DONE
[root@host101 tmp]# ps -ef|grep clickhouse
clickho+ 16150 1 14 23:39 ? 00:00:00 clickhouse-server --daemon --pid-file=/var/run/clickhouse-server/clickhouse-server.pid --config-file=/etc/clickhouse-server/config.xml
root 16204 8491 0 23:39 pts/0 00:00:00 grep --color=auto clickhouse

进入数据库

[root@host101 tmp]# clickhouse-client 
ClickHouse client version 20.5.4.40 (official build).
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 20.5.4 revision 54435.

host101 :) select 1;

SELECT 1

┌─1─┐
│ 1 │
└───┘

1 rows in set. Elapsed: 0.005 sec.

host101 :)

clickhouse目录结构如下

[root@host101 lib]# tree /var/lib/clickhouse -d -L 3
/var/lib/clickhouse
├── access
├── cores
├── data
│   ├── default
│   └── system
│       ├── asynchronous_metric_log
│       ├── metric_log
│       ├── query_log
│       ├── query_thread_log
│       └── trace_log
├── dictionaries_lib
├── flags
├── format_schemas
├── metadata
│   ├── default
│   └── system
├── metadata_dropped
├── preprocessed_configs
├── tmp
└── user_files

配置文件:

/etc/clickhouse-server/config.xml 

原文地址:https://www.cnblogs.com/nanxiang/p/14083670.html