首页 > 代码库 > kafka扩容
kafka扩容
需求:
对全kafka集群中的topic :imp-imps-app-web增加partition和replicate
1.kafka 扩容
首先按照搭建步骤,在其他机器上搭建集群,kafka的配置文件中 zkconnect 要保持与原kafka一致
2.验证kafka新节点是否加入集群成功,这个应该去zookeeper的zkCli.sh 去查看
[zk: localhost:2181(CONNECTED) 3] ls /kafka/brokers/ids
[27, 28, 29]
3.创建了一个topic
[root@zk-kafka001 bin]# ./kafka-topics.sh --create --zookeeper 10.0.150.27:2181/kafka --replication-factor 1 --partitions 1 --topic imp-imps-app-web
2.列出所有topic
./kafka-topics.sh --list --zookeeper 10.0.150.27:2181/kafka
3.修改了partiton数量
./kafka-topics.sh --zookeeper 10.0.150.27:2181/kafka --alter --topic imp-imps-app-web --partitions 3
4.查看一个topic的所有详细信息
bin/kafka-topics.sh --describe --zookeeper 10.0.150.27:2181/kafka --topic mmm
Topic:eee PartitionCount:3 ReplicationFactor:1 Configs:
Topic: eee Partition: 0 Leader: 37 Replicas: 37 Isr: 37
Topic: eee Partition: 1 Leader: 37 Replicas: 37 Isr: 37
Topic: eee Partition: 2 Leader: 38 Replicas: 38 Isr: 38
5.
在当前目录创建一个json文件
reassignment-node.json
vim imp-imps-app-web.json
加入内容:
{
"partitions": [
{
"topic": "imp-imps-app-web",
"partition": 0,
"replicas": [
27,
28,
29
]
},
{
"topic": "imp-imps-app-web",
"partition": 1,
"replicas": [
27,
28,
29
]
}
]
}
6.修改replicas
./kafka-reassign-partitions.sh --zookeeper 10.0.150.27:2181/kafka --reassignment-json-file imp-imps-app-web.json --execute
7.验证
./kafka-topics.sh --describe --zookeeper 10.0.150.34:2181/kafka --topic imp-imps-app-web
Topic:imp-imps-app-web PartitionCount:3 ReplicationFactor:2 Configs:
Topic: imp-imps-app-web Partition: 0 Leader: 34 Replicas: 34,35 Isr: 34,35
Topic: imp-imps-app-web Partition: 1 Leader: 34 Replicas: 34,35,36 Isr: 36,34,35
Topic: imp-imps-app-web Partition: 2 Leader: 38 Replicas: 38 Isr: 38
查看kafka版本
kafka查看版本需要查看libs下面jar包的名称。。。。
/app/zpy/kafka/libs
kafka扩容