1、清空某个topic数据
需要在service设置delete.topic.enable=true
./bin/kafka-topics.sh --zookeeper 172.23.75.105:2181 --delete --topic robots2
2、查看topic列表
./bin/kafka-topics.sh --zookeeper localhost:2181 --list
3、启动停止kafka
后台启动:nohup ./bin/kafka-server-start.sh ./config/server.properties &
./kafka-server-start.sh ../config/server.properties 2>&1 &
停止: ./bin/kafka-server-stop.sh
4、修改某个topic保存数据时间
./kafka-topics.sh --zookeeper ip地址1:2181,ip地址2:2181,ip地址3:2181 --alter --topic topic名字 --config retention.ms=43200000
5、修改某个topic,单条消息大小。
报错: org.apache.kafka.common.errors.RecordTooLargeException: The request included a message larger than the max message size the server will accept.
./kafka-topics.sh --zookeeper 127.0.0.1:2181 --list
7、消费数据
./kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --topic test.test_123