【问题标题】:clickhouse cluster : data not replicatedclickhouse 集群:数据未复制
【发布时间】:2021-05-21 13:35:17
【问题描述】:

我有一个包含 2 个节点的集群进行测试。 1 个分片和 2 个副本。 zookeeper集群3个节点

<remote_servers>
  <ch_cluster>
    <shard>
      <internal_replication>true</internal_replication>
      <replica>
        <host>ch1</host>
        <port>9000</port>
      </replica>
      <replica>
        <host>ch2</host>
        <port>9000</port>
      </replica>
    </shard>
  </ch_cluster>
</remote_servers>

ch1 中的宏:

  <macros>
        <shard>shard_01</shard>
        <replica>replica-01</replica>
    </macros>

ch2 中的宏:

   <macros>
        <shard>shard_01</shard>
        <replica>replica-02</replica>
    </macros>

动物园管理员配置:

   <zookeeper>
        <node>
            <host>zoo1</host>
            <port>2181</port>
        </node>
        <node>
            <host>zoo2</host>
            <port>2181</port>
        </node>
        <node>
            <host>zoo3</host>
            <port>2181</port>
        </node>
    </zookeeper>

我创建了第一个表

CREATE TABLE IF NOT EXISTS test.hits_local ON CLUSTER ch_cluster
(
  `date` Datetime,
  `user_id` String,
  `pageviews` Int32
)
ENGINE = ReplicatedMergeTree('/clickhouse/ch_cluster/tables/{shard}/hits_local', '{replica}')
PARTITION BY toStartOfHour(date)
ORDER BY (date)

然后我创建一个分布式表:

CREATE TABLE IF NOT EXISTS test.hits ON CLUSTER 'ch_cluster'
AS test.hits_local 
 (
      `date` Datetime,
      `user_id` String,
      `pageviews` Int32
    )
ENGINE = Distributed('ch_cluster', 'test', 'hits_local')

然后我在 ch1test.hits_local 表中插入数据 当从 ch2 中的 test.hits_local 中选择数据时,没有数据

然后我尝试从 ch2 中的 test.hits 分布式表中选择数据在 5-6 分钟后出现 但在 ch2

test.hits_local 中没有数据

我的问题是何时将数据复制到 ch2? 谁负责将数据复制到另一个节点?它是动物园管理员还是应该将数据插入到 ch1 和 ch2 的表中? 我应该将 internal_replicationtrueinternal_replication> 更改为 false 吗?

是否需要将数据复制到 ch2 中的 test.hits_local 中?

谢谢。

【问题讨论】:

    标签: replication database-replication clickhouse


    【解决方案1】:

    我应该将 true 改为 false 吗?

    不,你不应该。如果您使用 ReplicatedMergeTree internal_replication 必须为 true

    复制由 ReplicatedMergeTree 表引擎在内部完成。

    副本使用其主机名和端口 = 9009 进行通信。 检查 system.replication_queue 表是否有错误。

    很可能节点“ch1”在 Zookeeper 中宣布了自己的主机名,即“localhost”。 所以第二个节点“ch2”无法访问 localhost:9009 什么的。 您可以在 clickhouse-server.log 或 system.replication_queue 中找到此类问题(它有一列有错误)。

    即使在负载非常高的设置中,复制延迟通常也小于 2 秒。

    【讨论】:

    • zookeeper 在不同的节点上运行。如果发现此错误,我检查了日志文件: - default.hits_local (ReplicatedMergeTreeRestartingThread): 无法开始复制:副本 /clickhouse/ch_cluster/tables/01/hits_local/replicas/replica-1 似乎已经处于活动状态(主机:ch-01.localdomain,端口:9009,tcp_port:9000,数据库:默认,表:hits_local,方案:http,)。如果您确定不是,请稍后再试或手动删除 znode /clickhouse/ch_cluster/tables/01/hits_local/replicas/replica-1/is_active。 @Denny Crane
    • @alim 表示配置错误。检查所有主机是否都可以使用 NS ch-01.localdomain
    • 非常感谢 Denny Crane :) 它是 ch1 然后我将其更改为 ch-01
    猜你喜欢
    • 1970-01-01
    • 2019-01-08
    • 2019-01-15
    • 1970-01-01
    • 1970-01-01
    • 2019-10-27
    • 1970-01-01
    • 1970-01-01
    • 2016-12-25
    相关资源
    最近更新 更多