【kafka】多broker集群容错测试

启动zookeeper之后,在三台机器上启动kafka

root@master:/opt/modules/kafka_2.11# bin/kafka-server-start.sh -daemon config/server.properties 

创建三个副本,一个分区的topic,名称为test2

root@master:/opt/modules/kafka_2.11#  bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 3 --partitions 1 --topic test2

查看topic信息

root@master:/opt/modules/kafka_2.11# bin/kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic test2
Topic:test2     PartitionCount:1        ReplicationFactor:3     Configs:segment.bytes=1073741824
        Topic: test2    Partition: 0    Leader: 0       Replicas: 0,1,2 Isr: 0,1,2

PartitionCount:1 分区数为1
ReplicationFactor:3 副本数为3
Replicas: 0,1,2 代表副本存放的broker.id
Isr: 0,1,2 现在活着的broker的id为0,1,2
Leader: 0 表示现在是id为0的broker负责分区的读写

下面杀死broker.id为0的Leader
停掉kafka

root@master:/opt/modules/kafka_2.11# bin/kafka-server-stop.sh 

再次查看topic信息

root@slave01:/opt/modules/kafka_2.11# bin/kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic test2
Topic:test2     PartitionCount:1        ReplicationFactor:3     Configs:segment.bytes=1073741824
        Topic: test2    Partition: 0    Leader: 1       Replicas: 0,1,2 Isr: 1,2

可以看到,Leader已经变成id为1的机器,活着的只有1,2了
当只留下一个kafka节点时

root@slave02:/opt/modules/kafka_2.11# bin/kafka-topics.sh --describe --bootstrap-server localhost:9092 --topic test2
Topic:test2     PartitionCount:1        ReplicationFactor:3     Configs:segment.bytes=1073741824
        Topic: test2    Partition: 0    Leader: 2       Replicas: 0,1,2 Isr: 2

kafka依然运行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值