【发布时间】: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')
然后我在 ch1 的 test.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