The Kafka cluster will automatically detect any broker shutdown or failure and elect new leaders for the partitions on that machine. This will occur whether a server fails or it is brought down intentionally for maintenance or configuration changes. For the later cases Kafka supports a more graceful mechanism for stoping a server then just killing it. When a server is stopped gracefully it has two optimizations it will take advantage of:
It will sync all its logs to disk to avoid needing to do any log
recovery when it restarts (i.e. validating the checksum for all
messages in the tail of the log). Log recovery takes time so this speeds
up intentional restarts.
It will migrate any partitions the server is the leader for
to other replicas prior to shutting down. This will make the leadership
transfer faster and minimize the time each partition is unavailable to a
Syncing the logs will happen automatically happen whenever the server is stopped other than by a hard kill, but the controlled leadership migration requires using a special setting:
Note that controlled shutdown will only succeed if all the partitions hosted on the broker have replicas (i.e. the replication factor is greater than 1 and at least one of these replicas is alive). This is generally what you want since shutting down the last replica would make that topic partition unavailable.
发表于: 1年前 最后更新时间: 1月前 游览量:4120