diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2277c80
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.$*.bkp
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..cf6dd3b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,4 @@
+Creative Commons Legal Code
+
+CC BY 4.0 licence
+https://creativecommons.org/licenses/by/4.0/
\ No newline at end of file
diff --git a/README.md b/README.md
index b70c2ec..6189877 100644
--- a/README.md
+++ b/README.md
@@ -1 +1 @@
-# dlickhouse-learning-cluster
\ No newline at end of file
+# clickhouse-learning-cluster
\ No newline at end of file
diff --git a/configs/default_user.xml b/configs/default_user.xml
new file mode 100644
index 0000000..227b387
--- /dev/null
+++ b/configs/default_user.xml
@@ -0,0 +1,7 @@
+
+
+
+ 123456
+
+
+
\ No newline at end of file
diff --git a/configs/haproxy/haproxy.cfg b/configs/haproxy/haproxy.cfg
new file mode 100644
index 0000000..fac512d
--- /dev/null
+++ b/configs/haproxy/haproxy.cfg
@@ -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
diff --git a/configs/macros_ch1.xml b/configs/macros_ch1.xml
new file mode 100644
index 0000000..a7508be
--- /dev/null
+++ b/configs/macros_ch1.xml
@@ -0,0 +1,10 @@
+
+
+ 01
+ 01
+ 01
+ rep1
+ rep1
+ rep1
+
+
\ No newline at end of file
diff --git a/configs/macros_ch2.xml b/configs/macros_ch2.xml
new file mode 100644
index 0000000..31a2ac3
--- /dev/null
+++ b/configs/macros_ch2.xml
@@ -0,0 +1,10 @@
+
+
+ 01
+ 01
+ 02
+ rep2
+ rep2
+ rep1
+
+
\ No newline at end of file
diff --git a/configs/macros_ch3.xml b/configs/macros_ch3.xml
new file mode 100644
index 0000000..6c82936
--- /dev/null
+++ b/configs/macros_ch3.xml
@@ -0,0 +1,10 @@
+
+
+ 01
+ 02
+ 03
+ rep3
+ rep1
+ rep1
+
+
\ No newline at end of file
diff --git a/configs/macros_ch4.xml b/configs/macros_ch4.xml
new file mode 100644
index 0000000..dcc788e
--- /dev/null
+++ b/configs/macros_ch4.xml
@@ -0,0 +1,10 @@
+
+
+ 01
+ 02
+ 04
+ rep4
+ rep2
+ rep1
+
+
\ No newline at end of file
diff --git a/configs/z_config.xml b/configs/z_config.xml
new file mode 100644
index 0000000..a280488
--- /dev/null
+++ b/configs/z_config.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+ true
+ click19000default123456
+ click29000default123456
+ click39000default123456
+ click49000default123456
+
+
+
+
+
+ click19000default123456
+
+
+ click29000default123456
+
+
+ click39000default123456
+
+
+ click49000default123456
+
+
+
+
+
+ true
+ click19000default123456
+ click29000default123456
+
+
+ true
+ click39000default123456
+ click49000default123456
+
+
+
+
+
+ zookeeper
+ 2181
+
+
+
\ No newline at end of file
diff --git a/data/.gitkeep b/data/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..4a4c96a
--- /dev/null
+++ b/docker-compose.yml
@@ -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:
diff --git a/sql/sample_queries.sql b/sql/sample_queries.sql
new file mode 100644
index 0000000..dff95a8
--- /dev/null
+++ b/sql/sample_queries.sql
@@ -0,0 +1,8 @@
+-- Версия ClickHouse
+SELECT version();
+
+-- Созданные в системе кластера
+SHOW clusters;
+
+-- Список активных репликаций
+SELECT * FROM system.zookeeper WHERE path = '/clickhouse/task_queue/replicas/';