CentOS7上clickhouse的安装问题

操作系统:CentOS7
账号:root

1安装前准备工作

1)[root@cts111 software]# vim /etc/security/limits.conf
在文件末尾添加:

* soft nofile 65536 
* hard nofile 65536 
* soft nproc 131072 
* hard nproc 131072

2)[root@cts111 software]# vim /etc/security/limits.d/20-nproc.conf(可能不同机器的conf会不同)
在文件末尾添加:

* soft nofile 65536 
* hard nofile 65536 
* soft nproc 131072 
* hard nproc 131072

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

[root@cts111 software]# ulimit -n
65536

4)修改/etc/selinux/config中的SELINUX=disabled后重启

[root@cts111 software]# vim /etc/selinux/config
SELINUX=disabled

5)关闭防火墙

[root@cts111 software]# systemctl stop firewalld.service
[root@cts111 software]# systemctl status firewalld.service

使用命令systemctl status firewalld.service,在下方出现disavtive(dead),这样就说明防火墙已经关闭。
再在命令行中输入命令systemctl disable firewalld.service命令,即可永久关闭防火墙。

6)安装依赖

[root@cts111 software]# yum install -y libtool
[root@cts111 software]# yum install -y *unixODBC*
[root@cts111 software]# yum search libicu
[root@cts111 software]# yum install libicu.x86_64

7)下载地址及单机模式安装
官网:https://clickhouse.yandex/
下载地址:http://repo.red-soft.biz/repos/clickhouse/stable/el7/
单机模式:上传5个文件到 mkdir /usr/local/clickhouse

clickhouse-client-1.1.54236-4.el7.x86_64.rpm	09-Jun-2017 11:02	3.0K	 
clickhouse-compressor-1.1.54236-4.el7.x86_64.rpm	09-Jun-2017 11:02	880K	 
clickhouse-debuginfo-1.1.54236-4.el7.x86_64.rpm	09-Jun-2017 11:02	8.6M	 
clickhouse-server-1.1.54236-4.el7.x86_64.rpm	09-Jun-2017 11:02	32M	 
clickhouse-server-common-1.1.54236-4.el7.x86_64.rpm	09-Jun-2017 11:02	8.0K	

2 注意:我是这里出现的问题:

问题1:下错了安装包!如果操作系统是CentOS6,需要到http://repo.red-soft.biz/repos/clickhouse/stable/el6/下载,如果操作系统是CentOS6,需要到http://repo.red-soft.biz/repos/clickhouse/stable/el7/下载。
问题2:下载地址打不开。
有位好心大佬提供了百度网盘:

-- rpm包地址
https://packagecloud.io/Altinity/clickhouse
-- 百度云地址
链接:https://pan.baidu.com/s/1pFR66SzLvPYMfcpuPJww5Ahttps://pan.baidu.com/s/1pFR66SzLvPYMfcpuPJww5Ahttps://pan.baidu.com/s/1pFR66SzLvPYMfcpuPJww5A 
提取码:gh5a

3 解决办法

访问官网:https://clickhouse.tech/#quick-start,点击Quick start
在这里插入图片描述
这里提供了安装命令:
在这里插入图片描述

sudo yum install yum-utils
sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG
sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/clickhouse.repo
sudo yum install clickhouse-server clickhouse-client

sudo /etc/init.d/clickhouse-server start
clickhouse-client

按照上面的命令安装即可。

4 安装后可能出现的问题

如果出现Code: 210. DB::NetException: Connection refused问题:

[root@cts111 software]# clickhouse-client
ClickHouse client version 21.2.4.6 (official build).
Connecting to localhost:9000 as user default.
Code: 210. DB::NetException: Connection refused (localhost:9000)

由于clickhouse-client默认连接的主机是localhost,默认连接的端口号是9000,先用命令netstat -ltpn | grep 9000查看9000端口是否被占用。如果发现有被占用,可以修改它的默认端口号(修改方式见下面参考文章),如果端口号没有被占用,关机重启即可解决这个问题。

5 启动/关闭服务、客户端

1)启动/关闭服务

## 启动服务
[root@cts111 ~]# service clickhouse-server start
Start clickhouse-server service: Path to data directory in /etc/clickhouse-server/config.xml: /var/lib/clickhouse/
DONE
## 关闭服务
[root@cts111 ~]# service clickhouse-server stop

注意:关闭服务使用service clickhouse-server stop可能会关不掉:

[rocky@cts113 ~]$ sudo service clickhouse-server stop
Init script is already running

可以尝试以下命令:

#Cent OS7 系统上测试,需要使用以下命令执行
#service  clickhouse-server start 命令,
#只提示 Init script is already running,然后就没有动静了

sudo systemctl start clickhouse-server
sudo systemctl stop clickhouse-server
sudo systemctl status clickhouse-server

2)客户端连接

[root@cts111 ~]# 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.

cts111 :) show databases;

SHOW DATABASES

Query id: 18643bb5-97b8-463d-9495-46d6c82385f4

┌─name────┐
│ default │
│ system  │
└─────────┘

2 rows in set. Elapsed: 0.005 sec.

6 参考文章

1)ClickHouse官网
2)篇一|ClickHouse快速入门
3)ClickHouse原理及使用
4)CentOs安装ClickHouse及初步使用
5)centos7clickhouse安装教程以及遇到的坑
6)CLICKHOUSE进程杀不掉
7)clickhouse 离线安装

猜你喜欢

转载自blog.csdn.net/u010250240/article/details/113968987