kafka Java创建生产者报错:Invalid partition given with record: 1 is not in the range [0...1)

参考:https://www.jianshu.com/p/9e72b3942c59

原因是在kafka集群kafka/config/server.properties文件中num.patitions = 1. 需要修改分区默认值。

partitions在是在创建topic的时候默认创建的partitions节点的个数,只对新创建的topic生效,所有尽量在项目规划时候定一个合理的值。也可以通过命令行动态扩容。

./bin/kafka-topics.sh --zookeeper  localhost:2181 --alter --partitions 2 --topic  test

猜你喜欢

转载自www.cnblogs.com/ryu-manager/p/9438863.html
今日推荐