bin/kafka-topics.sh --zookeeper localhost:2181 --list
bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic
bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000
... wait a minute ...
| Producer | |
| Setup | |
| bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test-rep-one --partitions 6 --replication-factor 1 | |
| bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test --partitions 6 --replication-factor 3 | |
| Single thread, no replication | |
| bin/kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance test7 50000000 100 -1 acks=1 bootstrap.servers=esv4-hcl198.grid.linkedin.com:9092 buffer.memory=67108864 batch.size=8196 |
| #!/bin/bash | |
| if [ $# -ne 2 ]; then | |
| >&2 echo "usage: $0 <kafka_binary_folder> <bootstrap.server>" | |
| >&2 echo | |
| >&2 echo "It outputs the list of topics consumed by consumergroup as csv." | |
| >&2 echo "With the following structure:" | |
| >&2 echo " <consumer>,<topic>" | |
| exit 1 | |
| fi |
bin/kafka-topics.sh --zookeeper localhost:2181 --list
bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic
bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000
... wait a minute ...
| # Calculate the latest and earliest offsets, and provide the total # of messages in the topic (the difference): | |
| #!/bin/bash | |
| if [[ $# -eq 0 ]] ; then | |
| echo 'provide the name of a topic to get totals against' | |
| exit 0 | |
| fi | |
| latest=`bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic $1 --time -1 --offsets 1 | awk -F ":" '{sum += $3} END {print sum}'` | |
| earliest=`bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic $1 --time -2 --offsets 1 | awk -F ":" '{sum2 += $3} END {print sum2}'` | |
| total=`expr $latest - $earliest` |