• 启动zookeeper

    bin/zookeeper-server-start.sh -daemon config/zookeeper.properties		
    
  • 启动kafka

    bin/kafka-server-start.sh -daemon config/server.properties
    

  • 创建topic

    bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 3 --topic <your_topic>
    
  • 查看topic

    bin/kafka-topics.sh --zookeeper localhost:2181 --list
    
  • 查看topic partitions及replications

    bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic <your_topic>
    
  • 修改topic partitions

    bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic <your_topic> --partitions <expected_partitions>
    

    p.s. 修改partitions只能增不能减

  • 修改replications

    编辑replication.json

    {
        "version": 1,
        "partitions": [
            {
                "topic": "<your_topic>",
                "partition": 0,
                "replicas": [
                    1,
                    0,
                    2
                ]
            },
            {
                "topic": "<your_topic>",
                "partition": 1,
                "replicas": [
                    2,
                    1,
                    0
                ]
            },
            {
                "topic": "<your_topic>",
                "partition": 2,
                "replicas": [
                    0,
                    2,
                    1
                ]
            }
        ]
    }
    
    bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file replication.json --execute
    
  • 查看消费堆积信息

    bin/kafka-consumer-offset-checker.sh  --zookeeper localhost:2181 --group <your_group>
    

⤧  Next post ssh Multiplexing与远程登录会话克隆 ⤧  Previous post [转] for() && fork() || fork()