【问题标题】:Distributed table deleting partition分布式表删除分区
【发布时间】:2020-04-12 05:03:18
【问题描述】:

我创建了复制的合并树表如下:

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>

删除分区时有两个问题:

  1. 当我使用分布式表删除分区时

    集群 dwh DROP PARTITION '2020-03-13' 上的 ALTER TABLE probe.a;

我得到错误:

DB::Exception: 表 'a' 已复制,但 shard #4 未复制 根据其集群定义。可能 真实被遗忘在 集群配置。 (版本 19.16.14.65) (版本 19.16.14.65)

  1. 单独删除了分区,但分布式表仍然显示一半的行,但是当我在本地检查时没有行

对于没有复制的数据分片,如何解决分布式表的这个问题?

【问题讨论】:

  • 如果我正确理解您的集群由 2 个分片和 2 个副本组成 - 每个分片的副本数应该是 2 个或更多是错误的。您需要添加两个额外的服务器,以便每个服务器存储分片的两个副本之一(分片数为 2),或者使用circular topology 在一台服务器上存储两个副本(不推荐使用这种方式)。
  • @vladimir,我只使用两个分片。没有复制。目前不需要复制。我只是因为数据量大而要分离数据。
  • 为什么表 probe.a 定义为 ReplicatedMergeTree 而不是 MergeTree
  • 应该和现在一样,但是使用MergeTree-engine。分布式表 + 相关集群配置保持不变。

标签: clickhouse


【解决方案1】:

您使用复制表。你必须用&lt;internal_replication&gt;true&lt;/internal_replication&gt; 标记你的分片。

<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>

【讨论】:

  • 似乎这是问题所在,因为只添加了一个服务器 internal_replication。
猜你喜欢
  • 2019-11-17
  • 2021-09-12
  • 2015-01-19
  • 2020-01-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-18
  • 2020-10-18
相关资源
最近更新 更多