-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clickhouse: Supporting replicated merge tree (#22)
- Loading branch information
Showing
23 changed files
with
255 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
version: '3.9' | ||
|
||
services: | ||
|
||
clickhouse0: | ||
image: yandex/clickhouse-server | ||
container_name: clickhouse0 | ||
volumes: | ||
- ./tests/clickhouse/macros.xml:/etc/clickhouse-server/conf.d/macros.xml | ||
- ./tests/clickhouse/zookeeper.xml:/etc/clickhouse-server/conf.d/zookeeper.xml | ||
- ./tests/clickhouse/remote_servers.xml:/etc/clickhouse-server/config.d/remote_servers.xml | ||
ports: | ||
- 8123:8123 | ||
- 9000:9000 | ||
environment: | ||
CLICKHOUSE_DB: miga | ||
CLICKHOUSE_USER: user | ||
CLICKHOUSE_PASSWORD: password | ||
REPLICA_NAME: clickhouse0 | ||
healthcheck: | ||
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8123/ping"] | ||
interval: 5s | ||
timeout: 3s | ||
retries: 3 | ||
|
||
clickhouse1: | ||
image: yandex/clickhouse-server | ||
container_name: clickhouse1 | ||
volumes: | ||
- ./tests/clickhouse/macros.xml:/etc/clickhouse-server/conf.d/macros.xml | ||
- ./tests/clickhouse/zookeeper.xml:/etc/clickhouse-server/conf.d/zookeeper.xml | ||
- ./tests/clickhouse/remote_servers.xml:/etc/clickhouse-server/config.d/remote_servers.xml | ||
environment: | ||
CLICKHOUSE_DB: miga | ||
CLICKHOUSE_USER: user | ||
CLICKHOUSE_PASSWORD: password | ||
REPLICA_NAME: clickhouse1 | ||
healthcheck: | ||
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8123/ping"] | ||
interval: 5s | ||
timeout: 3s | ||
retries: 3 | ||
|
||
zookeeper: | ||
image: wurstmeister/zookeeper | ||
container_name: zookeeper | ||
hostname: zookeeper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<yandex> | ||
<macros> | ||
<installation>chapsuk</installation> | ||
<all-sharded-shard>0</all-sharded-shard> | ||
<cluster>miga</cluster> | ||
<shard>0</shard> | ||
<replica from_env="REPLICA_NAME" /> | ||
</macros> | ||
</yandex> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<yandex> | ||
<remote_servers> | ||
<miga> | ||
<shard> | ||
<internal_replication>true</internal_replication> | ||
<replica> | ||
<host>clickhouse0</host> | ||
<port>9000</port> | ||
</replica> | ||
<replica> | ||
<host>clickhouse1</host> | ||
<port>9000</port> | ||
</replica> | ||
</shard> | ||
</miga> | ||
</remote_servers> | ||
</yandex> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<yandex> | ||
<default_replica_path>/clickhouse/{installation}/{cluster}/tables/{shard}/{database}/{table}</default_replica_path> | ||
<default_replica_name>{replica}</default_replica_name> | ||
|
||
<zookeeper> | ||
<node> | ||
<host>zookeeper</host> | ||
<port>2181</port> | ||
</node> | ||
</zookeeper> | ||
</yandex> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- +goose Up | ||
CREATE TABLE users_replicated ON CLUSTER '{cluster}' ( | ||
id BIGINT, | ||
name VARCHAR(128), | ||
migastas BIGINT DEFAULT 0 | ||
) engine=MergeTree() order by id; | ||
|
||
-- +goose Down | ||
DROP TABLE IF EXISTS users_replicated ON CLUSTER '{cluster}'; |
8 changes: 8 additions & 0 deletions
8
tests/migrations/goose_clickhouse_replicated/00002_wallets.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- +goose Up | ||
CREATE TABLE wallets_replicated ON CLUSTER '{cluster}' ( | ||
id BIGINT, | ||
user_id BIGINT | ||
) engine=MergeTree() order by id; | ||
|
||
-- +goose Down | ||
DROP TABLE IF EXISTS wallets_replicated ON CLUSTER '{cluster}'; |
7 changes: 7 additions & 0 deletions
7
tests/migrations/goose_clickhouse_replicated/00003_add_users_email.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- +goose Up | ||
SET replication_alter_partitions_sync = 2; | ||
ALTER TABLE users_replicated ON CLUSTER '{cluster}' ADD COLUMN email VARCHAR(128); | ||
|
||
-- +goose Down | ||
SET replication_alter_partitions_sync = 2; | ||
ALTER TABLE users_replicated ON CLUSTER '{cluster}' DROP COLUMN email; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- +goose Up | ||
ALTER TABLE users_replicated ON CLUSTER '{cluster}' ADD COLUMN email VARCHAR; | ||
|
||
-- +goose Down | ||
ALTER TABLE users_replicated ON CLUSTER '{cluster}' DROP COLUMN IF EXISTS email; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- +goose Up | ||
CREATE TABLE never_replicated ON CLUSTER '{cluster}' ( | ||
id INT | ||
) engine=Memory; | ||
|
||
-- +goose Down | ||
DROP TABLE IF EXISTS never_replicated ON CLUSTER '{cluster}'; |
Oops, something went wrong.