ClickHouse高可用集群搭建(离线安装)

一、简介

ClickHouse官网

二、生产集群搭建

准备

  • Zookeeper集群
  • Linux服务器四台(以四台为列)

创建用户组和用户

groupadd clickhouse  ---创建用户组
useradd -m -d /home/clickhouse -g clickhouse clickhouse ---创建用户
passwd clickhouse ---修改密码

下载

准备好ClickHouse安装包,官网下载地址(选择需要下载的版本)

  • clickhouse-common-static-$LATEST_VERSION.tgz
  • clickhouse-common-static-dbg-$LATEST_VERSION.tgz
  • clickhouse-server-$LATEST_VERSION.tgz
  • clickhouse-client-$LATEST_VERSION.tgz

解压、安装(注意切换用户clickhouse)

tar -xzvf clickhouse-common-static-$LATEST_VERSION.tgz
sudo clickhouse-common-static-$LATEST_VERSION/install/doinst.sh

tar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgz
sudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.sh

tar -xzvf clickhouse-server-$LATEST_VERSION.tgz
sudo clickhouse-server-$LATEST_VERSION/install/doinst.sh
#启动命令
sudo systemctl start clickhouse-server  或  sudo /etc/init.d/clickhouse-server start  

#安装clickhouse-client,在其中一台机器安装即可,用于命令连接clickhouse-server
tar -xzvf clickhouse-client-$LATEST_VERSION.tgz
sudo clickhouse-client-$LATEST_VERSION/install/doinst.sh

修改配置

安装成功后,在/etc/clickhouse-server/ 目录下生成配置文件config.xml及user.xml、自定义配置目录config.d及users.d,推荐在config.d及users.d下新建配置文件,然后在config.xml及user.xml中引入config.d及users.d下的配置文件。

  • 修改config.xml
mkdir /opt/clickhouse_data    #新建ClickHouse数据目录
chown -R clickhouse:clickhouse /opt/clickhouse_data #注意修改目录权限
sudo vim /etc/clickhouse-server/config.xml
trace
/opt/clickhouse_data/log/clickhouse-server/clickhouse-server.log
/opt/clickhouse_data/log/clickhouse-server/clickhouse-server.err.log
/opt/clickhouse_data/clickhouse/
/opt/clickhouse_data/clickhouse/tmp/
/opt/clickhouse_data/clickhouse/user_files/
/etc/clickhouse-server/config.d/metrika.xml 
  • 新建/etc/clickhouse-server/config.d/metrika.xml
vim /etc/clickhouse-server/config.d/metrika.xml

你可能感兴趣的:(ClickHouse高可用集群搭建(离线安装))