io.confluent.ksql.exception.KafkaTopicExistsException:启动ksql-server-start时启动ksql-server.properties

时间:2019-04-03 12:16:52

标签: apache-kafka ksql kafka-topic

我使用ksql已经有一段时间了。 Kafka群集(如果有3个节点)。我也一直在使用udf,直到我停止服务器并重新启动它们为止,一切看起来都不错。 在服务器启动时,我在日志中看到以下内容:

[2019-04-03 11:29:54,381] ERROR Exception encountered running command: A Kafka topic with the name 'czxcorp-structured-data-enriched' already exists, with different partition/replica configuration than required. KSQL expects 4 partitions (topic has 9), and 1 replication factor (topic has 1).. Retrying in 5000 ms (io.confluent.ksql.util.RetryUtil:80)
[2019-04-03 11:29:54,381] ERROR Stack trace: io.confluent.ksql.exception.KafkaTopicExistsException: A Kafka topic with the name 'czxcorp-structured-data-enriched' already exists, with different partition/replica configuration than required. KSQL expects 4 partitions (topic has 9), and 1 replication factor (topic has 1).
        at io.confluent.ksql.services.TopicValidationUtil.validateTopicProperties(TopicValidationUtil.java:51)
        at io.confluent.ksql.services.TopicValidationUtil.validateTopicProperties(TopicValidationUtil.java:35)
        at io.confluent.ksql.services.KafkaTopicClientImpl.validateTopicProperties(KafkaTopicClientImpl.java:292)
        at io.confluent.ksql.services.KafkaTopicClientImpl.createTopic(KafkaTopicClientImpl.java:76)
        at io.confluent.ksql.planner.plan.KsqlStructuredDataOutputNode.createSinkTopic(KsqlStructuredDataOutputNode.java:244)
        at io.confluent.ksql.planner.plan.KsqlStructuredDataOutputNode.buildStream(KsqlStructuredDataOutputNode.java:146)
        at io.confluent.ksql.physical.PhysicalPlanBuilder.buildPhysicalPlan(PhysicalPlanBuilder.java:106)
        at io.confluent.ksql.QueryEngine.buildPhysicalPlan(QueryEngine.java:113)
        at io.confluent.ksql.KsqlEngine$EngineExecutor.execute(KsqlEngine.java:625)
        at io.confluent.ksql.KsqlEngine$EngineExecutor.access$800(KsqlEngine.java:577)
        at io.confluent.ksql.KsqlEngine.execute(KsqlEngine.java:247)
        at io.confluent.ksql.rest.server.computation.StatementExecutor.startQuery(StatementExecutor.java:277)
        at io.confluent.ksql.rest.server.computation.StatementExecutor.executeStatement(StatementExecutor.java:191)
        at io.confluent.ksql.rest.server.computation.StatementExecutor.handleStatementWithTerminatedQueries(StatementExecutor.java:167)
        at io.confluent.ksql.rest.server.computation.StatementExecutor.handleRestore(StatementExecutor.java:101)
        at io.confluent.ksql.rest.server.computation.CommandRunner.lambda$null$0(CommandRunner.java:139)
        at io.confluent.ksql.util.RetryUtil.retryWithBackoff(RetryUtil.java:63)
        at io.confluent.ksql.util.RetryUtil.retryWithBackoff(RetryUtil.java:36)
        at io.confluent.ksql.rest.server.computation.CommandRunner.lambda$processPriorCommands$1(CommandRunner.java:135)
        at java.util.ArrayList.forEach(ArrayList.java:1257)
        at io.confluent.ksql.rest.server.computation.CommandRunner.processPriorCommands(CommandRunner.java:134)
        at io.confluent.ksql.rest.server.KsqlRestApplication.buildApplication(KsqlRestApplication.java:414)
        at io.confluent.ksql.rest.server.KsqlServerMain.createExecutable(KsqlServerMain.java:80)
        at io.confluent.ksql.rest.server.KsqlServerMain.main(KsqlServerMain.java:42)
 (io.confluent.ksql.util.RetryUtil:84)

尽管我已经停止/终止了所有查询,但是日志会打印出从开始执行测试到数据(包括create, select, drop)的所有命令。我已从/ ext文件夹中取出.jar(UDF)并启动了服务器,尽管日志显示udf函数(我正在使用)不可用。

这是我的ksql-server.properties:

bootstrap.servers=hostname:9092
service.id=cyan_ksql
commit.interval.ms=5000
cache.max.bytes.buffering=20000000
num.stream.threads=10
fail.on.deserialization.error=false
listeners=http://localhost:8088
ksql.extension.dir=/opt/ksql-master/ext/

犯错误。我正在删除主题,并以某种方式重新创建了该主题。有人帮忙。

1 个答案:

答案 0 :(得分:1)

检查错误:

A Kafka topic with the name 'czxcorp-structured-data-enriched' already exists, with different partition/replica configuration than required. 
KSQL expects 4 partitions (topic has 9), and 1 replication factor (topic has 1)

如果您删除了该主题,则可以

  • 它实际上并没有被删除
  • 已删除它,并用其他九个分区重新创建了它,并且您出错的KSQL查询未指定对默认的四个覆盖(WITH (PARTITIONS=9
  • 另一条KSQL命令将在出错之前创建它,并且您的错误KSQL查询未指定默认值四的替代(WITH (PARTITIONS=9

如果您想弄乱状态并从头开始,只需更改您的ksql.service.id,这将使KSQL使用新的命令主题(重新启动进程时会重放该主题)