`

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

分享到:
评论

相关推荐

    Kafka Tool 2.0.7(linux系统)

    2. **创建主题**: 使用 `create topic` 命令创建主题,例如 `create topic my-topic --partitions 3 --replication-factor 2`。 3. **查看主题信息**: 使用 `describe topic` 命令查看主题详情,如 `describe topic...

    Packt.Learning.Apache.Kafka.2nd.Edition

    Chapter 7, Operationalizing Kafka, describes information about the Kafka tools required for cluster administration and cluster mirroring and also shares information about how to integrate Kafka with ...

    kafka_2.9.2-0.8.2.1.tgz

    bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zkconnect localhost:2181 --group test 删除topic与数据 1) kafka-topics.sh --delete --zookeeper host:port --topic topicname 2) 删除kafka...

    kafka 单机集群搭建和监控

    3. **Kafka Monitoring Tools**:例如Kafka Manager、Kafka Monitor、Confluent Control Center等,提供了可视化的监控界面。 4. **日志监控**:通过Log4j或Logback配置,将Kafka的日志输出到集中式日志系统,如...

    kafka命令.txt

    .\bin\windows\kafka-topics.bat kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic wzj3 --time -1 ``` - **描述**:获取指定Topic `wzj3` 在某个时间点的所有分区的偏移量。 - **应用场景**:...

    Kafka基础操作

    kafka-topics --create --zookeeper csdn-01:2181,csdn-02:2181,csdn-03:2181/kafka --replication-factor 3 --partitions 3 --topic topic-3-3 ``` ##### 3.3 消费者操作 - **创建消费者**:使用 `kafka-...

    Kafka性能测试报告.pdf

    使用Kafka提供的异步API性能测试工具kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance来进行测试。测试结果表明,异步API的性能非常高,对CPU进行监控,发现CPU的利用率只是在10%-20%之间,...

    Kafka 常用命令行详细介绍及整理

    kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper localhost:2181 --group test --topic testKJ1 ``` 以上命令行工具可以帮助开发者和管理员高效地管理和监控 Kafka 集群,包括创建和修改 ...

    storm集群安装

    ./kafka-topics.sh --create --topic cdr_logs --replication-factor 3 --partitions 3 --zookeeper 192.168.2.52:2181,192.168.2.53:2181,192.168.2.54: ``` #### 五、Storm集群安装 - **上传安装包**:上传...

    3台虚拟hadoop的安装配置,以前给朋友写的,现在免费分享出来,希望对大家有帮助,也可以来我的博客查找更多的相关内容

    - `hdfs-site.xml`:设置副本数量(`dfs.replication`)、NameNode和DataNode的数据存储目录。 - `mapred-site.xml`:指定MapReduce运行在YARN上。 - `yarn-site.xml`:配置ResourceManager的主机名和辅助服务。 ...

    mastering-spring-cloud2018

    mode and how to run multiple server instances with peer-to-peer replication. You will also learn how to enable discovery on the client side and register these clients in different zones. Chapter 5, ...

Global site tag (gtag.js) - Google Analytics