clickhouse集群部署

一、安装clickhouse

本示例安装在:centos7

按照官网RPM安装包安装步骤:

sudo yum install yum-utils
sudo rpm --import https://repo.clickhouse.com/CLICKHOUSE-KEY.GPG
sudo yum-config-manager --add-repo https://repo.clickhouse.com/rpm/stable/x86_64

然后运行命令安装:

sudo yum install clickhouse-server clickhouse-client

启动:

$ sudo /etc/init.d/clickhouse-server start

启动服务后,您可以使用命令行客户端连接到它:

#默认没有密码:
$ clickhouse-client
#有密码:
$ clickhouse-client -u default --password

示例:

$ ./clickhouse-client
ClickHouse client version 0.0.18749.
Connecting to localhost:9000.
Connected to ClickHouse server version 0.0.18749.

:) SELECT 1

SELECT 1

┌─1─┐
│ 1 │
└───┘

1 rows in set. Elapsed: 0.003 sec.

:)

恭喜正常工作了

也可以按指定版本安装,例如:

curl -O "https://packages.clickhouse.com/tgz/stable/clickhouse-common-static-22.2.2.1.tgz"
curl -O "https://packages.clickhouse.com/tgz/stable/clickhouse-common-static-dbg-22.2.2.1.tgz"
curl -O "https://packages.clickhouse.com/tgz/stable/clickhouse-server-22.2.2.1.tgz"
curl -O "https://packages.clickhouse.com/tgz/stable/clickhouse-client-22.2.2.1.tgz"

tar -xzvf "clickhouse-common-static-22.2.2.1.tgz"
sudo "clickhouse-common-static-22.2.2.1/install/doinst.sh"

tar -xzvf "clickhouse-common-static-dbg-22.2.2.1.tgz"
sudo "clickhouse-common-static-dbg-22.2.2.1/install/doinst.sh"

tar -xzvf "clickhouse-server-22.2.2.1.tgz"
sudo "clickhouse-server-22.2.2.1/install/doinst.sh"
sudo /etc/init.d/clickhouse-server start

tar -xzvf "clickhouse-client-22.2.2.1.tgz"
sudo "clickhouse-client-22.2.2.1/install/doinst.sh"

集群配置:

zookeeper的配置参考我另外的文章。

默认密码的修改:

vi /etc/clickhouse-server/users.xml

clickhouse集群部署_第1张图片

clickhouse配置文件:

vi /etc/clickhouse-server/config.xml

配置 listen_host字段:

clickhouse集群部署_第2张图片

 配置zookeeper字段:

clickhouse集群部署_第3张图片

配置 remote_server字段:

clickhouse集群部署_第4张图片

 配置macros字段:

此处根据每个节点的信息进行配置,示例为第五个分片的第一个副本,第四个的将5改为4即可,也可以自己命名。

clickhouse集群部署_第5张图片

 此时配置基本完成。

尝试使用命令查询节点信息:

select * from system.clusters;

clickhouse集群部署_第6张图片

 正确显示各个节点表示集群配置完成。

其他知识点:

clickhouse 数据存放在 /var/lib/clickhouse/data/
clickhouse 表存放在   /var/lib/clickhouse/store/cef/cef43d0f-85a0-422f-82d0-ebd98a26cef2/  表文件一般为 datas.sql  datas_all.sql

clickhouse 日志存放在 /var/log/clickhouse-server/

问题集锦:

Received exception from server (version 21.12.3):
Code: 279. DB::Exception: Received from localhost:9000. DB::Exception: All connection tries failed. Log: 

Code: 210. DB::NetException: Net Exception: No route to host (192.168.2.20:9000). (NETWORK_ERROR) (version 21.12.3.32 (official build))
Code: 210. DB::NetException: Net Exception: No route to host (192.168.2.20:9000). (NETWORK_ERROR) (version 21.12.3.32 (official build))
Code: 210. DB::NetException: Net Exception: No route to host (192.168.2.20:9000). (NETWORK_ERROR) (version 21.12.3.32 (official build))

: While executing Remote. (ALL_CONNECTION_TRIES_FAILED)

其他资料:

出现这个错误有两个位置可能造成:

1、listen_host字段没有取消注释或者取消注释的位置不对。

2、防火墙没有关闭

你可能感兴趣的:(其他,clickhouse,clickhouse集群,clickhouse集群配置,clickhouse安装)