kafka修改topic分区数和副本集数

  • A+
所属分类:Linux

修改分区数

  1. /usr/local/kafka/bin/kafka-topics.sh --alter --zookeeper 10.1.1.1:2181/kafka --topic hogtmoperation --partitions 5

修改副本集数

  1. /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文件如下:

  1. {
  2.     "version": 1,
  3.     "partitions": [
  4.         {
  5.             "topic": "hogtmoperation",
  6.             "partition": 0,
  7.             "replicas": [
  8.                 2,
  9.                 1
  10.             ]
  11.         },
  12.      {
  13.             "topic": "hogtmoperation",
  14.             "partition": 1,
  15.             "replicas": [
  16.                 3,
  17.                 2
  18.             ]
  19.         },
  20.      {
  21.             "topic": "hogtmoperation",
  22.             "partition": 2,
  23.             "replicas": [
  24.                 4,
  25.                 3
  26.             ]
  27.         },
  28.      {
  29.             "topic": "hogtmoperation",
  30.             "partition": 3,
  31.             "replicas": [
  32.                 5,
  33.                 4
  34.             ]
  35.         },
  36.      {
  37.             "topic": "hogtmoperation",
  38.             "partition": 4,
  39.             "replicas": [
  40.                 6,
  41.                 5
  42.             ]
  43.         }
  44.     ]
  45. }

Thu Feb 21 16:56:13 CST 2019

avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: