我执行shell脚本kafka-topics.sh将分区数从3更改为10。
./bin/kafka-topics.sh --zookeeper xxx.xx.xxx.xx:2181/my-broker-0 --alter --topic target-topic-example-1 --partitions 10
执行该命令后,Kafka群集立即发生错误。
[2018-11-20 14:45:29,954] INFO Created log for partition [target-topic-example-1,5] in /data/kafka/brokers with properties {flush.messages -> 9223372036854775807, message.timestamp.type -> CreateTime, segment.bytes -> 536870912, preallocate -> false, cleanup.policy -> [delete], delete.retention.ms -> 86400000, segment.ms -> 604800000, min.insync.replicas -> 1, file.delete.delay.ms -> 60000, retention.ms -> 259200000, max.message.bytes -> 10000000, message.format.version -> 0.10.1-IV2, index.interval.bytes -> 4096, segment.index.bytes -> 10485760, retention.bytes -> -1, segment.jitter.ms -> 0, min.cleanable.dirty.ratio -> 0.5, compression.type -> producer, unclean.leader.election.enable -> true, message.timestamp.difference.max.ms -> 9223372036854775807, min.compaction.lag.ms -> 0, flush.ms -> 9223372036854775807}. (kafka.log.LogManager)
[2018-11-20 14:45:29,955] INFO Partition [target-topic-example-1,5] on broker 8: No checkpointed highwatermark is found for partition [target-topic-example-1,5] (kafka.cluster.Partition)
[2018-11-20 14:45:29,957] INFO Completed load of log target-topic-example-1-4 with 1 log segments and log end offset 0 in 1 ms (kafka.log.Log)
[2018-11-20 14:45:29,957] INFO Created log for partition [target-topic-example-1,4] in /data/kafka/brokers with properties {flush.messages -> 9223372036854775807, message.timestamp.type -> CreateTime, segment.bytes -> 536870912, preallocate -> false, cleanup.policy -> [delete], delete.retention.ms -> 86400000, segment.ms -> 604800000, min.insync.replicas -> 1, file.delete.delay.ms -> 60000, retention.ms -> 259200000, max.message.bytes -> 10000000, message.format.version -> 0.10.1-IV2, index.interval.bytes -> 4096, segment.index.bytes -> 10485760, retention.bytes -> -1, segment.jitter.ms -> 0, min.cleanable.dirty.ratio -> 0.5, compression.type -> producer, unclean.leader.election.enable -> true, message.timestamp.difference.max.ms -> 9223372036854775807, min.compaction.lag.ms -> 0, flush.ms -> 9223372036854775807}. (kafka.log.LogManager)
[2018-11-20 14:45:29,958] INFO Partition [target-topic-example-1,4] on broker 8: No checkpointed highwatermark is found for partition [target-topic-example-1,4] (kafka.cluster.Partition)
[2018-11-20 14:45:29,958] INFO [ReplicaFetcherManager on broker 8] Removed fetcher for partitions target-topic-example-1-5,target-topic-example-1-4 (kafka.server.ReplicaFetcherManager)
[2018-11-20 14:45:29,958] INFO Truncating log target-topic-example-1-5 to offset 0. (kafka.log.Log)
[2018-11-20 14:45:29,958] INFO Truncating log target-topic-example-1-4 to offset 0. (kafka.log.Log)
[2018-11-20 14:45:29,961] INFO [ReplicaFetcherManager on broker 8] Added fetcher for partitions List([target-topic-example-1-5, initOffset 0 to broker BrokerEndPoint(1,My-broker02-172.cm.skp,9092)] , [target-topic-example-1-4, initOffset 0 to broker BrokerEndPoint(0,My- broker01-172.cm.skp,9092)] ) (kafka.server.ReplicaFetcherManager)
[2018-11-20 14:45:30,062] ERROR [ReplicaFetcherThread-0-1], Error for partition [other-topic-1,3] to broker 1:org.apache.kafka.common.errors.UnknownServerException: The server experienced an unexpected error when processing the request (kafka.server.ReplicaFetcherThread)
[2018-11-20 14:45:30,070] ERROR [ReplicaFetcherThread-0-1], Error for partition [other-topic-2,0] to broker 1:org.apache.kafka.common.errors.UnknownServerException: The server experienced an unexpected error when processing the request (kafka.server.ReplicaFetcherThread)
[2018-11-20 14:45:30,070] ERROR [ReplicaFetcherThread-0-1], Error for partition [other-topic-3,3] to broker 1:org.apache.kafka.common.errors.UnknownServerException: The server experienced an unexpected error when processing the request (kafka.server.ReplicaFetcherThread)
[2018-11-20 14:45:30,070] ERROR [ReplicaFetcherThread-0-1], Error for partition [other-topic-4,0] to broker 1:org.apache.kafka.common.errors.UnknownServerException: The server experienced an unexpected error when processing the request (kafka.server.ReplicaFetcherThread)
我的更改分区数的命令效果很好。 但是,我不知道上面的错误是什么样的。
(作为参考,总共有10个经纪人和500多个主题。)
答案 0 :(得分:0)
仅更改分区数还不够,您需要重新平衡集群。仅当消费者被告知这些新分区时,新分区才处于活动状态。
有关添加分区的过程,请参阅我的回答:https://stackoverflow.com/a/58293572/8702415
我还建议进行首选的副本选举。 ./bin/kafka-preferred-replica-election.sh --zookeeper localhost:9092