What happens when one of the Kafka replicas is dow

2019-06-02 07:31发布

I have a cluster of 2 Kafka brokers and a topic with replication factor 2. If one of the brokers dies, will my producers be able to continue sending new messages to this degraded cluster of 1 node? Or replication factor 2 requires 2 alive nodes and messaged will be refused?

5条回答
We Are One
2楼-- · 2019-06-02 08:02

It depends on a few factors:

  • What is your producer configuration for acks? If you configure to "all", the leader broker won't answer with an ACK until the message have been replicated to all nodes in ISR list. At this point is up to your producer to decide if he cares about ACKs or not.
  • What is your value for min.insync.replicas? If the number of nodes is below this config, your broker leader won't accept more messages from producers until more nodes are available.

So basically your producers may get into a pause for a while, until more nodes are up.

查看更多
神经病院院长
3楼-- · 2019-06-02 08:10

replication-factor 2 doesn't require 2 live brokers, it publish message while one broker is down depends on those configurations - acks - min.insync.replicas

Check those configurations as mentioned above @Javier

查看更多
爷、活的狠高调
4楼-- · 2019-06-02 08:17

Messages will not be ignored if the no. of alive brokers is lesser than the configured replicas. Whenever a new Kafka broker joins the cluster, the data gets replicated to that node.

You can reproduce this scenario by configuring the replication factor as 3 or more and start only one broker.

查看更多
神经病院院长
5楼-- · 2019-06-02 08:22

Kafka will handle reassigning partitions for producers and consumers that where dealing with the partitions lost, but it will problematic for new topics.

You could start one broker with a replication factor of 2 or 3. It does work. However, you could not create a topic with that replication factor until you have that amount of brokers in the cluster. Either the topic is auto generated on the first message or created manually, kafka will throw an error.

  • kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic test

Error while executing topic command : Replication factor: 3 larger than available brokers: 1. [2018-08-08 15:23:18,339] ERROR org.apache.kafka.common.errors.InvalidReplicationFactorException: Replication factor: 3 larger than available brokers: 1.

查看更多
一夜七次
6楼-- · 2019-06-02 08:25

As soon as new node joined to the kafka cluster, data will be replicated, the replicas factor does not effect the publisher messages

查看更多
登录 后发表回答