一 .修改Kafka Topic副本数
1.bin/kafka-topics.sh --zookeeper gw04:2181,gw05:2181,gw06:2181 --create --partitions 3 --replication-factor 3 --topic bms_clean_dwm_es11_yb
##新建测试topic bms_clean_dwm_es11_yb
2.bin/kafka-topics.sh --zookeeper gw04:2181,gw05:2181,gw06:2181 --topic bms_clean_dwm_es11_yb --describe ##查看Topic详情如下:
Topic:bms_clean_dwm_es11_yb PartitionCount:3 ReplicationFactor:3 Configs:
Topic: bms_clean_dwm_es11_yb Partition: 0 Leader: 49 Replicas: 49,48,47 Isr: 49,48,47
Topic: bms_clean_dwm_es11_yb Partition: 1 Leader: 48 Replicas: 48,47,49 Isr: 48,47,49
Topic: bms_clean_dwm_es11_yb Partition: 2 Leader: 47 Replicas: 47,49,48 Isr: 47,49,48
3.cat << EOF > increase-replication-factor.json
{“version”:1,
“partitions”:[
{“topic”:“bms_clean_dwm_es11_yb”,“partition”:0,“replicas”:[47]},
{“topic”:“bms_clean_dwm_es11_yb”,“partition”:1,“replicas”:[48]},
{“topic”:“bms_clean_dwm_es11_yb”,“partition”:2,“replicas”:[49]}
]
}
EOF
##新建修改副本数 increase-replication-factor.json 文件
4.bin/kafka-reassign-partitions.sh --zookeeper gw04:2181,gw05:2181,gw06:2181 --reassignment-json-file increase-replication-factor.json --execute
##执行操作命令将副本数改为 1
5.看到successfully,查看现在bms_clean_dwm_es11_yb的副本数已经修改为1
Topic:bms_clean_dwm_es11_yb PartitionCount:3 ReplicationFactor:1 Configs:
Topic: bms_clean_dwm_es11_yb Partition: 0 Leader: 47 Replicas: 47 Isr: 47
Topic: bms_clean_dwm_es11_yb Partition: 1 Leader: 48 Replicas: 48 Isr: 48
Topic: bms_clean_dwm_es11_yb Partition: 2 Leader: 49 Replicas: 49 Isr: 49
二 . 修改Kafka 分区数操作步骤
1.bin/kafka-topics.sh --zookeeper gw04:2181,gw05:2181,gw06:2181 --create --partitions 3 --replication-factor 3 --topic bms_clean_dwm_es11_ym
##新建测试topic bms_clean_dwm_es11_ym
2.bin/kafka-topics.sh --zookeeper gw04:2181,gw05:2181,gw06:2181 --topic bms_clean_dwm_es11_ym --describe ##查看Topic详情如下:
Topic:bms_clean_dwm_es11_ym PartitionCount:3 ReplicationFactor:3 Configs:
Topic: bms_clean_dwm_es11_ym Partition: 0 Leader: 49 Replicas: 49,48,47 Isr: 49,48,47
Topic: bms_clean_dwm_es11_ym Partition: 1 Leader: 47 Replicas: 47,49,48 Isr: 47,49,48
Topic: bms_clean_dwm_es11_ym Partition: 2 Leader: 48 Replicas: 48,47,49 Isr: 48,47,49
##分区数为3,副本数为3
3.bin/kafka-topics.sh --zookeeper gw04:2181,gw05:2181,gw06:2181 -alter --partitions 6 --topic bms_clean_dwm_es11_ym ##分区数只能增加不能减小
4.bin/kafka-topics.sh --zookeeper gw04:2181,gw05:2181,gw06:2181 --topic bms_clean_dwm_es11_ym --describe
Topic:bms_clean_dwm_es11_ym PartitionCount:6 ReplicationFactor:3 Configs:
Topic: bms_clean_dwm_es11_ym Partition: 0 Leader: 49 Replicas: 49,48,47 Isr: 49,48,47
Topic: bms_clean_dwm_es11_ym Partition: 1 Leader: 47 Replicas: 47,49,48 Isr: 47,49,48
Topic: bms_clean_dwm_es11_ym Partition: 2 Leader: 48 Replicas: 48,47,49 Isr: 48,47,49
Topic: bms_clean_dwm_es11_ym Partition: 3 Leader: 49 Replicas: 49,48,47 Isr: 49,48,47
Topic: bms_clean_dwm_es11_ym Partition: 4 Leader: 47 Replicas: 47,49,48 Isr: 47,49,48
Topic: bms_clean_dwm_es11_ym Partition: 5 Leader: 48 Replicas: 48,47,49 Isr: 48,47,49文章来源:https://www.toymoban.com/news/detail-407338.html
##查看详情来看分区数已经被改成6个,副本数还是3文章来源地址https://www.toymoban.com/news/detail-407338.html
到了这里,关于kafka修改Topic副本数和分区数的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!