kafka 修改分区_kafka关于修改副本数和分区的数的案例实战(也可用作leader节点均衡案例)...

本文通过实例展示了如何使用kafka-topics.sh和kafka-reassign-partitions.sh工具修改topic的分区数和副本数,包括创建、查看、修改及验证分区和副本的步骤,可用于实现leader节点均衡。
摘要由CSDN通过智能技术生成

kafka关于修改副本数和分区的数的案例实战(也可用作leader节点均衡案例)

作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.关于topic分区数的修改

1>.创建1分区1个的topic,名称为yinzhengjie-channel

[root@node101 ~]# kafka-topics.sh --zookeeper node102.yinzhengjie.org.cn:2181 --create --replication-factor 1 -partitions 1 --topic yinzhengjie-channel

Created topic"yinzhengjie-channel".

[root@node101~]#

2>.查看topic的信息

[root@node101 ~]# kafka-topics.sh --describe --zookeeper node102.yinzhengjie.org.cn:2181 --topic yinzhengjie-channel

Topic:yinzhengjie-channel PartitionCount:1 ReplicationFactor:1Configs:

Topic: yinzhengjie-channel Partition: 0 Leader: 103 Replicas: 103 Isr: 103 #可以很明显的看出kafka 的分区数和副本数都是1[root@node101~]#

3>.将之前创建的topic修改为3个分区

[root@node101 ~]# kafka-topics.sh --alter --zookeeper node102.yinzhengjie.org.cn:2181 --topic yinzhengjie-channel --partitions 3WARNING: If partitions are increasedfora topic that has a key, the partition logic or ordering of the messages will be affected

Adding partitions succeeded![root@node101~]#

4>.再次查看topic的分区数

[root@node101 ~]# kafka-topics.sh --describe --zookeeper node102.yinzhengjie.org.cn:2181 --topic yinzhengjie-channel

Topic:yin

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值