ClickHouse关于show create table

 

ClickHouse关于show create table

 

ck中当你执行show create table查看表元数据的时候,实际上来源是<clickhouse-path>/metadata/<databaseName>/<table_name>.sql

当我把该文件mv掉的时候:

[root@dev-app76 default]# pwd
/clickhouse/metadata/default
[root@dev-app76 default]# mv zkm_local.sql zkm_local.sql.bak

这个时候去执行show create table就会报错:

CK01 :) show create table zkm_local;

SHOW CREATE TABLE zkm_local

Query id: 4b04085c-1ff2-4f2d-a911-60c42d80aab3


0 rows in set. Elapsed: 0.002 sec. 

Received exception from server (version 22.3.2):
Code: 107. DB::Exception: Received from localhost:9000. DB::Exception: Cannot open file /clickhouse/store/89e/89eaf2c9-e58b-47ca-a53a-f141c0a7add7/zkm_local.sql, errno: 2, strerror: No such file or directory. (FILE_DOESNT_EXIST)

/clickhouse/store/89e/89eaf2c9-e58b-47ca-a53a-f141c0a7add7/zkm_local.sql实际就是/clickhouse/metadata/default/zkm_local.sql

ck中对metadata目录做了软链接而已:

[root@dev-app76 metadata]# ll default
lrwxrwxrwx 1 clickhouse clickhouse 59 Aug 15 17:23 default -> /clickhouse/store/89e/89eaf2c9-e58b-47ca-a53a-f141c0a7add7/

 

再次还原回去即可。

某些特殊场景有用,比如ReplicatedMergeTree类型的表的分布式DDL执行出问题,导致某些节点的这个sql文件表元数据和表在zk的信息出现问题,可以修改保持一致找回数据赶紧备份出来。

没遇到过可能有点抽象。。

 

posted @ 2023-01-11 16:21  PiscesCanon  阅读(513)  评论(0编辑  收藏  举报