我创建了复制的合并树表,如下所示:
CREATE TABLE probe.a on cluster dwh (
instime UInt64,
psn UInt64
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/probe/a', '{replica}') PARTITION BY instime ORDER BY (psn);然后,我创建了一个分布式表,如下:
CREATE TABLE probe.a_distributed on cluster dwh (
instime UInt64,
psn UInt64
) ENGINE = Distributed(dwh,probe, a, rand());然后,我在每个服务器中添加了宏:
服务器1
<yandex>
<macros replace="true">
<shard>1</shard>
<replica>server1.com</replica>
</macros>
</yandex>服务器2
<yandex>
<macros replace="true">
<shard>2</shard>
<replica>server2.com</replica>
</macros>
</yandex>远程服务器:
<dwh>
<!-- shard 01 -->
<shard>
<replica>
<host>server1.com</host>
<port>9000</port>
<user>default</user>
<password>test12pwd</password>
</replica>
</shard>
<!-- shard 02 -->
<shard>
<replica>
<host>server2.com</host>
<port>9000</port>
<user>default</user>
<password>test12pwd</password>
</replica>
</shard>
</dwh>我在删除分区时有两个问题:
当我使用分布式表删除分区时,
在集群dwh删除分区'2020-03-13';上的ALTER probe.a
我得到了错误:
DB::Exception:表'a‘被复制,但是shard #4没有根据集群定义复制。可能在集群配置中忘记了true。(19.16.14.65版)(19.16.14.65版)
。

如何解决分布式表中的问题,以解决数据共享而不进行复制?
发布于 2020-04-12 14:27:59
使用复制的表。你必须用<internal_replication>true</internal_replication>标记你的碎片。
<dwh>
<!-- shard 01 -->
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>server1.com</host>
<port>9000</port>
<user>default</user>
<password>test12pwd</password>
</replica>
</shard>
<!-- shard 02 -->
<shard>
<internal_replication>true</internal_replication>
<replica>
<host>server2.com</host>
<port>9000</port>
<user>default</user>
<password>test12pwd</password>
</replica>
</shard>
</dwh>https://stackoverflow.com/questions/61167079
复制相似问题