首页 文章

Kafka 重新分配__consumer_offsets不正确?

提问于
浏览
2

我对kafka-reassignment-paritions如何为__consumer_offsets主题起作用感到困惑?

我从1个zk和1个kafka代理开始,创建一个复制= 1,分区= 1的测试主题 . 消费和 生产环境 . 工作良好 .

我看到创建了__consumer_offsets主题 .

现在我添加第二个代理, offsets.topic.replication.factor=2 . 我跑了,

kafka-reassign-partitions --zookeeper zookeeper1:2181 --topics-to-move-json-file topics-to-move.json --broker-list "101,102" --generate

生成的重新分配看起来不正确 . 即使有2个实时经纪人,也只显示一个副本 .

我希望为每个分区获得以下副本:[101,102]或[201,101]

{
  "version": 1,
  "partitions": [
    {
      "topic": "__consumer_offsets",
      "partition": 19,
      "replicas": [101]
    },
    {
      "topic": "__consumer_offsets",
      "partition": 30,
      "replicas": [102]
    },
    {
      "topic": "__consumer_offsets",
      "partition": 47,
      "replicas": [101]
    }, ...

感谢任何建议 .

-Vms

1 回答

  • 4

    如果要增加主题的复制因子,请执行以下步骤:

    • 创建包含重新分配计划的json文件 . 在您的情况下,该文件可能如下所示:
    {"version":1, "partitions":[
      {"topic":"__consumer_offsets","partition":0,"replicas":[101,102]}, 
      {"topic":"__consumer_offsets","partition":1,"replicas":[102,101]},
      {"topic":"__consumer_offsets","partition":2,"replicas":[101,102]},
      {"topic":"__consumer_offsets","partition":3,"replicas":[102,101]},
      ...
      {"topic":"__consumer_offsets","partition":49,"replicas":[101,102]}
    ]}
    
    • 运行以下命令以增加此内部主题的RF:
    bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file reassign.json --execute
    

    然后运行 kafka-topics.sh --describe 以查看复制因子是否最多可达2 .

相关问题