1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| $ bin/kafka-topics.sh --bootstrap-server hadoop101:9092 --topic test --describe Topic: test TopicId: D7jWqskZSf-F-MC39chP5A PartitionCount: 3 ReplicationFactor: 3 Configs: segment.bytes=1073741824 Topic: test Partition: 0 Leader: 2 Replicas: 2,0,1 Isr: 2,1,0 Topic: test Partition: 1 Leader: 0 Replicas: 0,1,2 Isr: 0,1,2 Topic: test Partition: 2 Leader: 1 Replicas: 1,2,0 Isr: 1,2,0
$ vim topics-to-move.json { "topics": [ {"topic": "test"} ], "version": 1 }
$ bin/kafka-reassign-partitions.sh --bootstrap-server hadoop101:9092 --topics-to-move-json-file topics-to-move.json --broker-list "0,1,2,3" --generate Current partition replica assignment {"version":1,"partitions":[{"topic":"test","partition":0,"replicas":[2,0,1],"log_dirs":["any","any","any"]},{"topic":"test","partition":1,"replicas":[0,1,2],"log_dirs":["any","any","any"]},{"topic":"test","partition":2,"replicas":[1,2,0],"log_dirs":["any","any","any"]}]} Proposed partition reassignment configuration {"version":1,"partitions":[{"topic":"test","partition":0,"replicas":[2,3,0],"log_dirs":["any","any","any"]},{"topic":"test","partition":1,"replicas":[3,0,1],"log_dirs":["any","any","any"]},{"topic":"test","partition":2,"replicas":[0,1,2],"log_dirs":["any","any","any"]}]}
$ vim increase-replication-factor.json {"version":1,"partitions":[{"topic":"test","partition":0,"replicas":[2,3,0],"log_dirs":["any","any","any"]},{"topic":"test","partition":1,"replicas":[3,0,1],"log_dirs":["any","any","any"]},{"topic":"test","partition":2,"replicas":[0,1,2],"log_dirs":["any","any","any"]}]}
$ bin/kafka-reassign-partitions.sh --bootstrap-server hadoop101:9092 --reassignment-json-file increase-replication-factor.json --execute
$ bin/kafka-reassign-partitions.sh --bootstrap-server hadoop101:9092 --reassignment-json-file increase-replication-factor.json --verify Status of partition reassignment: Reassignment of partition test-0 is complete. Reassignment of partition test-1 is complete. Reassignment of partition test-2 is complete. Clearing broker-level throttles on brokers 0,1,2,3 Clearing topic-level throttles on topic test
$ bin/kafka-topics.sh --bootstrap-server hadoop100:9092 --topic test --describe Topic: test TopicId: D7jWqskZSf-F-MC39chP5A PartitionCount: 3 ReplicationFactor: 3 Configs: segment.bytes=1073741824 Topic: test Partition: 0 Leader: 2 Replicas: 2,3,0 Isr: 0,2,3 Topic: test Partition: 1 Leader: 1 Replicas: 3,0,1 Isr: 1,0,3 Topic: test Partition: 2 Leader: 1 Replicas: 0,1,2 Isr: 1,0,2
|