ClickHouse 安装部署

目录

1.安装前的准备

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

1.2 CentOS取消SELINUX

1.3 关闭防火墙

1.4 安装依赖

2.安装部署

2.1 网址

2.2 单机模式

2.3 分布式集群安装

2.3.1 在hadoop103,hadoop104上面执行之前的所有步骤

2.3.2 三台机器修改配置文件config.xml

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

2.3.4 三台机器启动ClickServer

3.卸载


1.安装前的准备

1.1 CentOS取消打开文件数限制在/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

重启服务器之后生效,用ulimit -n 或者ulimit -a查看设置结果
[root@hadoop102 ~]# ulimit -n
65536

1.2 CentOS取消SELINUX

// 修改/etc/selinux/config中的SELINUX=disabled后重启
[root@hadoop102 ~]# vim /etc/selinux/config
SELINUX=disabled

// 说明:关于SELINUX参数的具体讲解访问 http://c.biancheng.net/view/3906.html

1.3 关闭防火墙

[root@hadoop102 ~]# service iptables stop
[root@hadoop102 ~]# service ip6tables stop
ip6tables:将 chains 设置为 ACCEPT 策略:filter            [确定]
ip6tables:清除防火墙规则:                                [确定]
:正在卸载模块:                                           [确定]

1.4 安装依赖

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

2.安装部署

2.1 网址

    下载地址: Index of /repos/clickhouse/stable/el6

2.2 单机模式

// 2.2.1 上传4个文件到/opt/software/
[root@hadoop102 software]# ls
clickhouse-client-20.4.5.36-2.noarch.rpm
clickhouse-common-static-20.4.5.36-2.x86_64.rpm
clickhouse-common-static-dbg-20.4.5.36-2.x86_64.rpm
clickhouse-server-20.4.5.36-2.noarch.rpm

// 2.2.2 分别安装这4个rpm文件
[root@hadoop102 software]# rpm -ivh *.rpm --force --nodeps

// 2.2.3 启动ClickServer
快速启动:service clickhouse-server start
前台启动:[root@hadoop102 software]# clickhouse-server --config-file=/etc/clickhouse-server/config.xml
后台启动:[root@hadoop102 software]# nohup clickhouse-server --config-file=/etc/clickhouse-server/config.xml  >null 2>&1 &
[1] 4322

// 2.2.4 使用client连接server
[root@hadoop102 software]# clickhouse-client -m
ClickHouse client version 1.1.54236.
Connecting to localhost:9000.
Connected to ClickHouse server version 1.1.54236.
:)

// 2.2.5 关闭开机自启
sudo systemctl disable clickhouse-server

2.3 分布式集群安装

2.3.1 在hadoop103,hadoop104上面执行之前的所有步骤

2.3.2 三台机器修改配置文件config.xml

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

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

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

//说明:把 <listen_host>::</listen_host> 的注解打开才能让clickhouse被除本机以外的服务器访问

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

[root@hadoop102 ~]# vim /etc/metrika.xml
添加如下内容:
<yandex>
<clickhouse_remote_servers>
    <perftest_3shards_1replicas>
<!—数据分片1-->
        <shard>
             <internal_replication>true</internal_replication>
            <replica>
                <host>hadoop102</host>
                <port>9000</port>
            </replica>
        </shard>
<!—数据分片2-->
        <shard>
            <replica>
                <internal_replication>true</internal_replication>
                <host>hadoop103</host>
                <port>9000</port>
            </replica>
        </shard>
<!—数据分片3-->
        <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>                                                                                                                                       
  <method>lz4</method>
</case>
</clickhouse_compression>
</yandex>

// 注意:上面标红的地方需要根据机器不同去修改

2.3.4 三台机器启动ClickServer

首先在三台机器开启Zookeeper
前台启动:
[root@hadoop102 software]# clickhouse-server --config-file=/etc/clickhouse-server/config.xml
后台启动:
[root@hadoop102 software]# nohup clickhouse-server --config-file=/etc/clickhouse-server/config.xml  >null 2>&1 &
[1] 4322

3.卸载

# 卸载及删除安装文件(需root权限)
yum list installed | grep clickhouse
yum remove -y clickhouse-common-static
yum remove -y clickhouse-server-common
rm -rf /var/lib/clickhouse
rm -rf /etc/clickhouse-*
rm -rf /var/log/clickhouse-server

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员学习圈

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值