1、查看topic
/opt/kafka/bin/kafka-topics.sh --list --zookeeper zookeeper_ip:zookeeper_port
2、创建 topic
/opt/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper_ip:zookeeper_port --replication-factor 2 --partitions 1 --topic topic_name
3、删除Topic
/opt/kafka/bin/kafka-topics.sh --delete --zookeeper zookeeper_ip:zookeeper_port --topic topic_name
4、查看topic 详细信息
/opt/kafka/bin/kafka-topics.sh --zookeeper zookeeper_ip:zookeeper_port --describe --topic topic_name
5、修改topic副本数
例如:
编写修改副本计划
[root@k19-bigdata-4 ~]# cat replication.json
{"version":1,
"partitions":[
{"topic":"test","partition":0,"replicas":[0,1]},
{"topic":"test","partition":1,"replicas":[0,1]},
{"topic":"test","partition":2,"replicas":[0,1]},
{"topic":"test","partition":3,"replicas":[0,1]},
{"topic":"test","partition":4,"replicas":[0,1]},
{"topic":"test","partition":5,"replicas":[0,1]},
{"topic":"test","partition":6,"replicas":[0,1]}
]
}
执行计划
/opt/kafka/bin/kafka-reassign-partitions.sh --zookeeper zookeeper_ip:zookeeper_port --reassignment-json-file replication.json --execute
6、修改分区数据(只能增加)
/opt/kafka/bin/kafka-topics.sh --zookeeper zookeeper_ip:zookeeper_port --alter --topic test –partitions 6
例如:
7、创建生产者
/opt/kafka/bin/kafka-console-producer.sh --broker-list 10.0.32.210:6667 --topic K19-NTC-HTTP-LOG
8、创建消费者
/opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server 192.168.5.104:6667 --topic K19-NTC-HTTP-LOG --from-beginning
9、创建消费者组
/opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server 10.0.32.210:6667 --topic K19-NTC-HTTP-LOG --consumer.config /opt/kafka/config/consumer.properties
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/75757.html