clickhouse集群安装

环境

192.168.1.240 apm01
192.168.1.241 apm02
192.168.1.243 clickhouse02

安装JDK

在三台服务器上分别安装JDK1.8(此步骤略)

安装zookeeper

  1. 下载 zookeeper-3.4.12.tar.gz 安装包,放置到上面三台服务器的/opt目录下
  2. 进入到/opt目录下,解压tar包,tar -zxvf zookeeper-3.4.12.tar.gz
  3. 修改目录名,mv zookeeper-3.4.12 zookeeper
  4. 进入zookeeper的conf目录,拷贝zoo_sample.cfg为zoo.cfg,cp zoo_sample.cfg zoo.cfg
  5. 修改zoo.cfg文件
    tickTime=2000
    initLimit=10
    syncLimit=5
    dataDir=/data/zookeeper
    dataLogDir=/data/zookeeper
    clientPort=2181
    autopurge.purgeInterval=0
    globalOutstandingLimit=200
    server.1=apm01:2888:3888
    server.2=apm02:2888:3888
    server.3=clickhouse02:2888:3888 
    
  6. 设置环境变量
    export ZOOKEEPER_HOME=/opt/zookeeper
    export PATH=$PATH:$ZOOKEEPER_HOME/bin
  1. 创建目录
    mkdir -p /data/zookeeper
  2. 设置myid
    vim /data/zookeeper/myid #240为1,241为2,243为3
  3. 启动zookeeper
    进入zookeeper的bin目录下,执行./zkServer.sh start
  4. 测试zookeeper
    ./zkCli.sh -server 192.168.1.241:2181
    如果出现拒绝连接,查看防火墙是否关闭,关闭防火墙 systemctl stop firewalld 重启zookeeper

部署clickhouse

单节点安装(rpm包安装)

  1. 添加clickhouse用户
    useradd clickhouse
  2. 把下载好的rpm包上传到各个节点的/home/clickhouse目录下
  3. 安装rpm包
rpm -ivh clickhouse-server-common-19.1.8-1.el7.x86_64.rpm 
rpm -ivh clickhouse-common-static-19.1.8-1.el7.x86_64.rpm
rpm -ivh clickhouse-server-19.1.8-1.el7.x86_64.rpm 
rpm -ivh clickhouse-client-19.1.8-1.el7.x86_64.rpm
rpm -ivh unixODBC-2.3.1-11.el7.x86_64.rpm
  1. 配置/etc/clickhouse-server/config.xml
<log>/var/log/clickhouse-server/clickhouse-server.log</log>

<path>/data/clickhouse/</path>

<tmp_path>/data/clickhouse/tmp/</tmp_path>

<user_files_path>/data/clickhouse/user_files/</user_files_path>

<errorlog>/var/log/clickhouse-server/clickhouse-server.err.log</errorlog>
  1. 把上述目录的用户都赋权给clickhouse
    chown -R clickhouse:clickhouse 目录
  2. 启动clickhouse
    /etc/init.d/clickhouse-server start
  3. 验证单节点的clickhouse
    输入clickhouse-client进入clickhouse客户端,查询system数据库中的表名

配置集群

  1. 修改配置文件 vim /etc/clickhouse-server/config.xml
    打开 <listen_host>::</listen_host> 的注释
  2. 创建配置文件 vim /etc/metrika.xml
<yandex>
<clickhouse_remote_servers>
<perftest_3shards_1replicas>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>192.168.1.240</host>
<port>9000</port>
</replica>
</shard>
<shard>
<replica>
<internal_replication>true</internal_replication>
<host>192.168.1.241</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>192.168.1.243</host>
<port>9000</port>
</replica>
</shard>
</perftest_3shards_1replicas>
</clickhouse_remote_servers>

<!--zookeeper相关配置-->
<zookeeper-servers>
<node index="1">
<host>192.168.1.240</host>
<port>2181</port>
</node>
<node index="2">
<host>192.168.1.241</host>
<port>2181</port>
</node>
<node index="3">
<host>192.168.1.243</host>
<port>2181</port>
</node>
</zookeeper-servers>

<macros>
<replica>192.168.1.240</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>

上述配置中三个节点中不同的地方在于

<macros>
<replica>192.168.1.240</replica>
</macros>

改为当前节点的IP即可

  1. 重启clickhouse服务
/etc/init.d/clickhouse-server restart
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值