I have a cluster with 2 nodes for a test. 1 Shard and 2 replica. 3 nodes in the zookeeper cluster
<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>
macros in ch1 :
<macros>
<shard>shard_01</shard>
<replica>replica-01</replica>
</macros>
macro in ch2 :
<macros>
<shard>shard_01</shard>
<replica>replica-02</replica>
</macros>
zookeeper configuration :
<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>
I create the first table
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)
then i create a distributed table :
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')
then i insert data in test.hits_local table in ch1 when select data from test.hits_local in ch2 there is no data
then i tried to select from test.hits Distributed table in ch2 the data appear after 5-6 min but no data in test.hits_local in ch2
my question when the data replicated to ch2? who is responsible to replicate data to another node ? is it a zookeeper or should i insert the data into tables in ch1 and ch2? should i change <internal_replication>true</internal_replication> to false ?
is it necessary for the data to be replicated to test.hits_local in ch2?
thank you.