以下示例集群配置:
<clickhouse_remote_servers>
<shard_replica_cluster_1>
<shard>
<weight>1</weight>
<internal_replication>true</internal_replication>
<replica>
<host>ch01</host>
<port>9000</port>
</replica>
<replica>
<host>ch02</host>
<port>9000</port>
</replica>
</shard>
<shard>
<weight>1</weight>
<internal_replication>true</internal_replication>
<replica>
<host>ch03</host>
<port>9000</port>
</replica>
<replica>
<host>ch04</host>
<port>9000</port>
</replica>
</shard>
</shard_replica_cluster_1>
</clickhouse_remote_servers>
注意,以下 2 种方式在缩小容期间可能会导致还集群对外服务暂停。
副本节点下线,主副本仍然保留相同的数据,因此不需要对副本节点数据进行备份。
同时由于主副本和副本间是对等的,因此下线主副本和副本原理相同,下线主副本后,副本分片会选举成为主副本提供服务。
主要步骤(下线副本 A):
mertrika.xml
配置中去除需要下线的副本 A 的 replica 配置;以下示例下线分片 1 的 ch02 分片。
1. 修改所有节点 metrika.xml,移除 ch02 replica 配置。
<clickhouse_remote_servers>
<shard_replica_cluster_1>
<shard>
<weight>1</weight>
<internal_replication>true</internal_replication>
<replica>
<host>ch01</host>
<port>9000</port>
</replica>
</shard>
<shard>
<weight>1</weight>
<internal_replication>true</internal_replication>
<replica>
<host>ch03</host>
<port>9000</port>
</replica>
<replica>
<host>ch04</host>
<port>9000</port>
</replica>
</shard>
</shard_replica_cluster_1>
</clickhouse_remote_servers>
2. 重启 ch01、ch03、ch04 节点,下线 ch02 节点
ch01/ch03/ch04 :) clickhouse-server restart
ch02 :) clickhouse-server stop
# 检查节点
ch01 :) select * from system.clusters