Skip to content
Jimmy Bonds edited this page Dec 19, 2018 · 3 revisions

kafkactl Topic Mgmt:

Create a Topic with 1 Partition and a Replication Factor of 1:

  • Create the Topic:
# > kafkactl admin create -t my.target.topic -p 1 -r 1

Successfully created topic my.target.topic

  • Show the Topic Metadata or Details:
# > kafkactl topic my.target.topic -m

TOPIC            PART  OFFSET  LEADER  REPLICAS  ISRs  OFFLINE
my.target.topic  0     0       5       [5]       [5]   []

Migrate a Partition to another Broker:

  • First replicate the partition to the desired broker, specify the desired leader first in the list. Verify ISRs are in Sync before continuing further:
> kafkactl admin move -t my.target.topic -p 0 --brokers "2,5"
{"version":1,"partitions":[{"topic":"my.target.topic","partition":0,"replicas":[2,5]}]}

 Successfully Started Reassign Partition Process.

> kafkactl topic my.target.topic -m

TOPIC            PART  OFFSET  LEADER  REPLICAS  ISRs   OFFLINE
my.target.topic  0     0       5       [2 5]     [5 2]  []

  • Move the Partition again, specifying the desired broker(s) / Verify:
> kafkactl admin move -t my.target.topic -p 0 --brokers "2"
{"version":1,"partitions":[{"topic":"my.target.topic","partition":0,"replicas":[2]}]}

 Successfully Started Reassign Partition Process.

> kafkactl topic my.target.topic -m

TOPIC            PART  OFFSET  LEADER  REPLICAS  ISRs  OFFLINE
my.target.topic  0     0       2       [2]       [2]   []

Increase Partitions and/or Replication Factor on a Topic:

  • Verify Topic beforehand and increase partitions to 15:
# > kafkactl -b targetbroker01 topics my.target.topic -m
TOPIC            PART  OFFSET  LEADER  REPLICAS  ISRs  OFFLINE
my.target.topic  0     4755    2       [2]       [2]   []

# > kafkactl -b targetbroker01 admin increase -t my.target.topic -p 15
 Increase Partitions Successful for topic: my.target.topic
  • Verify increase Partition count:
# > kafkactl -b targetbroker01 topics my.target.topic -m
TOPIC            PART  OFFSET  LEADER  REPLICAS  ISRs  OFFLINE
my.target.topic  0     4755    2       [2]       [2]   []
my.target.topic  1     0       3       [3]       [3]   []
my.target.topic  2     0       4       [4]       [4]   []
my.target.topic  3     0       5       [5]       [5]   []
my.target.topic  4     0       1       [1]       [1]   []
my.target.topic  5     0       2       [2]       [2]   []
my.target.topic  6     0       3       [3]       [3]   []
my.target.topic  7     0       4       [4]       [4]   []
my.target.topic  8     0       5       [5]       [5]   []
my.target.topic  9     0       1       [1]       [1]   []
my.target.topic  10    0       2       [2]       [2]   []
my.target.topic  11    0       3       [3]       [3]   []
my.target.topic  12    0       4       [4]       [4]   []
my.target.topic  13    0       5       [5]       [5]   []
my.target.topic  14    0       1       [1]       [1]   []

  • Increase Replication Factor to 3:
# > kafkactl -b targetbroker01 admin increase -t my.target.topic -r 3
 Successfully Started Reassign Partition Process.

# > kafkactl -b targetbroker01 topics my.target.topic -m
TOPIC            PART  OFFSET  LEADER  REPLICAS  ISRs     OFFLINE
my.target.topic  0     4755    2       [2 5 4]   [2 4 5]  []
my.target.topic  1     0       3       [3 2 1]   [3 1 2]  []
my.target.topic  2     0       4       [4 3 1]   [4 1 3]  []
my.target.topic  3     0       5       [5 2 4]   [5 4 2]  []
my.target.topic  4     0       1       [1 3 5]   [1 5 3]  []
my.target.topic  5     0       2       [2 1 4]   [2 1 4]  []
my.target.topic  6     0       3       [3 2 5]   [3 2 5]  []
my.target.topic  7     0       4       [4 3 1]   [4 3 1]  []
my.target.topic  8     0       5       [5 2 4]   [5 2 4]  []
my.target.topic  9     0       1       [1 3 5]   [1 3 5]  []
my.target.topic  10    0       2       [2 1 4]   [2 1 4]  []
my.target.topic  11    0       3       [3 2 5]   [3 5 2]  []
my.target.topic  12    0       4       [4 3 1]   [4 1 3]  []
my.target.topic  13    0       5       [5 2 4]   [5 2 4]  []
my.target.topic  14    0       1       [1 3 5]   [1 5 3]  []

Deleting a Topic:

  • There will be no confirmation or warnings when deleting a topic!
> kafkactl admin delete -t my.target.topic

Successfully deleted topic my.target.topic