【问题标题】:is there someway to sharding in clickhouse?有没有办法在clickhouse中进行分片?
【发布时间】:2019-10-22 13:48:47
【问题描述】:

我有两个关于如何在 clickhouse 中分片的问题。

第一季度。 clickhouse中分片是否需要使用分布式引擎?

第二季度。 我想知道是否可以根据我设置的标准进行分片,而不是根据分片的权重自动分配。

Example.
 - If id is 1, it is stored in shard1.
 - If id is 2, it is stored in shard2.
 - If id is 3, it is stored in shard3.



I understand the sharding through the distribution engine as follows.
- distributed engine use the cluster defined in the config.xml file.
- It is automatically distributed to the shard according to the weight of the shard.

感谢您阅读我的问题。期待您的回复。

【问题讨论】:

    标签: clickhouse


    【解决方案1】:

    第一季度。 clickhouse中分片是否需要使用分布式引擎?

    是的。分布式引擎知道如何将查询分发到分布在分片和副本上的本地表。如果没有这个,您将需要在每个分片上运行查询并自己组装结果。

    第二季度。我想知道是否可以根据我设置的标准进行分片,而不是根据分片的权重自动分配。

    是的。有两种方法可以将数据写入分片。

    1. 通过分布式表插入。 ClickHouse 将使用分片键分发到本地表。
    2. 直接写入本地表。在这种情况下,由您决定如何分发数据。许多安装使用这种方法,因为它可以通过直接访问基础表来实现更高的性能。

    分布式引擎实际上只是通往本地表的网关,这就是#2 起作用的原因。

    【讨论】:

    • 感谢您的回复。但我还有三个问题。 1. sharding key 是不是只能是常量或者表的列? 2. 当数据使用shading key进行分发时,我们能预测数据插入到哪个shard吗? 3、如果每个shard的权重相同,应该如何设置sharding key才能让每个shard平均分配?
    猜你喜欢
    • 2021-08-16
    • 2021-06-26
    • 1970-01-01
    • 2021-10-15
    • 2020-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多