Skip to content

Instantly share code, notes, and snippets.

@ssledz
Last active July 21, 2017 13:33
Show Gist options
  • Save ssledz/46ff6d22a5fa9fad30ed676c8fa10051 to your computer and use it in GitHub Desktop.
Save ssledz/46ff6d22a5fa9fad30ed676c8fa10051 to your computer and use it in GitHub Desktop.
# list topics
bin/kafka-topics.sh --list --zookeeper localhost:2181
# list groups
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
# describe group
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group console-consumer-59433 --describe
# list partitions and offsets
bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --broker-info --group console-consumer-59433 --topic test_topic --zookeeper localhost:2181
# export zk offset
bin/kafka-run-class.sh kafka.tools.ExportZkOffsets --zkconnect localhost:2181 --group console-consumer-59433 --output-file file.txt
# import zk offset
bin/kafka-run-class.sh kafka.tools.ImportZkOffsets --zkconnect localhost:2181 --input-file input.txt
# create topic with one day retention
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --config retention.ms=86400000 --topic test-topic
# describe topic
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test-topic
# run console producer
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test-topic
# run console consumer (read from beginning)
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test-topic --from-beginning
# run connector test case (FileStreamSource, FileStreamSink)
echo -e "foo\nbar" > test.txt
bin/connect-standalone.sh config/connect-standalone.properties config/connect-file-source.properties config/connect-file-sink.properties
cat test.sink.txt
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic connect-test --from-beginning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment