前言
插件及服务器版本
服务器:ubuntu 16.04
ClickHouse:21.4.6.55
配置一个单Shard、3副本的ClickHouse集群,并验证测试
3台ubuntu 16.04的服务器:
192.168.10.17
192.168.10.10
192.168.10.16
3台服务器均安装ClickHouse:
sudo apt-get install apt-transport-https ca-certificates dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4
echo "deb https://repo.clickhouse.tech/deb/stable/ main/" | sudo tee \
/etc/apt/sources.list.d/clickhouse.list
sudo apt-get update
sudo apt-get install -y clickhouse-server clickhouse-client
sudo service clickhouse-server start
clickhouse-client
修改3台服务器ClickHouse配置文件 /etc/clickhouse-server/config.xml
1、在 <remote_servers> 标签内添加如下配置:
配置副本节点
<nt_1shards_3replicas>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>192.168.10.17</host>
<port>9000</port>
</replica>
<replica>
<host>192.168.10.10</host>
<port>9000</port>
</replica>
<replica>
<host>192.168.10.16</host>
<port>9000</port>
</replica>
</shard>
</nt_1shards_3replicas>
2、添加zookeeper配置
<zookeeper>
<node index="1">
<host>192.168.10.17</host>
<port>2181</port>
</node>
<node index="2">
<host>192.168.10.10</host>
<port>2181</port>
</node>
<node index="3">
<host>192.168.10.16</host>
<port>2181</port>
</node>
</zookeeper>
3、添加macros配置
<macros>
<shard>1</shard>
<replica>192.168.10.17</replica> //这里每个结点的配置添加当前节点IP
</macros>
systemctl restart clickhouse-server.service
ClickHouse-Client查看配置是否生效:
select * from system.clusters;
CREATE TABLE test_replicated ON CLUSTER nt_1shards_3replicas
(
id String,
code String
)ENGINE = ReplicatedMergeTree('/clickhouse/tables/nt_1shards_3replicas/{shard}/test_replicated','{replica}')
ORDER BY id
SETTINGS index_granularity= 8192;
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://gaokaiyang.blog.csdn.net/article/details/116526966
内容来源于网络,如有侵权,请联系作者删除!