Работающий кластер
This commit is contained in:
@@ -0,0 +1 @@
|
||||
.$*.bkp
|
||||
@@ -0,0 +1,4 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
CC BY 4.0 licence
|
||||
https://creativecommons.org/licenses/by/4.0/
|
||||
@@ -0,0 +1,7 @@
|
||||
<clickhouse>
|
||||
<users>
|
||||
<default>
|
||||
<password>123456</password>
|
||||
</default>
|
||||
</users>
|
||||
</clickhouse>
|
||||
@@ -0,0 +1,20 @@
|
||||
global
|
||||
maxconn 4096
|
||||
log stdout format raw local0
|
||||
|
||||
defaults
|
||||
mode tcp
|
||||
timeout connect 10s
|
||||
timeout client 1m
|
||||
timeout server 1m
|
||||
|
||||
frontend clickhouse_front
|
||||
bind *:8123
|
||||
default_backend clickhouse_back
|
||||
|
||||
backend clickhouse_back
|
||||
balance roundrobin
|
||||
server clickhouse1 click1:8123 check
|
||||
server clickhouse2 click2:8123 check
|
||||
server clickhouse3 click3:8123 check
|
||||
server clickhouse4 click4:8123 check
|
||||
@@ -0,0 +1,10 @@
|
||||
<clickhouse>
|
||||
<macros>
|
||||
<shard_c1sh4rep>01</shard_c1sh4rep>
|
||||
<shard_c2sh2rep>01</shard_c2sh2rep>
|
||||
<shard_c4sh1rep>01</shard_c4sh1rep>
|
||||
<replica_c1sh4rep>rep1</replica_c1sh4rep>
|
||||
<replica_c2sh2rep>rep1</replica_c2sh2rep>
|
||||
<replica_c4sh1rep>rep1</replica_c4sh1rep>
|
||||
</macros>
|
||||
</clickhouse>
|
||||
@@ -0,0 +1,10 @@
|
||||
<clickhouse>
|
||||
<macros>
|
||||
<shard_c1sh4rep>01</shard_c1sh4rep>
|
||||
<shard_c2sh2rep>01</shard_c2sh2rep>
|
||||
<shard_c4sh1rep>02</shard_c4sh1rep>
|
||||
<replica_c1sh4rep>rep2</replica_c1sh4rep>
|
||||
<replica_c2sh2rep>rep2</replica_c2sh2rep>
|
||||
<replica_c4sh1rep>rep1</replica_c4sh1rep>
|
||||
</macros>
|
||||
</clickhouse>
|
||||
@@ -0,0 +1,10 @@
|
||||
<clickhouse>
|
||||
<macros>
|
||||
<shard_c1sh4rep>01</shard_c1sh4rep>
|
||||
<shard_c2sh2rep>02</shard_c2sh2rep>
|
||||
<shard_c4sh1rep>03</shard_c4sh1rep>
|
||||
<replica_c1sh4rep>rep3</replica_c1sh4rep>
|
||||
<replica_c2sh2rep>rep1</replica_c2sh2rep>
|
||||
<replica_c4sh1rep>rep1</replica_c4sh1rep>
|
||||
</macros>
|
||||
</clickhouse>
|
||||
@@ -0,0 +1,10 @@
|
||||
<clickhouse>
|
||||
<macros>
|
||||
<shard_c1sh4rep>01</shard_c1sh4rep>
|
||||
<shard_c2sh2rep>02</shard_c2sh2rep>
|
||||
<shard_c4sh1rep>04</shard_c4sh1rep>
|
||||
<replica_c1sh4rep>rep4</replica_c1sh4rep>
|
||||
<replica_c2sh2rep>rep2</replica_c2sh2rep>
|
||||
<replica_c4sh1rep>rep1</replica_c4sh1rep>
|
||||
</macros>
|
||||
</clickhouse>
|
||||
@@ -0,0 +1,48 @@
|
||||
<clickhouse>
|
||||
<remote_servers replace="true">
|
||||
<!-- 1 shards 4 replicas -->
|
||||
<c1sh4rep>
|
||||
<shard>
|
||||
<internal_replication>true</internal_replication>
|
||||
<replica><host>click1</host><port>9000</port><user>default</user><password>123456</password></replica>
|
||||
<replica><host>click2</host><port>9000</port><user>default</user><password>123456</password></replica>
|
||||
<replica><host>click3</host><port>9000</port><user>default</user><password>123456</password></replica>
|
||||
<replica><host>click4</host><port>9000</port><user>default</user><password>123456</password></replica>
|
||||
</shard>
|
||||
</c1sh4rep>
|
||||
<!-- 4 shards 1 replicas -->
|
||||
<c4sh1rep>
|
||||
<shard>
|
||||
<replica><host>click1</host><port>9000</port><user>default</user><password>123456</password></replica>
|
||||
</shard>
|
||||
<shard>
|
||||
<replica><host>click2</host><port>9000</port><user>default</user><password>123456</password></replica>
|
||||
</shard>
|
||||
<shard>
|
||||
<replica><host>click3</host><port>9000</port><user>default</user><password>123456</password></replica>
|
||||
</shard>
|
||||
<shard>
|
||||
<replica><host>click4</host><port>9000</port><user>default</user><password>123456</password></replica>
|
||||
</shard>
|
||||
</c4sh1rep>
|
||||
<!-- 2 shards 2 replicas -->
|
||||
<c2sh2rep>
|
||||
<shard>
|
||||
<internal_replication>true</internal_replication>
|
||||
<replica><host>click1</host><port>9000</port><user>default</user><password>123456</password></replica>
|
||||
<replica><host>click2</host><port>9000</port><user>default</user><password>123456</password></replica>
|
||||
</shard>
|
||||
<shard>
|
||||
<internal_replication>true</internal_replication>
|
||||
<replica><host>click3</host><port>9000</port><user>default</user><password>123456</password></replica>
|
||||
<replica><host>click4</host><port>9000</port><user>default</user><password>123456</password></replica>
|
||||
</shard>
|
||||
</c2sh2rep>
|
||||
</remote_servers>
|
||||
<zookeeper>
|
||||
<node index="1">
|
||||
<host>zookeeper</host>
|
||||
<port>2181</port>
|
||||
</node>
|
||||
</zookeeper>
|
||||
</clickhouse>
|
||||
@@ -0,0 +1,94 @@
|
||||
x-configs: &ch-default-configs
|
||||
image: clickhouse/clickhouse-server:25.1
|
||||
environment:
|
||||
TZ: "Europe/Moscow"
|
||||
ulimits:
|
||||
nproc: 65535
|
||||
nofile:
|
||||
soft: 262144
|
||||
hard: 262144
|
||||
networks:
|
||||
- ch_learning_net
|
||||
depends_on:
|
||||
- zookeeper
|
||||
|
||||
services:
|
||||
zookeeper:
|
||||
# image: 'bitnami/zookeeper:3.9.3'
|
||||
image: zookeeper:3.9.3
|
||||
networks:
|
||||
- ch_learning_net
|
||||
environment:
|
||||
- ALLOW_ANONYMOUS_LOGIN=yes
|
||||
- ZOOKEEPER_CLIENT_PORT=2181
|
||||
- TZ="Europe/Moscow"
|
||||
ports:
|
||||
- "2182:2181"
|
||||
- "2888:2888"
|
||||
- "3888:3888"
|
||||
|
||||
click1:
|
||||
<<: *ch-default-configs
|
||||
volumes:
|
||||
- ./configs/default_user.xml:/etc/clickhouse-server/users.d/default_user.xml
|
||||
- ./configs/z_config.xml:/etc/clickhouse-server/config.d/z_config.xml
|
||||
- ./configs/macros_ch1.xml:/etc/clickhouse-server/config.d/macros.xml
|
||||
- ./data:/var/lib/clickhouse/user_files/data
|
||||
ports:
|
||||
- "8002:9000"
|
||||
- "9123:8123"
|
||||
|
||||
click2:
|
||||
<<: *ch-default-configs
|
||||
volumes:
|
||||
- ./configs/default_user.xml:/etc/clickhouse-server/users.d/default_user.xml
|
||||
- ./configs/z_config.xml:/etc/clickhouse-server/config.d/z_config.xml
|
||||
- ./configs/macros_ch2.xml:/etc/clickhouse-server/config.d/macros.xml
|
||||
- ./data:/var/lib/clickhouse/user_files/data
|
||||
ports:
|
||||
- "8003:9000"
|
||||
- "9124:8123"
|
||||
|
||||
click3:
|
||||
<<: *ch-default-configs
|
||||
volumes:
|
||||
- ./configs/default_user.xml:/etc/clickhouse-server/users.d/default_user.xml
|
||||
- ./configs/z_config.xml:/etc/clickhouse-server/config.d/z_config.xml
|
||||
- ./configs/macros_ch3.xml:/etc/clickhouse-server/config.d/macros.xml
|
||||
- ./data:/var/lib/clickhouse/user_files/data
|
||||
ports:
|
||||
- "8004:9000"
|
||||
- "9125:8123"
|
||||
|
||||
click4:
|
||||
<<: *ch-default-configs
|
||||
volumes:
|
||||
- ./configs/default_user.xml:/etc/clickhouse-server/users.d/default_user.xml
|
||||
- ./configs/z_config.xml:/etc/clickhouse-server/config.d/z_config.xml
|
||||
- ./configs/macros_ch4.xml:/etc/clickhouse-server/config.d/macros.xml
|
||||
- ./data:/var/lib/clickhouse/user_files/data
|
||||
ports:
|
||||
- "8005:9000"
|
||||
- "9126:8123"
|
||||
|
||||
haproxy:
|
||||
image: haproxy:3.1.7
|
||||
networks:
|
||||
- ch_learning_net
|
||||
ports:
|
||||
- "9001:9000"
|
||||
- "8124:8123" # HTTP порт для ClickHouse c балансировкой
|
||||
volumes:
|
||||
- ./configs/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
|
||||
depends_on:
|
||||
- click1
|
||||
- click2
|
||||
- click3
|
||||
- click4
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
ch_learning_net:
|
||||
driver: bridge
|
||||
|
||||
# volumes:
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Версия ClickHouse
|
||||
SELECT version();
|
||||
|
||||
-- Созданные в системе кластера
|
||||
SHOW clusters;
|
||||
|
||||
-- Список активных репликаций
|
||||
SELECT * FROM system.zookeeper WHERE path = '/clickhouse/task_queue/replicas/';
|
||||
Reference in New Issue
Block a user