CentOS7 分布式集群安装 ClickHouse

CentOS7 安装 ClickHouse

1.安装前准备

准备三台装有Zookeeper的服务器,先在hadoop02上做如下操作

(1)CentOS 取消打开文件数限制
1)在/etc/security/limits.conf、/etc/security/limits.d/20-nproc.conf 这 2 个文件的末尾加入一下内容:

[root@hadoop02 software]# vi /etc/security/limits.conf
# 在文件末尾添加:
* soft nofile 65536 
* hard nofile 65536 
* soft nproc 131072 
* hard nproc 131072
[root@hadoop02 software]# vi /etc/security/limits.d/20-
nproc.conf
# 在文件末尾添加:
* soft nofile 65536 
* hard nofile 65536 
* soft nproc 131072 
* hard nproc 131072

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

[root@hadoop02 ~]# ulimit -n
65536

(2)CentOS 取消 SELINUX
修改/etc/selinux/config 中的 SELINUX=disabled

[root@hadoop02 ~]# vi /etc/selinux/config
SELINUX=disabled

(3)关闭防火墙

[root@hadoop02 ~]# service iptables stop 
[root@hadoop02 ~]# service ip6tables stop

(4)安装依赖

[root@hadoop02 ~]# yum install -y libtool
[root@hadoop02 ~]# yum install -y *unixODBC*

2.单机安装

(1)网址
官网:https://clickhouse.yandex/
下载地址:http://repo.red-soft.biz/repos/clickhouse/stable/el7/

(2)下载RPM,并上传到 /opt/software/ck/ 目录下
clickhouse-debuginfo-1.1.54236-4.el7.x86_64.rpm文件可暂不上传
在这里插入图片描述
注意:如果文件和组不是 root ,请设置文件的组和用户

[root@hadoop02 ck]# chown root:root *.rpm

效果如下:

[root@hadoop02 ck]# ll
total 33788
-rwxrwxrwx 1 root root     3048 Dec 10 15:30 clickhouse-client-1.1.54236-4.el7.x86_64.rpm
-rwxrwxrwx 1 root root   901472 Dec 10 15:30 clickhouse-compressor-1.1.54236-4.el7.x86_64.rpm
-rwxrwxrwx 1 root root 33680608 Dec 10 15:30 clickhouse-server-1.1.54236-4.el7.x86_64.rpm
-rwxrwxrwx 1 root root     8164 Dec 10 15:30 clickhouse-server-common-1.1.54236-4.el7.x86_64.rpm

(3)安装
1)安装依赖

[root@hadoop02 ck]# yum install libicu.x86_64

2)安装这些rpm文件

[root@hadoop02 ck]# rpm -ivh *.rpm

Preparing...                          ################################# [100%]
Updating / installing...
   1:clickhouse-server-common-1.1.5423################################# [ 25%]
   2:clickhouse-server-1.1.54236-4.el7################################# [ 50%]
   3:clickhouse-client-1.1.54236-4.el7################################# [ 75%]
   4:clickhouse-compressor-1.1.54236-4################################# [100%]

3.分布式集群安装

(1)在 hadoop03,hadoop04 上面执行之前的所有步骤,实现每台服务器的单机安装

(2)三台机器修改配置文件 config.xml

[root@hadoop02 ~]# vi /etc/clickhouse-server/config.xml
<listen_host>::</listen_host>
<!-- <listen_host>::1</listen_host> -->
<!-- <listen_host>127.0.0.1</listen_host> -->

[root@hadoop03 ~]# vi /etc/clickhouse-server/config.xml
<listen_host>::</listen_host>
<!-- <listen_host>::1</listen_host> -->
<!-- <listen_host>127.0.0.1</listen_host> -->

[root@hadoop04 ~]# vi /etc/clickhouse-server/config.xml
<listen_host>::</listen_host>
<!-- <listen_host>::1</listen_host> -->
<!-- <listen_host>127.0.0.1</listen_host> -->

(3)在三台机器的 etc 目录下新建 metrika.xml 文件

[root@hadoop02 ~]# vi /etc/metrika.xml
#hadoop03\hadoop04同上

添加如下内容:

<yandex>
<clickhouse_remote_servers>
	<perftest_3shards_1replicas>
		<shard>
			<internal_replication>true</internal_replication>
			<replica>
				<host>hadoop02</host>
				<port>9000</port>
			</replica>
		</shard>
		<shard>
			<internal_replication>true</internal_replication>
			<replica>
				<host>hadoop03</host>
				<port>9000</port>
			</replica>
		</shard>
		<shard>
			<internal_replication>true</internal_replication>
			<replica>
				<host>hadoop04</host>
				<port>9000</port>
			</replica>
		</shard>
	</perftest_3shards_1replicas>
</clickhouse_remote_servers>

<zookeeper-servers>
	<node index="1">
		<host>hadoop02</host>
		<port>2181</port>
	</node>
	<node index="2">
		<host>hadoop03</host>
		<port>2181</port>
	</node>
	<node index="3">
		<host>hadoop04</host>
		<port>2181</port>
	</node>
</zookeeper-servers>

<macros>
	<replica>hadoop02</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>
		<method>lz4</method>
	</case>
</clickhouse_compression>
</yandex>

(4)三台机器启动 ClickServer

首先需要在三台机器开启 Zookeeper

[root@hadoop02 ck]# service clickhouse-server start

[root@hadoop03 ck]# service clickhouse-server start

[root@hadoop04 ck]# service clickhouse-server start

(5)在hadoop02上用客户端连接服务,并查看集群

[root@hadoop02 etc]# clickhouse-client -m
ClickHouse client version 1.1.54236.
Connecting to localhost:9000.
Connected to ClickHouse server version 1.1.54236.

:) select * from system.clusters;

SELECT *
FROM system.clusters 

┌─cluster────────────────────┬─shard_num─┬─shard_weight─┬─replica_num─┬─host_name─┬─host_address───┬─port─┬─is_local─┬─user────┬─default_database─┐
│ perftest_3shards_1replicas │         1 │            1 │           1 │ hadoop02  │ 192.168.92.142 │ 9000 │        1 │ default │                  │
│ perftest_3shards_1replicas │         2 │            1 │           1 │ hadoop03  │ 192.168.92.143 │ 9000 │        0 │ default │                  │
│ perftest_3shards_1replicas │         3 │            1 │           1 │ hadoop04  │ 192.168.92.144 │ 9000 │        0 │ default │                  │
└────────────────────────────┴───────────┴──────────────┴─────────────┴───────────┴────────────────┴──────┴──────────┴─────────┴──────────────────┘

此时ClickHouse的分布式集群安装完毕

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值