Saturday, June 15, 2019

Kafka command line cheat sheet in windows

The following are the command line to startup kafka after installed.
In here, I have kafka unzip into d:\app.

Start kafka

cd D:\apps\kafka_2.12-2.2.0

bin\windows\zookeeper-server-start.bat "config\zookeeper.properties"

 
bin\windows\kafka-server-start.bat "config\server.properties"


Topic :

Create topic
bin\windows\kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test   

List topic
bin\windows\kafka-topics.bat --list --bootstrap-server localhost:9092

bin\windows\kafka-topics.bat --describe --bootstrap-server localhost:9092


bin\windows\kafka-topics.bat --describe --bootstrap-server localhost:9092 --topic test


Producer:

console
bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test

Power shell to pipe apache web server access log
gc access.log | D:\dvp\kafka\kafka_2.12-2.2.0\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test
 

gc access.log -wait -tail 1 | ... (Like linux tail -f access.log. Not working)

Configure apache httpd.conf
TransferLog "| d:/dvp/kafka/kafka_2.12-2.2.0/bin/windows/kafka-console-producer.bat --topic test --broker-list localhost:9092"

For both pipe and TransferLog, I really doubt the reliabliability.




Consumer:
Console
bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning

No comments: