什么是clickhous
ClickHouse 是俄罗斯的Yandex于2016年开源的列式存储数据库(DBMS),主要用于在线分析处理查询(OLAP),能够使用SQL查询实时生成分析数据报告。
安装前的准备
以CentOS6.8为例
1. CentOS取消打开文件数限制
在/etc/security/limits.conf、/etc/security/limits.d/90-nproc.conf这2个文件的末尾加入一下内容:
- soft nofile 65536
- hard nofile 65536
- soft nproc 131072
- hard nproc 131072
重启生效 用ulimit –n 或者ulimit –a查看设置结果
用ulimit –n 或者ulimit –a查看设置结果
[root@hadoop102 ~]# ulimit -n
65536
2. CentOS取消取消SELINU
修改/etc/selinux/config中的SELINUX=disabled后重启
vim /etc/selinux/config
SELINUX=disabled
3. CentOS关闭防火墙
service iptables stop
service ip6tables stop
4. 安装依赖
yum install -y libtool
yum install -y *unixODBC*
安装
1.网址
2.单机模式
上传5个文件到Linux中
[root@hadoop102 software]# ls
clickhouse-client-1.1.54236-4.el6.x86_64.rpm
clickhouse-server-1.1.54236-4.el6.x86_64.rpm
clickhouse-compressor-1.1.54236-4.el6.x86_64.rpm
clickhouse-server-common-1.1.54236-4.el6.x86_64.rpm
clickhouse-debuginfo-1.1.54236-4.el6.x86_64.rpm
分别安装这5个rpm文件
[root@hadoop102 software]# rpm -ivh *.rpm
启动ClickServer
前台启动:
clickhouse-server –config-file=/etc/clickhouse-server/config.xml
后台启动:
nohup clickhouse-server –config-file=/etc/clickhouse-server/config.xml >null 2>&1
[1] 2696
使用client连接server
clickhouse-client
3.分布式安装
准备三台机器,改好主机名之类的,然后执行以上所有步骤
我这里是hadoop102,hadoop103,hadoop104
三台机器修改配置文件config.xml
vim /etc/clickhouse-server/config.xml
把60行左右的三行改为这样
<listen_host>::</listen_host>
<!-- <listen_host>::1</listen_host> -->
<!-- <listen_host>127.0.0.1</listen_host> -->
在三台机器的etc目录下新建metrika.xml文件
vim /etc/metrika.xml
添加如下内容:
<yandex>
<clickhouse_remote_servers>
<perftest_3shards_1replicas>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>hadoop102</host>
<port>9000</port>
</replica>
</shard>
<shard>
<replica>
<internal_replication>true</internal_replication>
<host>hadoop103</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>hadoop104</host>
<port>9000</port>
</replica>
</shard>
</perftest_3shards_1replicas>
</clickhouse_remote_servers>
<zookeeper-servers>
<node index="1">
<host>hadoop102</host>
<port>2181</port>
</node>
<node index="2">
<host>hadoop103</host>
<port>2181</port>
</node>
<node index="3">
<host>hadoop104</host>
<port>2181</port>
</node>
</zookeeper-servers>
<macros>
<replica>hadoop102</replica>
</macros>
<networks>
<ip>::/0</ip>
</networks>
<clickhouse_compression>
<case>
<min_part_size>10000000000</min_part_size>
<min_part_size_ratio>0.01</min_part_size_ratio>