环境
OS:Centos 7
clickhouse:24.8.11.5
拓扑结构:3分片单副本
节点ip 角色
192.168.1.102 分片1
192.168.1.105 分片2, zookeeper单点
192.168.1.106 分片3
1.安装zookeeper(单机)
参考如下安装部署连接:
https://www.cnblogs.com/hxlasky/p/18683624
#####################clickhouse部署(每个节点都安装)############################
1.准备安装介质
介质下载地址:
https://packages.clickhouse.com/rpm/stable/
或是
https://packagecloud.io/Altinity/clickhouse
我这里下载的是如下三个包
clickhouse-client-24.8.11.5.x86_64.rpm
clickhouse-common-static-24.8.11.5.x86_64.rpm
clickhouse-server-24.8.11.5.x86_64.rpm
[root@node1 soft]# mkdir /soft/clickhouse
[root@node1 soft]# cd /soft/clickhouse
wget https://packages.clickhouse.com/rpm/stable/clickhouse-client-24.8.11.5.x86_64.rpm
wget https://packages.clickhouse.com/rpm/stable/clickhouse-common-static-24.8.11.5.x86_64.rpm
wget https://packages.clickhouse.com/rpm/stable/clickhouse-server-24.8.11.5.x86_64.rpm
2.安装
[root@localhost clickhouse]#rpm -ivh clickhouse-common-static-24.8.11.5.x86_64.rpm
[root@localhost clickhouse]#rpm -ivh clickhouse-client-24.8.11.5.x86_64.rpm
[root@localhost clickhouse]#rpm -ivh clickhouse-server-24.8.11.5.x86_64.rpm
3.修改数据目录和日志目录
创建数据目录和日志目录
[root@localhost ~]# mkdir -p /home/middle/clickhouse/data
[root@localhost ~]# mkdir -p /home/middle/clickhouse/log
[root@localhost ~]# chown -R clickhouse:clickhouse /home/middle/clickhouse/
修改数据目录
vi /etc/clickhouse-server/config.xml
原来的<!-- Path to data directory, with trailing slash. --><path>/var/lib/clickhouse/</path>
修改为<!-- Path to data directory, with trailing slash. --><path>/home/middle/clickhouse/data/</path>
修改日志目录
原来的:<level>trace</level><log>/var/log/clickhouse-server/clickhouse-server.log</log><errorlog>/var/log/clickhouse-server/clickhouse-server.err.log</errorlog>
修改为:<level>trace</level><log>/home/middle/clickhouse/log/clickhouse-server.log</log><errorlog>/home/middle/clickhouse/log/clickhouse-server.err.log</errorlog>
4.配置远程登录
[root@localhost clickhouse]#vi /etc/clickhouse-server/config.xml
把下面2行注释去掉,之前是注释的,现在要开启
原来的:<!-- Default values - try listen localhost on IPv4 and IPv6. --><!--<listen_host>::1</listen_host><listen_host>127.0.0.1</listen_host>-->
修改为:<!-- Default values - try listen localhost on IPv4 and IPv6. --><listen_host>::1</listen_host>
<listen_host>0.0.0.0</listen_host>
5.修改允许删除掉任何表和表分区,将如下两行去掉注释,使其生效
[root@localhost clickhouse]#vi /etc/clickhouse-server/config.xml
原来的:<!-- <max_table_size_to_drop>0</max_table_size_to_drop> --><!-- <max_partition_size_to_drop>0</max_partition_size_to_drop> -->
修改为:<max_table_size_to_drop>0</max_table_size_to_drop> <max_partition_size_to_drop>0</max_partition_size_to_drop>
6.拷贝配置文件到另外的实例
scp /etc/clickhouse-server/config.xml root@192.168.1.105:/etc/clickhouse-server/
scp /etc/clickhouse-server/config.xml root@192.168.1.106:/etc/clickhouse-server/
7.启动clickhouse-server
每个节点都尝试启动
centos 7需要使用systemctl启动
systemctl status clickhouse-server.service
systemctl start clickhouse-server.service
systemctl stop clickhouse-server.service
clickhouse默认使用的是9000端口,注意避免端口冲突:
<tcp_port>9000</tcp_port>
8.尝试登录
每个节点都尝试登录,目前是免密登录的
clickhouse-client --host localhost