大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
1. 查看topic
信息(“副本”是为该分区复制日志的节点列表,无论它们是引导者还是当前处于活动状态,“ isr”是“同步”副本的集合。这是副本列表的子集,当前仍处于活动状态并追随领导者。)
[hadoop@hadoop000 tmp]$ kafka-topics.sh --describe --zookeeper hadoop000:2181 --topic my-replicated-topic
Topic:my-replicated-topic PartitionCount:1 ReplicationFactor:3 Configs:
Topic: my-replicated-topic Partition: 0 Leader: 3 Replicas: 3,1,2 Isr: 1,2,3
2. 查看三个broker的配置
[hadoop@hadoop000 tmp]$ jps -m
3761 ConsoleProducer --broker-list hadoop000:9093,hadoop000:9094,hadoop000:9095 --topic my-replicated-topic
4178 Jps -m
3717 ConsoleConsumer --zookeeper hadoop000:2181 --from-beginning --topic my-replicated-topic
3637 ConsoleProducer --broker-list hadoop000:9092 --topic my-replicated-topic
3175 QuorumPeerMain /home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin/../conf/zoo.cfg
3788 ConsoleConsumer --zookeeper hadoop000:2181 --topic my-replicated-topic
3310 Kafka /home/hadoop/app/kafka_2.11-0.9.0.0/config/server-2.properties
3230 Kafka /home/hadoop/app/kafka_2.11-0.9.0.0/config/server-1.properties
3406 Kafka /home/hadoop/app/kafka_2.11-0.9.0.0/config/server-3.properties
3. 杀死broker2模拟容错
[hadoop@hadoop000 tmp]$ kill -9 3310
#领导权已切换到关注者之一,并且节点2不再位于同步副本集中:
[hadoop@hadoop000 tmp]$ jps -m
4208 Jps -m
3761 ConsoleProducer --broker-list hadoop000:9093,hadoop000:9094,hadoop000:9095 --topic my-replicated-topic
3717 ConsoleConsumer --zookeeper hadoop000:2181 --from-beginning --topic my-replicated-topic
3637 ConsoleProducer --broker-list hadoop000:9092 --topic my-replicated-topic
3175 QuorumPeerMain /home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin/../conf/zoo.cfg
3788 ConsoleConsumer --zookeeper hadoop000:2181 --topic my-replicated-topic
3230 Kafka /home/hadoop/app/kafka_2.11-0.9.0.0/config/server-1.properties
3406 Kafka /home/hadoop/app/kafka_2.11-0.9.0.0/config/server-3.properties
[hadoop@hadoop000 tmp]$ kafka-topics.sh --describe --zookeeper hadoop000:2181 --topic my-replicated-topic
Topic:my-replicated-topic PartitionCount:1 ReplicationFactor:3 Configs:
Topic: my-replicated-topic Partition: 0 Leader: 3 Replicas: 3,1,2 Isr: 1,3
4. 但是,即使最初进行写操作的领导者已经下线,消息仍然可以使用
[hadoop@hadoop000 ~]$ kafka-console-consumer.sh --zookeeper hadoop000:2181 --from-beginning --topic my-replicated-topic
hello
[hadoop@hadoop000 ~]$ kafka-console-producer.sh --broker-list hadoop000:9093,hadoop000:9094,hadoop000:9095 --topic my-replicated-topic
hello
至此说明 Kafka
的容错性是完全有保障的。
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/164332.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...