kafka replication tools 博客分类: kafka kafkareplication
kafka工具
replication tool工作步骤(异步过程,执行完1就结束):
1.更新zk上的/admin/preferred_replica_election节点,内容为副本的几个位置(不包含已经奔溃的leader)
2.controller中的zk的listener读取topic partition的副本的几个位置
3.controller获取每个topic partition的副本的几个replica中的第一个,作为referred replica;
如果这个preferred replica不是leader且在isr中,则controller发出request到这个preferred replica的broker,通知其作为topic partition的leader
bin/kafka-preferred-replica-election.sh --zookeeper localhost:81821/kafka-zk --path-to-json-file topicPartitionList.json
topicPartitionList.json格式为:
{
"partitions":
[
{"topic": "topic1", "partition": "0"},
{"topic": "topic1", "partition": "1"},
{"topic": "topic1", "partition": "2"},
{"topic": "topic2", "partition": "0"},
{"topic": "topic2", "partition": "1"},
]
}
FAQ
What happens if the preferred replica is not in the ISR?
The controller will fail to move the leadership to the preferred replica if it is not in the ISR. This is to ensure that there is no dataloss. When the replica becomes "in-sync" with the leader, the tool can be run again to move the leader.
则移动失败,避免数据丢失
How to find if all the partitions have been moved to the "preferred replica" after running the tool?
ListTopicCommand is an excellent tool that provides an overview of all the topic partitions in the cluster. For each topic partition, it displays the leader, assigned replicas and current "in-sync" replica set. If the leader and the first replica in the assigned replica set are the same then the Preferred replica leader election" tool succeeded. If not, the tool failed and may have to be run again.
跟isr的第一个replica相同
推荐阅读
-
kafka replication tools 博客分类: kafka kafkareplication
-
忍不住要喷一下kafka 博客分类: MQ大数据
-
Kafka-消息中间件 博客分类: 架构 Kafka消息中间件
-
Kafka的分布式架构设计与High Availability机制 博客分类: kafka kafka分布式busHAHigh Availability
-
kafka 博客分类: java随笔 jmswindows
-
KafKa服务搭建 博客分类: kafka kafka
-
kafka技术题 博客分类: 笔试面试
-
kafka技术题 博客分类: 笔试面试
-
Kafka入门 博客分类: java kafka消息系统消息发布订阅分布式集群
-
Spring 初探(5) kafka 博客分类: Spring cloud 系列,kafka springkafka