1、环境准备
1. 版本选择
服务选择:Centos 6.5
Clickhouse:22.2.3.5
2. 防火墙关闭
[root@cdh1 ~]# service iptables stop --临时关闭防火墙
[root@cdh1 ~]# chkconfig iptables off --永久关闭防火墙
3. 取消Centos文件句柄
在文件/etc/security/limits.conf文件的末尾追加以下内容
[root@cdh1 ~]# vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
4. 安装依赖
[root@cdh1 clickhouse]# sudo yum install yum-utils
5. 关闭SELINUX
修改 /etc/selinux/config下面SELINUX的参数为disabled,并且重启服务器
[root@cdh1 clickhouse]# vi /etc/selinux/config
SELINUX=disabled
2、开始安装
1. Clickhouse试用
官方提供了一个在线试用版的Clickhouse,大家可以登录地址进行体验,提供了3张表datasets.hits_100m_obfuscated、datasets.hits_v1、datasets.visits_v1
体验地址:https://play.clickhouse.com/?file=playground
2. 软件包下载
由于我们采用的RPM包安装,所以需要提前下载包,可以登录地址:https://packages.clickhouse.com/rpm/stable/ ,下载对应的包。我们这次选择的版本是22.2.3.5,所以下载下面4个包:
clickhouse-client-22.2.3.5-2.noarch.rpm
clickhouse-common-static-22.2.3.5-2.x86_64.rpm
clickhouse-common-static-dbg-22.2.3.5-2.x86_64.rpm
clickhouse-server-22.2.3.5-2.noarch.rpm
3. 上传软件包
将包上传到服务器的/opt/clickhouse路径下面
4. 安装软件包
现在启动安装,由于这个路径下面只有Clickhouse的4个包,我们可以一起安装,运行命令
[root@cdh1 clickhouse]# rpm -ivh *.rpm
通过命名检查是否安装情况
[root@cdh1 clickhouse]# rpm -qa|grep clickhouse
5. 修改配置文件
默认情况下,安装后的文件在如下路径下, 我们可以通过修改conf里面的配置路径进行修改,这个后续会说到。
bin /usr/bin
conf /etc/clickhouse-server/
lib /var/lib/clickhouse
log /var/log/clickhouse-server
现在我们要服务运行起来,我们先修改/etc/clickhouse-server/config.xml中将下面的listen_host的注释删除了,这样才能要Clickhouse除本机以外的主机访问。
<!-- <listen_host>::</listen_host> -->
6. 启动Clickhouse服务
由于刚才修改了配置文件,所以我们需要重新启动Clickhouse,我们使用
sudo /etc/init.d/clickhouse-server stop|start|status 等命令进行操作,这块需要注意,因为我这边是使用root用户,所以需要sudo一下,不然会出现Clickhouse的权限问题
[root@cdh1 clickhouse-server]# sudo /etc/init.d/clickhouse-server status
/var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 1929.
The process with pid = 1929 is running.
Usage: /etc/init.d/clickhouse-server {start|stop|status|restart|forcestop|forcerestart|reload|condstart|condstop|condrestart|condreload|initdb}
[root@cdh1 clickhouse-server]# sudo /etc/init.d/clickhouse-server stop
/var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 1929.
The process with pid = 1929 is running.
Sent terminate signal to process with pid 1929.
Waiting for server to stop
/var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 1929.
The process with pid = 1929 is running.
Waiting for server to stop
Now there is no clickhouse-server process.
Server stopped
[root@cdh1 clickhouse-server]# sudo /etc/init.d/clickhouse-server start
chown -R clickhouse: '/var/run/clickhouse-server/'
Will run su -s /bin/sh 'clickhouse' -c '/usr/bin/clickhouse-server --config-file /etc/clickhouse-server/config.xml --pid-file /var/run/clickhouse-server/clickhouse-server.pid --daemon'
Waiting for server to start
Waiting for server to start
Server started
7. 使用client进行连接服务
我们直接使用clickhouse-client去连接查询。
[root@cdh1 clickhouse-server]# clickhouse-client
在启动过程可能会出现这样的错误,这个是设置了密码,我先可以将文件删除在去连接就可以了,删除文件/etc/clickhouse-server/users.d/default-password.xml
更多内容关注公众号