ClickHouse集群配置
(基于ClickHouse版本21.4.6.55)
1. ClickHouse集群(3分片2副本配置)
<?xml version="1.0"?>
<yandex>
<remote_servers>
<shards3_replications2>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>hadoop01</host>
<port>9000</port>
</replica>
<replica>
<host>hadoop02</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>hadoop03</host>
<port>9000</port>
</replica>
<replica>
<host>hadoop04</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>hadoop05</host>
<port>9000</port>
</replica>
<replica>
<host>hadoop06</host>
<port>9000</port>
</replica>
</shard>
</shards3_replications2>
</remote_servers>
<zookeeper>
<node index="1">
<host>hadoop01</host>
<port>2181</port>
</node>
<node index="2">
<host>hadoop02</host>
<port>2181</port>
</node>
<node index="3">
<host>hadoop03</host>
<port>2181</port>
</node>
</zookeeper>
</yandex>
共6个节点,3个分片,每个分片2个副本。由于分片数一样,每个分片的副本数也一样,所以不需要配置macros
标签。
2. ClickHouse集群(2分片1副本配置)
<?xml version="1.0"?>
<yandex>
<remote_servers>
<shards2_replications1>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>hadoop01</host>
<port>9000</port>
</replica>
<replica>
<host>hadoop02</host>
<port>9000</port>
</replica>
</shard>
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>hadoop03</host>
<port>9000</port>
</replica>
</shard>
</shards2_replications1>
</remote_servers>
<zookeeper>
<node index="1">
<host>hadoop01</host>
<port>2181</port>
</node>
<node index="2">
<host>hadoop02</host>
<port>2181</port>
</node>
<node index="3">
<host>hadoop03</host>
<port>2181</port>
</node>
</zookeeper>
<macros>
<shard>01</shard>
<replica>rep_1_1</replica>
</macros>
</yandex>
其中由于一共只有3个节点,2个分片并且只有其中一个分片有副本,所有必须配置macros
标签,其中写清楚每个机器上存储的是哪一个分片,哪一个副本即可。