kafka ops commmand

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:2181

内网

kafka-topics --list --zookeeper xxxxx: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 xxxxx:2181 --partitions 40 --replication-factor 1 --topic all_type_data_r2p40

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

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

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

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


kafka-topics --create --zookeeper xxxxxx: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 xxxxx:2181

kafka-topics --list --zookeeper xxxxx:2181

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

列出指定话题的详细信息

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

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

kafka生产数据

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

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

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

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

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

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

netstat -anp | grep 9092

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

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

kafka-console-consumer --bootstrap-server xxxxx:9092 --topic maxwell --from-beginning
posted @ 2021-05-06 17:25  Eistert  阅读(111)  评论(0)    收藏  举报