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);