[KAFKA]kafka常用操作
Posted amberly
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[KAFKA]kafka常用操作相关的知识,希望对你有一定的参考价值。
-- kafka路径示例
/opt/cloudera/parcels/KAFKA/bin
-- kafka启动
./kafka-server-start.sh -daemon ../config/server.properties
-- 帮助信息
kafka-topics --help
-- 查看topic
kafka-topics --list -zookeeper hadoop02:9092,hadoop03:9092,hadoop04:9092 --topic MQ_TN_BIG_DATA_CALL_API_MSG_XXX_XXX
-- 查看topc结构
kafka-topics --describe -zookeeper hadoop02:9092,hadoop03:9092,hadoop04:9092 --topic MQ_TN_BIG_DATA_CALL_API_MSG_XXX_XXX
-- 创建topic 2个分区,2个副本
bin/kafka-topics.sh --create --zookeeper hadoop02:9092,hadoop03:9092,hadoop04:9092 --replication-factor 2 --partitions 2 --topic test
-- 生产消息
kafka-console-producer.sh --broker-list hadoop02:9092,hadoop03:9092,hadoop04:9092 --topic MQ_TN_BIG_DATA_CALL_API_MSG_XXX_XXX
-- 消费消息
kafka-console-consumer.sh -zookeeper hadoop02:9092,hadoop03:9092,hadoop04:9092 --from-beginning --topic MQ_TN_BIG_DATA_CALL_API_MSG_XXX_XXX
-- 为topic增加partition.
kafka-topics.sh –zookeeper hadoop02:9092,hadoop03:9092,hadoop04:9092 –alter –partitions 3 –topic MQ_TN_BIG_DATA_CALL_API_MSG_XXX_XXX
以上是关于[KAFKA]kafka常用操作的主要内容,如果未能解决你的问题,请参考以下文章