To increase the number of replicas for a given topic

Published:

Step1: Create a JSON file to specify the changes

{"version":1,
  "partitions":[
     {"topic":"signals","partition":0,"replicas":[0,1,2]},
     {"topic":"signals","partition":1,"replicas":[0,1,2]},
     {"topic":"signals","partition":2,"replicas":[0,1,2]}
]}

Step 2: Execute the below command to increase the topic size

 bin/kafka-reassign-partitions.sh --zookeeper 10.154.0.5:12182  --reassignment-json-file increase-replication-factor.json --execute

Output will be

{"version":1,"partitions":[{"topic":"105_120_SOLARWINDS_135_ALERTS","partition":3,"replicas":[1,2,3],"log_dirs":["any","any","any"]},{"topic":"105_120_SOLARWINDS_135_ALERTS","partition":1,"replicas":[1,2,3],"log_dirs":["any","any","any"]},{"topic":"105_120_SOLARWINDS_135_ALERTS","partition":0,"replicas":[1,2,3],"log_dirs":["any","any","any"]},{"topic":"105_120_SOLARWINDS_135_ALERTS","partition":4,"replicas":[1,2,3],"log_dirs":["any","any","any"]},{"topic":"105_120_SOLARWINDS_135_ALERTS","partition":2,"replicas":[1,2,3],"log_dirs":["any","any","any"]}]}

Save this to use as the --reassignment-json-file option during rollback
Successfully started reassignment of partitions.

Verify the modification by executing the below command

 bin/kafka-topics.sh --zookeeper gavelds01:12182 --topic 105_120_SOLARWINDS_135_ALERTS --describe

Output will be

Topic:105_120_SOLARWINDS_135_ALERTS     PartitionCount:5        ReplicationFactor:3     Configs:
        Topic: 105_120_SOLARWINDS_135_ALERTS    Partition: 0    Leader: 2       Replicas: 1,2,3 Isr: 2,1,3
        Topic: 105_120_SOLARWINDS_135_ALERTS    Partition: 1    Leader: 1       Replicas: 1,2,3 Isr: 1,2,3
        Topic: 105_120_SOLARWINDS_135_ALERTS    Partition: 2    Leader: 2       Replicas: 1,2,3 Isr: 2,1,3
        Topic: 105_120_SOLARWINDS_135_ALERTS    Partition: 3    Leader: 1       Replicas: 1,2,3 Isr: 1,2,3
        Topic: 105_120_SOLARWINDS_135_ALERTS    Partition: 4    Leader: 2       Replicas: 1,2,3 Isr: 2,1,3