啟動(dòng)kafka
kafka-server-start.sh $KAFKA_HOME/config/server.properties
kafka-server-start.sh -daemon $KAFKA_HOME/config/server.properties
首次啟動(dòng)成功后,會(huì)在$KAFKA_HOME/logs目錄下創(chuàng)建相應(yīng)的日志文件
獲取Kafka進(jìn)程的PID
PIDS=$(jps | grep -i 'Kafka' | awk '{print PIDS
殺掉Kafka進(jìn)程
kill -9 $PIDS
執(zhí)行jps命令查看Java進(jìn)程,此時(shí)進(jìn)程信息至少包括以下幾項(xiàng):
- Jps
- QuorumPeerMain
- Kafka
查看topic
kafka-topics.sh --list --zookeeper localhost:2181
創(chuàng)建topic
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic topicname
啟動(dòng)生產(chǎn)者
kafka-console-producer.sh --broker-list localhost:9092 --topic topicname
啟動(dòng)消費(fèi)者
kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic topicname
刪除topic
kafka-topics.sh --delete --zookeeper localhost:2181 --topic topicname
如果topic被正常刪除,查詢不到,說(shuō)明topic沒有被引用;如果被標(biāo)記為--marked for deletion,說(shuō)明還有對(duì)這個(gè)topic的引用
查看數(shù)據(jù)過(guò)期時(shí)間
kafka-configs.sh --zookeeper localhost:2181 --describe --entity-name my_first_topic --entity-type topics
修改數(shù)據(jù)過(guò)期時(shí)間
kafka-configs.sh --zookeeper localhost:2181 --alter --entity-name my_first_topic --entity-type topics --add-config retention.ms=86400000
查看主題數(shù)據(jù)偏移量
kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic task_instance_info --time -1