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
/var/log/clickhouse-server/clickhouse-server.log

/data/clickhouse/

/data/clickhouse/tmp/

/data/clickhouse/user_files/

/var/log/clickhouse-server/clickhouse-server.err.log
  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
    打开 :: 的注释
  2. 创建配置文件 vim /etc/metrika.xml




true

192.168.1.240
9000




true
192.168.1.241
9000



true

192.168.1.243
9000








192.168.1.240
2181


192.168.1.241
2181


192.168.1.243
2181




192.168.1.240



::/0




10000000000
0.01
lz4




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


192.168.1.240

改为当前节点的IP即可

  1. 重启clickhouse服务
/etc/init.d/clickhouse-server restart

你可能感兴趣的:(数据库)