我老婆逸仙 2021-04-06 16:17 采纳率: 0%
浏览 555

clickhouse分布式表查询报错There is no table

clickhouse0-0.clickhouse0.clickhouse-new.svc.cluster.local. :) select * from log_gather_devops_4a_devops_4a_logs_all

SELECT *
FROM log_gather_devops_4a_devops_4a_logs_all

0 rows in set. Elapsed: 0.005 sec. 

Received exception from server (version 21.3.4):
Code: 279. DB::Exception: Received from localhost:9000. DB::Exception: All connection tries failed. Log: 

There is no table `devops_filelog_collection`.`devops_filelog_collection.log_gather_devops_4a_devops_4a_logs` on server: clickhouse0-0.clickhouse0:9000
There is no table `devops_filelog_collection`.`devops_filelog_collection.log_gather_devops_4a_devops_4a_logs` on server: clickhouse1-1.clickhouse1:9001

报错的情况如上,我在报错里的那个server里查到了对应的表,我的使用情况是自动创建表,我把代码粘到下面,求大佬帮忙看看

建表语句,用的mybatis :

    <update id="createPhysicalTables">
        CREATE TABLE IF NOT EXISTS ${physicalTableName} on cluster ${clusterName}
        (
            createDate     Date DEFAULT toDate(now()),
            logDateTime    DateTime,
            offset         UInt64,
            logLevel       String,
            path           String,
            note           Nullable(String)
        )
        ENGINE = MergeTree()
            PARTITION BY createDate
            ORDER BY(
            createDate,
            logDateTime,
            offset,
            logLevel)
            PRIMARY KEY(
            createDate)
            SETTINGS index_granularity=8192;
    </update>

    <update id="createLogicalTables">
        CREATE TABLE IF NOT EXISTS ${logicalTableName} on cluster ${clusterName} as ${physicalTableName}
            ENGINE = Distributed(
                                    ${clusterName},
                                    ${databaseName},
                                    ${physicalTableName},
                                    rand());
    </update>

Mapper:

    void createPhysicalTables(@Param("physicalTableName") String physicalTableName, @Param("clusterName") String clusterName) throws UncategorizedSQLException;

    void createLogicalTables(@Param("physicalTableName") String physicalTableName, @Param("logicalTableName") String logicalTableName, @Param("databaseName") String databaseName, @Param("clusterName") String clusterName) throws UncategorizedSQLException;

service调用的情况:其中fileLogDatabaseName是定义好的库名,clusterName是定义好的集群名

        String physicalTableName = fileLogDatabaseName + ".log_gather_" + recordEntity.getAppTableName() + "_logs";
        clickhouseMapper.createPhysicalTables(physicalTableName, clusterName);
        clickhouseMapper.createLogicalTables(physicalTableName, physicalTableName + "_all", fileLogDatabaseName, clusterName);
  • 写回答

3条回答 默认 最新

  • 关注

    注意表名大小写,还有权限问题,如果没有同义词的话要加上用户前缀哦

    评论

报告相同问题?

悬赏问题

  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch