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相同
相关推荐
2. **创建主题**: 使用 `create topic` 命令创建主题,例如 `create topic my-topic --partitions 3 --replication-factor 2`。 3. **查看主题信息**: 使用 `describe topic` 命令查看主题详情,如 `describe topic...
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 ...
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...
3. **Kafka Monitoring Tools**:例如Kafka Manager、Kafka Monitor、Confluent Control Center等,提供了可视化的监控界面。 4. **日志监控**:通过Log4j或Logback配置,将Kafka的日志输出到集中式日志系统,如...
.\bin\windows\kafka-topics.bat kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic wzj3 --time -1 ``` - **描述**:获取指定Topic `wzj3` 在某个时间点的所有分区的偏移量。 - **应用场景**:...
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提供的异步API性能测试工具kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance来进行测试。测试结果表明,异步API的性能非常高,对CPU进行监控,发现CPU的利用率只是在10%-20%之间,...
kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper localhost:2181 --group test --topic testKJ1 ``` 以上命令行工具可以帮助开发者和管理员高效地管理和监控 Kafka 集群,包括创建和修改 ...
./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集群安装 - **上传安装包**:上传...
- `hdfs-site.xml`:设置副本数量(`dfs.replication`)、NameNode和DataNode的数据存储目录。 - `mapred-site.xml`:指定MapReduce运行在YARN上。 - `yarn-site.xml`:配置ResourceManager的主机名和辅助服务。 ...
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, ...