修改kafka分区数

作者: testerzhang | 来源:发表于2019-05-06 15:27 被阅读0次

    这里记录下如何修改kafka的topic分区

    • 查看当前topic分区,假设主题是testtopic
    $ ./kafka-topics.sh --describe --zookeeper xxx.xxx.xxx.xxx:端口1,xxx.xxx.xxx.xxx:端口2,xxx.xxx.xxx.xxx:端口3 --topic testtopic
    
    
    Topic:testtopic     PartitionCount:1        ReplicationFactor:1     Configs:
            Topic: testtopic    Partition: 0    Leader: 2       Replicas: 2     Isr: 2
    
    • 修改分区个数
    $ ./kafka-topics.sh --alter  --zookeeper xxx.xxx.xxx.xxx:端口1,xxx.xxx.xxx.xxx:端口2,xxx.xxx.xxx.xxx:端口3 --topic testtopic --partitions 4
    
    
    WARNING: If partitions are increased for a topic that has a key, the partition logic or ordering of the messages will be affected
    Adding partitions succeeded!
    
    • 再次查看当前topic分区
    $  ./kafka-topics.sh --describe --zookeeper xxx.xxx.xxx.xxx:端口1,xxx.xxx.xxx.xxx:端口2,xxx.xxx.xxx.xxx:端口3 --topic testtopic 
    
    Topic:testtopic     PartitionCount:4        ReplicationFactor:1     Configs:
            Topic: testtopic    Partition: 0    Leader: 2       Replicas: 2     Isr: 2
            Topic: testtopic    Partition: 1    Leader: 3       Replicas: 3     Isr: 3
            Topic: testtopic    Partition: 2    Leader: 1       Replicas: 1     Isr: 1
            Topic: testtopic    Partition: 3    Leader: 2       Replicas: 2     Isr: 2
    

    相关文章

      网友评论

        本文标题:修改kafka分区数

        本文链接:https://www.haomeiwen.com/subject/atxdoqtx.html