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

修改分区数

  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


【AD】美国洛杉矶CN2 VPS/香港CN2 VPS/日本CN2 VPS推荐,延迟低、稳定性高、免费备份_搬瓦工vps

【AD】RackNerd 推出的 KVM VPS 特价优惠,在纽约、西雅图、圣何塞和阿什本每年仅需 12.88 美元!