kafka集群环境下topic不可用

近期生产环境出现有多个kafka服务得情况下,竟然出现某些topic消息无法入队列。

排错思路:

1.查看目前还活跃得broker数量,zookeeper安装目录执行 

1    ./zkCli.sh 

2.ls /brokers/ids   

2. 查topic得relication 是否分配到多个broker上了,cd kafka安装目录

./kafka-topics.sh --describe --zookeeper localhost:2181,localhost2:2181 --topic my-topic

结果

Topic:my-topic PartitionCount:1 ReplicationFactor:1 Configs:

Topic: my-topic Partition: 0 Leader: 1 Replicas: 1 Isr: 1

Replicas 代表只有1上有副本,那么当broker 1 挂了以后,整个topic变为不可用

3.增加 my-topic 得Replicas,制作json,执行命令以下

/opt/idc/apps/kafka/bin/kafka-reassign-partitions.sh --zookeeper 10.214.168.63:2181,10.214.168.66:2181 --reassignment-json-file kafka-topic-replication.txt --execute

校验是否加完

/opt/idc/apps/kafka/bin/kafka-reassign-partitions.sh --zookeeper 10.214.168.63:2181,10.214.168.66:2181 --reassignment-json-file kafka-topic-replication.txt --verify

增加partition

./bin/kafka-topics.sh –zookeeper 192.168.2.225:2183/config/mobile/mq –alter –partitions 20 –topic topic_test


附kafka-topic-replication.txt 如下:

{

"version": 1,

"partitions": [

{

"topic": "my-topic",

"partition": 0,

"replicas": [

1,

0

]

}

]

}

你可能感兴趣的:(kafka集群环境下topic不可用)