kafka Topicコピー数とパーティション数の変更
3186 ワード
一.Kafka Topicコピー数の変更
二.Kafkaパーティション数の変更操作手順
1.bin/kafka-topics.sh --zookeeper 172.18.163.203:2181,172.18.163.204:2181,172.18.163.205:2181 --create --partitions 5 --replication-factor 3 --topic test01
## topic test01
2.bin/kafka-topics.sh --zookeeper 172.18.163.203:2181 --topic test01 --describe ## Topic :
Topic:test01 PartitionCount:5 ReplicationFactor:3 Configs:
Topic: test01 Partition: 0 Leader: 0 Replicas: 0,1,2 Isr: 0,1,2
Topic: test01 Partition: 1 Leader: 1 Replicas: 1,2,0 Isr: 1,2,0
Topic: test01 Partition: 2 Leader: 2 Replicas: 2,0,1 Isr: 2,0,1
Topic: test01 Partition: 3 Leader: 0 Replicas: 0,2,1 Isr: 0,2,1
Topic: test01 Partition: 4 Leader: 1 Replicas: 1,0,2 Isr: 1,0,2
3.cat << EOF > increase-replication-factor.json
{"version":1,
"partitions":[
{"topic":"test01","partition":0,"replicas":[0,2]},
{"topic":"test01","partition":1,"replicas":[0,1]},
{"topic":"test01","partition":2,"replicas":[1,2]},
{"topic":"test01","partition":3,"replicas":[1,2]},
{"topic":"test01","partition":4,"replicas":[0,2]}
]
}
EOF
## increase-replication-factor.json
4.bin/kafka-reassign-partitions.sh --zookeeper 172.18.163.203:2181,172.18.163.204:2181,172.18.163.205:2181 --reassignment-json-file increase-replication-factor.json --execute
## 2
5. successfully, test01 2
Topic:test01 PartitionCount:5 ReplicationFactor:2 Configs:
Topic: test01 Partition: 0 Leader: 0 Replicas: 0,2 Isr: 0,2
Topic: test01 Partition: 1 Leader: 1 Replicas: 0,1 Isr: 1,0
Topic: test01 Partition: 2 Leader: 2 Replicas: 1,2 Isr: 2,1
Topic: test01 Partition: 3 Leader: 1 Replicas: 1,2 Isr: 2,1
Topic: test01 Partition: 4 Leader: 0 Replicas: 0,2 Isr: 0,2
二.Kafkaパーティション数の変更操作手順
1.bin/kafka-topics.sh --zookeeper 172.18.163.203:2181,172.18.163.204:2181,172.18.163.205:2181 --create --partitions 5 --replication-factor 3 --topic test01
## topic test01
2.bin/kafka-topics.sh --zookeeper 172.18.163.203:2181 --topic test01 --describe ## Topic :
Topic:test01 PartitionCount:5 ReplicationFactor:2 Configs:
Topic: test01 Partition: 0 Leader: 0 Replicas: 0,2 Isr: 0,2
Topic: test01 Partition: 1 Leader: 1 Replicas: 0,1 Isr: 1,0
Topic: test01 Partition: 2 Leader: 2 Replicas: 1,2 Isr: 2,1
Topic: test01 Partition: 3 Leader: 1 Replicas: 1,2 Isr: 2,1
Topic: test01 Partition: 4 Leader: 0 Replicas: 0,2 Isr: 0,2
## 5, 2
3.bin/kafka-topics.sh --zookeeper 172.18.163.203:2181,172.18.163.204:2181,172.18.163.205:2181 -alter --partitions 6 --topic test01 ##
4.bin/kafka-topics.sh --zookeeper 172.18.163.203:2181 --topic test01 --describe
Topic:test01 PartitionCount:6 ReplicationFactor:2 Configs:
Topic: test01 Partition: 0 Leader: 0 Replicas: 0,2 Isr: 0,2
Topic: test01 Partition: 1 Leader: 1 Replicas: 0,1 Isr: 1,0
Topic: test01 Partition: 2 Leader: 2 Replicas: 1,2 Isr: 2,1
Topic: test01 Partition: 3 Leader: 1 Replicas: 1,2 Isr: 2,1
Topic: test01 Partition: 4 Leader: 0 Replicas: 0,2 Isr: 0,2
Topic: test01 Partition: 5 Leader: 2 Replicas: 2,0 Isr: 2,0
## 6 , 2