kafka集群五、__consumer_offsets副本数修改

  kafka几圈搭建好了,但当一个节点挂机后整个集群还是不能使用并没有起到集群的作用,这是为什么?

在新版本Kafka中,__consumer_offsets这个topic是存放消费者偏移量的,但是该主题默认配置副本数量只有1,容易造成单点故障

     注:上一篇博客地址https://www.cnblogs.com/yclh/p/14894764.html

 

(1),我们可以动态修改(无需重启服务)副本因子,提高kafka的可靠性
     编辑 replication.json 文件告诉__consumer_offsets topic上50个分区分副本都在哪些节点上
     将replication.json 放到/opt/kafka/kafka_2.11-2.1.1/bin 目录下

(2)之后执行 cd /opt/kafka/kafka_2.11-2.1.1/bin
    ./kafka-reassign-partitions.sh --zookeeper 192.168.0.105:12181 --reassignment-json-file  replication.json  --execute

注:自己搭建的集群里还修改了如下配置,然后重启
       配置文件里  vi /opt/kafka/kafka_2.11-2.1.1/config/server.properties
      增加如下两行
      auto.create.topics.enable=true
      default.replication.factor=3

 

replication.json的内容如下:注:中间省略号的地方自己补全即可

{
    "version": 1,
    "partitions": [
        {
            "topic": "__consumer_offsets",
            "partition": 0,
            "replicas": [
                104,
                105,
                106
            ]
        },
        {
            "topic": "__consumer_offsets",
            "partition": 1,
            "replicas": [
                104,
                105,
                106
            ]
        },
        ........
        {
            "topic": "__consumer_offsets",
            "partition": 48,
            "replicas": [
                104,
                105,
                106
            ]
        },
        {
            "topic": "__consumer_offsets",
            "partition": 49,
            "replicas": [
                104,
                105,
                106
            ]
        }
    ]
}

上一篇:消费一下kafka的__consumer_offsets


下一篇:[Tips] pandas获取每月最后一天