kafka replication tools

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相同

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值