栏目分类:
子分类:
返回
文库吧用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
文库吧 > IT > 前沿技术 > 大数据 > 大数据系统

修改Kafka topic分区副本数

修改Kafka topic分区副本数

修改Kafka topic分区副本数
    • 1. 创建topic
    • 2. 查询topic
    • 3. 修改topic副本数为2

1. 创建topic
./kafka-topics.sh --zookeeper=localhost:2181 --create --replication-factor 1 --partitions 3 --topic TEST
2. 查询topic
./kafka-topics.sh --zookeeper=localhost:2181 --describe --topic TEST

Topic: TEST TopicId: yxXZoA78TCyJDYekr_89iw PartitionCount: 3 ReplicationFactor: 1 Configs:
Topic: TEST Partition: 0 Leader: 1 Replicas: 1 Isr: 1
Topic: TEST Partition: 1 Leader: 2 Replicas: 2 Isr: 2
Topic: TEST Partition: 2 Leader: 3 Replicas: 3 Isr: 3

3. 修改topic副本数为2

创建配置文件add_test_topic_replication2.json,内容如下

{
    "version":1,
    "partitions":[
        {
            "topic":"TEST",
            "partition":0,
            "replicas":[
                1,
                2
            ]
        },
        {
            "topic":"TEST",
            "partition":1,
            "replicas":[
                2,
                3
            ]
        },
        {
            "topic":"TEST",
            "partition":2,
            "replicas":[
                3,
                1
            ]
        }
    ]
}

执行命令修改分区副本数

./kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file add_test_topic_replication2.json --execute

结果如下

[2021-09-29 14:07:29,513] INFO Registered kafka:type=kafka.Log4jController MBean (kafka.utils.Log4jControllerRegistration$:31)
[2021-09-29 14:07:30,222] INFO [ZooKeeperClient] Initializing a new session to localhost:2181. (kafka.zookeeper.ZooKeeperClient:66)
[2021-09-29 14:07:30,263] INFO [ZooKeeperClient] Waiting until connected. (kafka.zookeeper.ZooKeeperClient:66)
[2021-09-29 14:07:30,290] INFO [ZooKeeperClient] Connected. (kafka.zookeeper.ZooKeeperClient:66)
Current partition replica assignment
{“version”:1,“partitions”:[{“topic”:“TEST”,“partition”:0,“replicas”:[1],“log_dirs”:[“any”]},{“topic”:“TEST”,“partition”:1,“replicas”:[2],“log_dirs”:[“any”]},{“topic”:“TEST”,“partition”:2,“replicas”:[3],“log_dirs”:[“any”]}]}

转载请注明:文章转载自 www.wk8.com.cn
本文地址:https://www.wk8.com.cn/it/280032.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 wk8.com.cn

ICP备案号:晋ICP备2021003244-6号