我有单个 kafka 代理,并且正在使用 kafka-node 在 nodeJS 中实现 kafka。我想创建一个包含 3 个分区的主题。这样做时,出现的问题是只有第一个分区正在分配领导者,而其他两个分区没有获得领导者。我想为所有分区分配领导者。谁能告诉我我该怎么做?提前致谢。
var client = new kafka.KafkaClient();
var topic = 't-26';
var topicsToCreate = [
{
topic: topic,
partitions: 3,
Leader: 0,
replicationFactor: 1,
replicaAssignment: [
{
partition: 0,
replicas: [0]
},
{
partition: 1,
replicas: [1]
},
{
partition: 2,
replicas: [2]
}
]
},
];
client.createTopics(topicsToCreate, (error, result) => {
console.log(result);
});
主题创建如下 -
Topic: t-26 PartitionCount: 3 ReplicationFactor: 1 Configs:
Topic: t-26 Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: t-26 Partition: 1 Leader: none Replicas: 1 Isr:
Topic: t-26 Partition: 2 Leader: none Replicas: 2 Isr: