修改分区数 
- /usr/local/kafka/bin/kafka-topics.sh --alter --zookeeper 10.1.1.1:2181/kafka --topic hogtmoperation --partitions 5
 
  复制代码 
修改副本集数 
- /usr/local/kafka/bin/kafka-reassign-partitions.sh -zookeeper 10.1.1.1:2181/kafka --reassignment-json-file /root/replication.json --execute
 
  复制代码 
 
其中/root/replication.json文件如下: 
- {
 
 -     "version": 1,
 
 -     "partitions": [
 
 -         {
 
 -             "topic": "hogtmoperation",
 
 -             "partition": 0,
 
 -             "replicas": [
 
 -                 2,
 
 -                 1
 
 -             ]
 
 -         },
 
 -      {
 
 -             "topic": "hogtmoperation",
 
 -             "partition": 1,
 
 -             "replicas": [
 
 -                 3,
 
 -                 2
 
 -             ]
 
 -         },
 
 -      {
 
 -             "topic": "hogtmoperation",
 
 -             "partition": 2,
 
 -             "replicas": [
 
 -                 4,
 
 -                 3
 
 -             ]
 
 -         },
 
 -      {
 
 -             "topic": "hogtmoperation",
 
 -             "partition": 3,
 
 -             "replicas": [
 
 -                 5,
 
 -                 4
 
 -             ]
 
 -         },
 
 -      {
 
 -             "topic": "hogtmoperation",
 
 -             "partition": 4,
 
 -             "replicas": [
 
 -                 6,
 
 -                 5
 
 -             ]
 
 -         }
 
 -     ]
 
 - }
 
  复制代码 |