Skip to main content

Create db and replicated tables

Build Replicated ClickHouse Tables

Keeper is fully working.
Now you can create replicated database + replicated tables that sync across all 3 servers.


๐Ÿš€ Step-by-step instructions (copy/paste)

1. Create database on all nodes:


CREATE DATABASE replicated_db;

2. Create table with replication

Node1:


CREATE TABLE replicated_db.events ( id UInt64, msg String ) ENGINE = ReplicatedMergeTree('/clickhouse/tables/events', 'replica1') ORDER BY id;

Node2:


CREATE TABLE replicated_db.events ( id UInt64, msg String ) ENGINE = ReplicatedMergeTree('/clickhouse/tables/events', 'replica2') ORDER BY id;

Node3:


CREATE TABLE replicated_db.events ( id UInt64, msg String ) ENGINE = ReplicatedMergeTree('/clickhouse/tables/events', 'replica3') ORDER BY id;

๐Ÿงช Test replication:

Insert into Node1:


INSERT INTO replicated_db.events VALUES (1, 'hello');

Check on Node2:


SELECT * FROM replicated_db.events;

Check on Node3:


SELECT * FROM replicated_db.events;

You will see:


1 | hello