大数据组件-Kafka常用命令(持续更新完善)

kafka_2.12-1.0.2 common command

1.启动kafka服务

bin/kafka-server-start.sh config/server.properties &

2.停止kafka服务

./kafka-server-stop.sh

3.查看所有的话题

./kafka-topics.sh --list --zookeeper localhost:9092
./kafka-topics.sh --list --zookeeper localhost:2181

内网

kafka-topics --list --zookeeper ip:2181

4.创建topic

./kafka-topics.sh --create --zookeeper localhost:2181 --partitions 1 --replication-factor 1 --topic hotitems
./kafka-topics.sh --list --zookeeper localhost:2181

5.创建生产者

./kafka-console-producer.sh --broker-list localhost:9092 --topic wordcount

./kafka-console-producer.sh --broker-list localhost:9092 --topic hotitems

6.启动kafka connect

bin/connect-standalone.sh config/connect-standalone.properties config/connect-mysql-source.properties

7.消费kafka,查看是否导入成功

hotitems
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic hotitems --from-beginning
maxwell
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic maxwell --from-beginning
user_behavior
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic user_behavior --from-beginning

8.删除topic数据?????慎用待验证

./bin/kafka-topics.sh --delete --topic hotitems --zookeeper localhost:2181

某一topic数据清空

./kafka-topics.sh --zookeeper localhost:2181 --delete --topic hotitems

kafka_2.12-1.0.2 cm manage kafka

某一topic数据清空

kafka-topics --zookeeper localhost:2181 --delete --topic hotitems

kafka-topics --list --zookeeper localhost:9092

kafka-topics --create --zookeeper ip:2181 --partitions 40 --replication-factor 1 --topic all_type_data_r2p40

kafka-topics --create --zookeeper ip:2181 --partitions 5 --replication-factor 1 --topic user_follow

kafka-topics --create --zookeeper ip:2181 --partitions 5 --replication-factor 1 --topic video_info

kafka-topics --create --zookeeper ip:2181 --partitions 5 --replication-factor 1 --topic user_active

kafka-topics --create --zookeeper ip:2181 --partitions 5 --replication-factor 1 --topic default_r2p5


kafka-topics --create --zookeeper ip:2181 --partitions 5 --replication-factor 1 --topic flink-rt-calc

wordcount topic
kafka-topics --create --zookeeper localhost:2181 --partitions 5 --replication-factor 1 --topic wordcount

查看所有的话题

kafka-topics --list --zookeeper ip:2181

kafka-topics --list --zookeeper ip:2181

kafka-topics --list --zookeeper localhost:2181

列出指定话题的详细信息

kafka-topics --zookeeper ip:2181 --describe  --topic all_type_data_r2p40

kafka-topics --zookeeper ip:2181 --describe  --topic wordcount

kafka生产数据

kafka-console-producer --broker-list ip:9092 --topic wordcount

kafka-console-consumer --bootstrap-server localhost:9092 --topic hotitems --from-beginning

--bootstrap-server localhost:9092 --topic wordcount --from-beginning

kafka-console-producer --broker-list ip:9092 --topic wordcount

kafka-console-consumer --bootstrap-server ip:9092 --topic wordcount --from-beginning

listeners=PLAINTEXT://0.0.0.0:9092,
advertised.listeners=PLAINTEXT://xxxdata002:9092

netstat -anp | grep 9092

kafka-consumer-groups --new-consumer --bootstrap-server ip:9092 --list

kafka-console-consumer --bootstrap-server localhost:9092 --topic hotitems --from-beginning

kafka-console-consumer --bootstrap-server ip:9092 --topic maxwell --from-beginning
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值