kafka集群扩容

前提:

我们已经搭建好了一个kafka集群:

zookeeper:

192.168.233.128:2128

192.168.233.129:2128

192.168.233.130:2128

192.168.233.131:2128

kafka broker:

192.168.233.128:9092

192.168.233.129:9092

192.168.233.130:9092

192.168.233.131:9092

已经创建了一个 topic:quickstart76-events
$ /data/kafka_2.13-3.0.0/bin/kafka-topics.sh --bootstrap-server 192.168.233.132:9092 --topic quickstart76-events --describe
Topic: quickstart76-events	TopicId: RTYJMgt-SbSPERLyUkAI6Q	PartitionCount: 6	ReplicationFactor: 2	Configs: segment.bytes=1073741824
	Topic: quickstart76-events	Partition: 0	Leader: 3	Replicas: 3,2	Isr: 3,2
	Topic: quickstart76-events	Partition: 1	Leader: 1	Replicas: 1,3	Isr: 1,3
	Topic: quickstart76-events	Partition: 2	Leader: 0	Replicas: 0,1	Isr: 1,0
	Topic: quickstart76-events	Partition: 3	Leader: 2	Replicas: 2,0	Isr: 2,0
	Topic: quickstart76-events	Partition: 4	Leader: 3	Replicas: 3,1	Isr: 3,1
	Topic: quickstart76-events	Partition: 5	Leader: 1	Replicas: 1,0	Isr: 1,0

1、通过kafka部署方式添加两个broker

192.168.233.132:9092

192.168.233.133:9092

查看quickstart76-events的分区状态并没有改变,因为kafka对旧的topic不会因为扩容了就主动去修改它的分区和副本情况。

2、再创将一个新的topic

/path/to/kafka_home/bin/kafka-topics.sh --bootstrap-server 192.168.233.128:9092,192.168.233.129:9092,192.168.233.130:9092,192.168.233.131:9092 --create --topic quickstart77-events --partitions 6 --replication-factor 2

3、查看新topic的分区情况

$ /data/kafka_2.13-3.0.0/bin/kafka-topics.sh --bootstrap-server 192.168.233.132:9092 --topic quickstart77-events --describe
Topic: quickstart77-events	TopicId: A7bNWYseSNqlGfs1XPhN9g	PartitionCount: 6	ReplicationFactor: 2	Configs: segment.bytes=1073741824
	Topic: quickstart77-events	Partition: 0	Leader: 5	Replicas: 5,4	Isr: 5,4
	Topic: quickstart77-events	Partition: 1	Leader: 1	Replicas: 1,2	Isr: 1,2
	Topic: quickstart77-events	Partition: 2	Leader: 4	Replicas: 4,3	Isr: 4,3
	Topic: quickstart77-events	Partition: 3	Leader: 2	Replicas: 2,0	Isr: 2,0
	Topic: quickstart77-events	Partition: 4	Leader: 3	Replicas: 3,5	Isr: 3,5
	Topic: quickstart77-events	Partition: 5	Leader: 0	Replicas: 0,1	Isr: 0,1

可见,针对新的topic,分区和对应的副本会铺满全部的broker。

而旧的topic需要手动调整分区。

你可能感兴趣的:(kafka,分布式)