集群环境下,在任意一个节点创建数据库,如果加上了ON CLUSTER clustername,则在集群环境的所有节点上都创建了该数据库,并在集群环境的所有节点上都创建了该数据库对应的目录,且数据库的metadata_path对应的目录路径在所有节点都是一致的
集群环境下,在任意一个节点创建数据库,如果不加ON CLUSTER clustername,则只在当前节点建立了这个数据库,其他节点没有自动建立,需要在其他节点也执行创建一遍,且数据库的metadata_path对应的目录在各个节点各不相同
CREATE DATABASE lukestest1 ON CLUSTER cluster_2shared2replicas;
CREATE DATABASE lukestest2;
集群环境下,在任意一个节点删除数据库,如果加上了ON CLUSTER clustername,则在集群环境的所有节点上都删除了该数据库,并在集群环境的所有节点上都删除了数据库对应的目录
集群环境下,在任意一个节点删除数据库,如果不加ON CLUSTER clustername,则只在当前节点删除了该数据库,也只在当前节点删除了该数据库对应的目录,其他节点不受影响
drop database lukestest1 ON CLUSTER cluster_2shared2replicas;
drop database testlukes202306;
在节点1上创建数据库加ON CLUSTER cluster_2shared2replicas的输出结果
sql
DAILACHDBUD001 :) CREATE DATABASE lukestest1 ON CLUSTER cluster_2shared2replicas;
CREATE DATABASE lukestest1 ON CLUSTER cluster_2shared2replicas
Query id: 54163214-009c-4362-9b51-d5e61f9c1767
┌─host───────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ DAILACHDBUD001 │ 9000 │ 0 │ │ 3 │ 0 │
│ DAILACHDBUD004 │ 9000 │ 0 │ │ 2 │ 0 │
└────────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
┌─host───────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ DAILACHDBUD003 │ 9000 │ 0 │ │ 1 │ 1 │
└────────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
┌─host───────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ DAILACHDBUD002 │ 9000 │ 0 │ │ 0 │ 0 │
└────────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
4 rows in set. Elapsed: 0.927 sec.
在节点1上创建数据库不加ON CLUSTER cluster_2shared2replicas的输出结果
sql
DAILACHDBUD001 :) CREATE DATABASE lukestest2;
CREATE DATABASE lukestest2
Query id: 670adde2-f104-443e-bba9-42dca3fbbdd1
Ok.
0 rows in set. Elapsed: 0.009 sec.
在四个节点上查询新建的数据库路径
备注:发现使用ON CLUSTER关键字在所有节点上同时创建的数据库,数据库的metadata_path在所有节点都是一致的;每个节点上单独创建的数据库,数据库的metadata_path在各个节点各不相同
sql
DAILACHDBUD001 :) select name,engine,data_path,metadata_path from system.databases;
┌─name───────────────┬─engine─┬─data_path──────────────────────┬─metadata_path───────────────────────────────────────────────────────────┐
│ INFORMATION_SCHEMA │ Memory │ /chdata/clickhouse/data/ │ │
│ default │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/9a9/9a92deeb-da20-4395-9200-3ede0acb203a/ │
│ information_schema │ Memory │ /chdata/clickhouse/data/ │ │
│ lukestest1 │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/ │
│ lukestest2 │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/0df/0dff644a-40ac-4138-8c0d-1b7f0c382454/ │
│ sentry │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/24a/24a5aa06-54b5-4606-8c27-5e3adfd11049/ │
│ system │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/ccd/ccda574b-2524-4045-91ae-5c4490452d50/ │
│ testlukes202306 │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/6b4/6b439484-c011-48f9-8d05-339ea2cd7961/ │
└────────────────────┴────────┴────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
root@DAILACHDBUD001:~# ll /chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/
total 140
drwxr-x--- 2 clickhouse clickhouse 4096 Oct 26 08:44 ./
drwxr-x--- 3 clickhouse clickhouse 50 Oct 23 02:56 ../
-rw-r----- 1 clickhouse clickhouse 172 Oct 26 08:37 %2Einner_id%2E3150ecef%2D55fb%2D41c9%2Da8c1%2D7f9028b344ab.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 26 08:38 %2Einner_id%2E409529be%2Dadf3%2D40c2%2Dad9c%2Dacd4b88f069d.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 26 08:44 %2Einner_id%2E8260d608%2Dfb5e%2D4252%2Da3ed%2De205626288d1.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 26 08:44 %2Einner_id%2E95151d8d%2D0b0a%2D4671%2D9fe6%2D49e3429f8452.sql
-rw-r----- 1 clickhouse clickhouse 198 Oct 25 10:18 table_distributed1.sql
-rw-r----- 1 clickhouse clickhouse 198 Oct 26 03:46 table_Distributed_mergetree3.sql
-rw-r----- 1 clickhouse clickhouse 197 Oct 24 09:49 table_Distributed_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 208 Oct 26 02:47 table_Distributed_ReplicatedMergeTree2.sql
-rw-r----- 1 clickhouse clickhouse 208 Oct 26 03:23 table_Distributed_ReplicatedMergeTree3.sql
-rw-r----- 1 clickhouse clickhouse 207 Oct 24 09:50 table_Distributed_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 26 06:25 table_mergetest12.sql
-rw-r----- 1 clickhouse clickhouse 157 Oct 26 06:28 table_mergetest1_Merge.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 26 06:24 table_mergetest1.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 26 06:26 table_mergetest23.sql
-rw-r----- 1 clickhouse clickhouse 302 Oct 26 08:44 table_mergetest2_materialized1.sql
-rw-r----- 1 clickhouse clickhouse 302 Oct 26 08:44 table_mergetest2_materialized_nopopulate1.sql
-rw-r----- 1 clickhouse clickhouse 302 Oct 26 08:38 table_mergetest2_materialized_nopopulate.sql
-rw-r----- 1 clickhouse clickhouse 302 Oct 26 08:37 table_mergetest2_materialized.sql
-rw-r----- 1 clickhouse clickhouse 157 Oct 26 06:28 table_mergetest2_Merge.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 26 08:35 table_mergetest2.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 25 05:42 tableMergeTree1.sql
-rw-r----- 1 clickhouse clickhouse 192 Oct 25 05:57 tableMergeTree1_view2.sql
-rw-r----- 1 clickhouse clickhouse 192 Oct 25 05:57 tableMergeTree1_view3.sql
-rw-r----- 1 clickhouse clickhouse 197 Oct 25 05:57 tableMergeTree1_view_round.sql
-rw-r----- 1 clickhouse clickhouse 189 Oct 25 05:43 tableMergeTree1_view.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 26 03:46 table_mergetree3.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 23 08:02 table_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 278 Oct 24 04:14 table_ReplicatedAggregatingMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 25 06:18 table_ReplicatedMergeTree1.sql
-rw-r----- 1 clickhouse clickhouse 208 Oct 25 06:25 table_ReplicatedMergeTree1_view.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 02:47 table_ReplicatedMergeTree2.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 03:22 table_ReplicatedMergeTree3.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 23 10:24 table_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 276 Oct 24 04:10 table_ReplicatedReplacingMergeTree.sql
root@DAILACHDBUD001:~# ll /chdata/clickhouse/data/store/0df/0dff644a-40ac-4138-8c0d-1b7f0c382454/
total 24
drwxr-x--- 2 clickhouse clickhouse 252 Oct 24 09:51 ./
drwxr-x--- 3 clickhouse clickhouse 50 Oct 23 02:56 ../
-rw-r----- 1 clickhouse clickhouse 197 Oct 24 09:51 table_Distributed_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 207 Oct 24 09:51 table_Distributed_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 23 08:04 table_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 278 Oct 24 04:14 table_ReplicatedAggregatingMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 23 10:25 table_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 276 Oct 24 04:11 table_ReplicatedReplacingMergeTree.sql
DAILACHDBUD002 :) select name,engine,data_path,metadata_path from system.databases;
┌─name───────────────┬─engine─┬─data_path──────────────────────┬─metadata_path───────────────────────────────────────────────────────────┐
│ INFORMATION_SCHEMA │ Memory │ /chdata/clickhouse/data/ │ │
│ default │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/d35/d35e18e6-f03d-41f9-8cc0-537be187ad21/ │
│ information_schema │ Memory │ /chdata/clickhouse/data/ │ │
│ lukestest1 │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/ │
│ lukestest2 │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/ec4/ec480a66-3d57-4ee9-a194-74fa7b7bb705/ │
│ sentry │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/24a/24a5aa06-54b5-4606-8c27-5e3adfd11049/ │
│ system │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/af6/af67a94d-23e8-4a24-9d8f-97e4a8ec8e63/ │
│ testlukes202306 │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/6b4/6b439484-c011-48f9-8d05-339ea2cd7961/ │
└────────────────────┴────────┴────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
root@DAILACHDBUD002:~# ll /chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/
total 84
drwxr-x--- 2 clickhouse clickhouse 4096 Oct 27 05:50 ./
drwxr-x--- 3 clickhouse clickhouse 50 Oct 23 02:56 ../
-rw-r----- 1 clickhouse clickhouse 198 Oct 25 10:18 table_distributed1.sql
-rw-r----- 1 clickhouse clickhouse 198 Oct 26 03:46 table_Distributed_mergetree3.sql
-rw-r----- 1 clickhouse clickhouse 197 Oct 24 09:49 table_Distributed_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 208 Oct 26 02:47 table_Distributed_ReplicatedMergeTree2.sql
-rw-r----- 1 clickhouse clickhouse 208 Oct 26 03:23 table_Distributed_ReplicatedMergeTree3.sql
-rw-r----- 1 clickhouse clickhouse 207 Oct 24 09:50 table_Distributed_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 25 05:42 tableMergeTree1.sql
-rw-r----- 1 clickhouse clickhouse 192 Oct 25 05:57 tableMergeTree1_view2.sql
-rw-r----- 1 clickhouse clickhouse 192 Oct 25 05:57 tableMergeTree1_view3.sql
-rw-r----- 1 clickhouse clickhouse 197 Oct 25 05:57 tableMergeTree1_view_round.sql
-rw-r----- 1 clickhouse clickhouse 189 Oct 25 05:43 tableMergeTree1_view.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 26 03:46 table_mergetree3.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 23 08:02 table_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 278 Oct 24 04:14 table_ReplicatedAggregatingMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 25 06:18 table_ReplicatedMergeTree1.sql
-rw-r----- 1 clickhouse clickhouse 208 Oct 25 06:25 table_ReplicatedMergeTree1_view.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 02:47 table_ReplicatedMergeTree2.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 03:22 table_ReplicatedMergeTree3.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 23 10:24 table_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 276 Oct 24 04:10 table_ReplicatedReplacingMergeTree.sql
root@DAILACHDBUD002:~# ll /chdata/clickhouse/data/store/ec4/ec480a66-3d57-4ee9-a194-74fa7b7bb705/
total 24
drwxr-x--- 2 clickhouse clickhouse 252 Oct 24 09:51 ./
drwxr-x--- 3 clickhouse clickhouse 50 Oct 23 05:53 ../
-rw-r----- 1 clickhouse clickhouse 197 Oct 24 09:51 table_Distributed_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 207 Oct 24 09:51 table_Distributed_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 23 08:04 table_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 278 Oct 24 04:14 table_ReplicatedAggregatingMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 23 10:25 table_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 276 Oct 24 04:11 table_ReplicatedReplacingMergeTree.sql
DAILACHDBUD003 :) select name,engine,data_path,metadata_path from system.databases;
┌─name───────────────┬─engine─┬─data_path──────────────────────┬─metadata_path───────────────────────────────────────────────────────────┐
│ INFORMATION_SCHEMA │ Memory │ /chdata/clickhouse/data/ │ │
│ default │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/fb8/fb81d157-e9cc-43f1-9eeb-61c52011363d/ │
│ information_schema │ Memory │ /chdata/clickhouse/data/ │ │
│ lukestest1 │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/ │
│ lukestest2 │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/b26/b26b894a-44a7-470e-b860-6524655b0cbc/ │
│ sentry │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/24a/24a5aa06-54b5-4606-8c27-5e3adfd11049/ │
│ system │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/f51/f5122fb5-b2c4-4a1b-bb16-1e5383aa7c6a/ │
│ testlukes202306 │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/6b4/6b439484-c011-48f9-8d05-339ea2cd7961/ │
└────────────────────┴────────┴────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
root@DAILACHDBUD003:~# ll /chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/
total 84
drwxr-x--- 2 clickhouse clickhouse 4096 Oct 26 06:23 ./
drwxr-x--- 3 clickhouse clickhouse 50 Oct 23 02:56 ../
-rw-r----- 1 clickhouse clickhouse 198 Oct 25 10:18 table_distributed1.sql
-rw-r----- 1 clickhouse clickhouse 198 Oct 26 03:46 table_Distributed_mergetree3.sql
-rw-r----- 1 clickhouse clickhouse 197 Oct 24 09:49 table_Distributed_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 208 Oct 26 02:47 table_Distributed_ReplicatedMergeTree2.sql
-rw-r----- 1 clickhouse clickhouse 208 Oct 26 03:23 table_Distributed_ReplicatedMergeTree3.sql
-rw-r----- 1 clickhouse clickhouse 207 Oct 24 09:50 table_Distributed_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 25 05:42 tableMergeTree1.sql
-rw-r----- 1 clickhouse clickhouse 192 Oct 25 05:57 tableMergeTree1_view2.sql
-rw-r----- 1 clickhouse clickhouse 192 Oct 25 05:57 tableMergeTree1_view3.sql
-rw-r----- 1 clickhouse clickhouse 197 Oct 25 05:57 tableMergeTree1_view_round.sql
-rw-r----- 1 clickhouse clickhouse 189 Oct 25 05:43 tableMergeTree1_view.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 26 03:46 table_mergetree3.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 23 08:02 table_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 278 Oct 24 04:14 table_ReplicatedAggregatingMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 25 06:18 table_ReplicatedMergeTree1.sql
-rw-r----- 1 clickhouse clickhouse 208 Oct 25 06:25 table_ReplicatedMergeTree1_view.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 02:47 table_ReplicatedMergeTree2.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 03:22 table_ReplicatedMergeTree3.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 23 10:24 table_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 276 Oct 24 04:10 table_ReplicatedReplacingMergeTree.sql
root@DAILACHDBUD003:~# ll /chdata/clickhouse/data/store/b26/b26b894a-44a7-470e-b860-6524655b0cbc/
total 24
drwxr-x--- 2 clickhouse clickhouse 252 Oct 24 09:51 ./
drwxr-x--- 3 clickhouse clickhouse 50 Oct 23 05:56 ../
-rw-r----- 1 clickhouse clickhouse 197 Oct 24 09:51 table_Distributed_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 207 Oct 24 09:51 table_Distributed_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 23 08:04 table_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 278 Oct 24 04:14 table_ReplicatedAggregatingMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 23 10:25 table_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 276 Oct 24 04:11 table_ReplicatedReplacingMergeTree.sql
DAILACHDBUD004 :) select name,engine,data_path,metadata_path from system.databases;
┌─name───────────────┬─engine─┬─data_path──────────────────────┬─metadata_path───────────────────────────────────────────────────────────┐
│ INFORMATION_SCHEMA │ Memory │ /chdata/clickhouse/data/ │ │
│ default │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/f91/f91dcc2d-e6f6-4948-a4a6-356cb74339ec/ │
│ information_schema │ Memory │ /chdata/clickhouse/data/ │ │
│ lukestest1 │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/ │
│ lukestest2 │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/d5c/d5c04c61-2e1f-4624-801d-b121f2f50365/ │
│ sentry │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/24a/24a5aa06-54b5-4606-8c27-5e3adfd11049/ │
│ system │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/bdc/bdc336ca-96d2-4103-ab01-6a209278ccd2/ │
│ testlukes202306 │ Atomic │ /chdata/clickhouse/data/store/ │ /chdata/clickhouse/data/store/6b4/6b439484-c011-48f9-8d05-339ea2cd7961/ │
└────────────────────┴────────┴────────────────────────────────┴─────────────────────────────────────────────────────────────────────────┘
root@DAILACHDBUD004:~# ll /chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/
total 84
drwxr-x--- 2 clickhouse clickhouse 4096 Oct 26 06:23 ./
drwxr-x--- 3 clickhouse clickhouse 50 Oct 23 02:56 ../
-rw-r----- 1 clickhouse clickhouse 198 Oct 25 10:18 table_distributed1.sql
-rw-r----- 1 clickhouse clickhouse 198 Oct 26 03:46 table_Distributed_mergetree3.sql
-rw-r----- 1 clickhouse clickhouse 197 Oct 24 09:49 table_Distributed_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 208 Oct 26 02:47 table_Distributed_ReplicatedMergeTree2.sql
-rw-r----- 1 clickhouse clickhouse 208 Oct 26 03:23 table_Distributed_ReplicatedMergeTree3.sql
-rw-r----- 1 clickhouse clickhouse 207 Oct 24 09:50 table_Distributed_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 25 05:42 tableMergeTree1.sql
-rw-r----- 1 clickhouse clickhouse 192 Oct 25 05:57 tableMergeTree1_view2.sql
-rw-r----- 1 clickhouse clickhouse 192 Oct 25 05:57 tableMergeTree1_view3.sql
-rw-r----- 1 clickhouse clickhouse 197 Oct 25 05:57 tableMergeTree1_view_round.sql
-rw-r----- 1 clickhouse clickhouse 189 Oct 25 05:43 tableMergeTree1_view.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 26 03:46 table_mergetree3.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 23 08:02 table_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 278 Oct 24 04:14 table_ReplicatedAggregatingMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 25 06:18 table_ReplicatedMergeTree1.sql
-rw-r----- 1 clickhouse clickhouse 208 Oct 25 06:25 table_ReplicatedMergeTree1_view.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 02:47 table_ReplicatedMergeTree2.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 03:22 table_ReplicatedMergeTree3.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 23 10:24 table_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 276 Oct 24 04:10 table_ReplicatedReplacingMergeTree.sql
root@DAILACHDBUD004:~# ll /chdata/clickhouse/data/store/d5c/d5c04c61-2e1f-4624-801d-b121f2f50365/
total 24
drwxr-x--- 2 clickhouse clickhouse 252 Oct 24 09:51 ./
drwxr-x--- 3 clickhouse clickhouse 50 Oct 23 05:57 ../
-rw-r----- 1 clickhouse clickhouse 197 Oct 24 09:51 table_Distributed_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 207 Oct 24 09:51 table_Distributed_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 172 Oct 23 08:04 table_mergetree.sql
-rw-r----- 1 clickhouse clickhouse 278 Oct 24 04:14 table_ReplicatedAggregatingMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 23 10:25 table_ReplicatedMergeTree.sql
-rw-r----- 1 clickhouse clickhouse 276 Oct 24 04:11 table_ReplicatedReplacingMergeTree.sql
删除数据库,可以直接delete on cluster在四个节点上一起删除,四个节点的数据库都删除后,数据库对应的目录也在四个节点上被删除了
sql
DAILACHDBUD001 :) drop database lukestest1 ON CLUSTER cluster_2shared2replicas;
Query id: 914d41e0-3bac-4d75-a068-0d19783a3a2b
┌─host───────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ DAILACHDBUD001 │ 9000 │ 0 │ │ 3 │ 1 │
│ DAILACHDBUD002 │ 9000 │ 0 │ │ 2 │ 1 │
│ DAILACHDBUD004 │ 9000 │ 0 │ │ 1 │ 1 │
└────────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
┌─host───────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ DAILACHDBUD003 │ 9000 │ 0 │ │ 0 │ 0 │
└────────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
4 rows in set. Elapsed: 0.418 sec.
DAILACHDBUD001 :) drop database lukestest2 ON CLUSTER cluster_2shared2replicas;
Query id: a5f2409a-c30b-44a2-9bfa-6bd322deddeb
┌─host───────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ DAILACHDBUD001 │ 9000 │ 0 │ │ 3 │ 1 │
│ DAILACHDBUD004 │ 9000 │ 0 │ │ 2 │ 1 │
│ DAILACHDBUD002 │ 9000 │ 0 │ │ 1 │ 1 │
└────────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
┌─host───────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ DAILACHDBUD003 │ 9000 │ 0 │ │ 0 │ 0 │
└────────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
4 rows in set. Elapsed: 0.270 sec
删除数据库后,对应的目录也被删除了
sql
root@DAILACHDBUD001:~# ll /chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/
ls: cannot access '/chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/': No such file or directory
root@DAILACHDBUD001:~#
root@DAILACHDBUD001:~# ll /chdata/clickhouse/data/store/0df/0dff644a-40ac-4138-8c0d-1b7f0c382454/
ls: cannot access '/chdata/clickhouse/data/store/0df/0dff644a-40ac-4138-8c0d-1b7f0c382454/': No such file or directory
root@DAILACHDBUD002:~# ll /chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/
ls: cannot access '/chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/': No such file or directory
root@DAILACHDBUD002:~#
root@DAILACHDBUD002:~# ll /chdata/clickhouse/data/store/ec4/ec480a66-3d57-4ee9-a194-74fa7b7bb705/
ls: cannot access '/chdata/clickhouse/data/store/ec4/ec480a66-3d57-4ee9-a194-74fa7b7bb705/': No such file or directory
root@DAILACHDBUD003:~# ll /chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/
ls: cannot access '/chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/': No such file or directory
root@DAILACHDBUD003:~#
root@DAILACHDBUD003:~# ll /chdata/clickhouse/data/store/b26/b26b894a-44a7-470e-b860-6524655b0cbc/
ls: cannot access '/chdata/clickhouse/data/store/b26/b26b894a-44a7-470e-b860-6524655b0cbc/': No such file or directory
root@DAILACHDBUD004:~# ll /chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/
ls: cannot access '/chdata/clickhouse/data/store/91a/91aa06cd-96c3-4586-af6f-4e6587d7b368/': No such file or directory
root@DAILACHDBUD004:~#
root@DAILACHDBUD004:~# ll /chdata/clickhouse/data/store/d5c/d5c04c61-2e1f-4624-801d-b121f2f50365/
ls: cannot access '/chdata/clickhouse/data/store/d5c/d5c04c61-2e1f-4624-801d-b121f2f50365/': No such file or directory
只在节点1上删除testlukes202306不加on cluster,则只是删除了节点1上的该数据库并删除节点1该数据库对应的目录,其他节点不受影响
sql
DAILACHDBUD001 :) show databases;
┌─name───────────────┐
│ INFORMATION_SCHEMA │
│ default │
│ information_schema │
│ sentry │
│ system │
│ testlukes202306 │
└────────────────────┘
DAILACHDBUD001 :) drop database testlukes202306;
DROP DATABASE testlukes202306
Query id: 05800077-7194-409e-aa49-38ffaa045542
Ok.
0 rows in set. Elapsed: 0.015 sec.
DAILACHDBUD001 :) show databases;
┌─name───────────────┐
│ INFORMATION_SCHEMA │
│ default │
│ information_schema │
│ sentry │
│ system │
└────────────────────┘
root@DAILACHDBUD001:~# ll /chdata/clickhouse/data/store/6b4/6b439484-c011-48f9-8d05-339ea2cd7961/
ls: cannot access '/chdata/clickhouse/data/store/6b4/6b439484-c011-48f9-8d05-339ea2cd7961/': No such file or directory
DAILACHDBUD002 :) show databases;
┌─name───────────────┐
│ INFORMATION_SCHEMA │
│ default │
│ information_schema │
│ sentry │
│ system │
│ testlukes202306 │
└────────────────────┘
root@DAILACHDBUD002:~# ll /chdata/clickhouse/data/store/6b4/6b439484-c011-48f9-8d05-339ea2cd7961/
total 20
drwxr-x--- 2 clickhouse clickhouse 104 Oct 26 05:26 ./
drwxr-x--- 3 clickhouse clickhouse 50 Oct 26 05:21 ../
-rw-r----- 1 clickhouse clickhouse 193 Oct 26 05:22 table4_all.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 05:21 table4.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 05:24 table5.sql
-rw-r----- 1 clickhouse clickhouse 193 Oct 26 05:26 table6_all.sql
-rw-r----- 1 clickhouse clickhouse 207 Oct 26 05:25 table6.sql
DAILACHDBUD003 :) show databases;
┌─name───────────────┐
│ INFORMATION_SCHEMA │
│ default │
│ information_schema │
│ sentry │
│ system │
│ testlukes202306 │
└────────────────────┘
root@DAILACHDBUD003:~# ll /chdata/clickhouse/data/store/6b4/6b439484-c011-48f9-8d05-339ea2cd7961/
total 20
drwxr-x--- 2 clickhouse clickhouse 104 Oct 26 05:26 ./
drwxr-x--- 3 clickhouse clickhouse 50 Oct 26 05:21 ../
-rw-r----- 1 clickhouse clickhouse 193 Oct 26 05:22 table4_all.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 05:21 table4.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 05:24 table5.sql
-rw-r----- 1 clickhouse clickhouse 193 Oct 26 05:26 table6_all.sql
-rw-r----- 1 clickhouse clickhouse 207 Oct 26 05:25 table6.sql
DAILACHDBUD004 :) show databases;
┌─name───────────────┐
│ INFORMATION_SCHEMA │
│ default │
│ information_schema │
│ sentry │
│ system │
│ testlukes202306 │
└────────────────────┘
root@DAILACHDBUD004:~# ll /chdata/clickhouse/data/store/6b4/6b439484-c011-48f9-8d05-339ea2cd7961/
total 20
drwxr-x--- 2 clickhouse clickhouse 104 Oct 26 05:26 ./
drwxr-x--- 3 clickhouse clickhouse 50 Oct 26 05:21 ../
-rw-r----- 1 clickhouse clickhouse 193 Oct 26 05:22 table4_all.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 05:21 table4.sql
-rw-r----- 1 clickhouse clickhouse 267 Oct 26 05:24 table5.sql
-rw-r----- 1 clickhouse clickhouse 193 Oct 26 05:26 table6_all.sql
-rw-r----- 1 clickhouse clickhouse 207 Oct 26 05:25 table6.sql