概述:clickhouse是一个高性能的列式数据库,特点就是快快快,查询性能是mysql的100-1000倍,非常适合存储频繁写入的数据,比如:日志,用户事件记录。单表存储上亿甚至十几亿行数据库查询都是很快的。具体性能参考
https://clickhouse.yandex/benchmark.html 缺点:不能进行更新操作,不能删除单行数据(只能整表删除),没有事务。
1、准备
在/etc/security/limits.conf、/etc/security/limits.d/90-nproc.conf这2个文件的末尾加入一下内容:
[root@hadoop102 software]# vim /etc/security/limits.conf
在文件末尾添加:
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
[root@hadoop102 software]# vim /etc/security/limits.d/90-nproc.conf
在文件末尾添加:
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
重启服务器it -n 或者ulimit -a查看设置结果
[root@hadoop102 ~]# ulimit -n
65536
CentOS取消SELINUX
修改/etc/selinux/config中的SELINUX=disabled后重启
[root@hadoop102 ~]# vim /etc/selinux/config
SELINUX=disabled
2、配置好yum源
$ curl -s https://packagecloud.io/install/repositories/Altinity/clickhouse/script.rpm.sh | sudo bash
$ sudo yum -q makecache -y --disablerepo='*' --enablerepo='Altinity_clickhouse' #更新yum
$ sudo yum list 'clickhouse*' #检验是否配置好源
已加载插件:fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Altinity_clickhouse/signature | 836 B 00:00
Altinity_clickhouse/signature | 1.0 kB 00:00 ...
Altinity_clickhouse-source/signature | 819 B 00:00
Altinity_clickhouse-source/signature | 951 B 00:00 ...
已安装的软件包
clickhouse-client.x86_64 18.16.1-1.el6 @Altinity_clickhouse
clickhouse-common-static.x86_64 18.16.1-1.el6 @Altinity_clickhouse
clickhouse-compressor.x86_64 1.1.54336-3.el6 @Altinity_clickhouse
clickhouse-debuginfo.x86_64 18.14.15-1.el6 @Altinity_clickhouse
clickhouse-server.x86_64 18.16.1-1.el6 @Altinity_clickhouse
clickhouse-server-common.x86_64 18.16.1-1.el6 @Altinity_clickhouse
clickhouse-test.x86_64 18.16.1-1.el6 @Altinity_clickhouse
3、安装clickhouse
$ yum -y install clickhouse-server clickhouse-client
或者
$ yum -y install clickhouse-*
4、启动或者停止clickhouse-server
$ sudo /etc/init.d/clickhouse-server stop|start|restart
$ clickhouse-client --port=9001 #连接clickhouse-server
5、clickhouse配置文件
/etc/clickhouse-server/config.xml
/etc/clickhouse-server/users.xml
我这里的端口是9001 ,端口可以在/etc/clickhouse-server/config.xml 修改
6、远程连接
修改/etc/clickhouse-server/config.xml
去掉<listen_host>::</listen_host>注释
7、添加用户
修改/etc/clickhouse-server/users.xml
在<!-- Example of user with readonly access. -->上新增:
<netprobe>
<password>Wdkj@2017</password>
<networks incl="networks" replace="replace">
<ip>::/0</ip>
</networks>
<profile>default</profile>
<quota>default</quota>
</netprobe>
8、参考资料
https://github.com/Altinity/clickhouse-rpm-install
9、rpm包安装
下载相关安装包
- 在opt目录下创建clickhouse目录,方便下载文件
Cd /opt/clickhouse 一次执行一下命令
① wget --content-disposition
https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-test-19.5.3.8-1.el7.x86_64.rpm/download.rpm;
② wget --content-disposition
https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-server-common-19.5.3.8-1.el7.x86_64.rpm/download.rpm;
③ wget --content-disposition
https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-server-19.5.3.8-1.el7.x86_64.rpm/download.rpm;
④ wget --content-disposition
https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-debuginfo-19.5.3.8-1.el7.x86_64.rpm/download.rpm;
⑤ wget --content-disposition
https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-common-static-19.5.3.8-1.el7.x86_64.rpm/download.rpm;
⑥ wget --content-disposition
https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-client-19.5.3.8-1.el7.x86_64.rpm/download.rpm;
安装Clickhouse
- 按顺序安装安装包
① rpm -ivh clickhouse-server-common-19.5.3.8-1.el7.x86_64.rpm
② rpm -ivh clickhouse-common-static-19.5.3.8-1.el7.x86_64.rpm
③ rpm -ivh clickhouse-server-19.5.3.8-1.el7.x86_64.rpm
④ rpm -ivh clickhouse-debuginfo-19.5.3.8-1.el7.x86_64.rpm
⑤ rpm -ivh clickhouse-test-19.5.3.8-1.el7.x86_64.rpm
⑥ rpm -ivh clickhouse-client-19.5.3.8-1.el7.x86_64.rpm
启动Clickhouse
执行命令:service clickhouse-server start
注:(刚安装的Clickhouse 用户名为:deafault密码:无,http远程连接端口8123)
本地连接命令 clickhouse-client -h <ip>