简体   繁体   中英

ClickHouse ReplicatedMergeTrees configuration problems

I have two tables on two different machines both running zookeeper as a daemon, one of them has myid 1 the other has myid 2.

The table is configured as such on the machine "1":

CREATE TABLE test(values)
ReplicatedMergeTree('/clickhouse/tables/01/test', '1', date, timestamp, 8192)

The table is configured as such on the machine "2":

CREATE TABLE test(values)
ReplicatedMergeTree('/clickhouse/tables/01/test', '2', date, timestamp, 8192)

The 01 in the '/clickhouse/tables/01/test' is probably the values messing with me... since I '{layer}-{shard}' with it.... but since I have no remote_servers configured I assumed I can just use any value and it wouldn't matter, since I don't want query distribution, just data duplication.

Also the tables seem to be "aware" of eachother since creating two tables with the replica number '2' or '1' results in an error saying such a table already exists.

Do I need to configure a remote_server by default if I want to use replication ? Do I need to configure zookeeper specifically for the tables I want to replicated ? Do you guys have any in-details examples of setting up data replication with clickhouse ?

It seems that you have done everything correctly. {layer}-{shard} part is optional - it just simplifies creation of similar tables on many servers. Bare minimum for configuring a replicated table is a path in zookeeper that is common for all replicas (by convention this path starts with /clickhouse/tables/ but in fact any unique path will do) and an identifier that is unique to each replica ( '1' and '2' are totally OK, but more descriptive names allowing you to identify the corresponding host are recommended).

Configuring remote_servers is not necessary for replication, but zookeeper is required. You can use a single zookeeper cluster for all replicated tables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM