Skip to content

Instantly share code, notes, and snippets.

@yaud
Last active June 15, 2018 10:54
Show Gist options
  • Save yaud/a0f2acb667d0d4a39ba20f0355648342 to your computer and use it in GitHub Desktop.
Save yaud/a0f2acb667d0d4a39ba20f0355648342 to your computer and use it in GitHub Desktop.
Kafka 1.1 cheat sheet

Get latest offsets for topic:

bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic <topic-name> --time -1

Get consumer group info:

bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group <group-name> --describe

List topic's config overriden properties:

bin/kafka-configs.sh --zookeeper localhost:2181 --entity-type topics --entity-name <topic-name> --describe

Override topic's config property:

bin/kafka-configs.sh --zookeeper localhost:2181 --entity-type topics --entity-name <topic-name> --alter --add-config <property>=<value>

Remove topic's config overriden property:

bin/kafka-configs.sh --zookeeper localhost:2181 --entity-type topics --entity-name <topic-name> --alter --delete-config <property>

Override broker property on all brokers (cluster-wise dynamic update mode):

bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type brokers --entity-default --alter --add-config <property>=<value>

To run local instance of Kafka on localhost:9092 and ZooKeeper on localhost:2181:

Install Docker

https://docs.docker.com/install/

Pull docker image

docker pull bitnami/kafka:[TAG] e.g. docker pull bitnami/kafka:1.1.0 or just docker pull bitnami/kafka for latest version.

Start ZooKeeper

docker run -d --name zookeeper --network=host -e ALLOW_ANONYMOUS_LOGIN=yes bitnami/zookeeper

Start Kafka

docker run -d --name kafka --network=host -e ALLOW_PLAINTEXT_LISTENER=yes bitnami/kafka:1.1.0

Ensure everything is up and running

  • run docker ps -a and check STATUS
  • if it is not UP (e.g. Exited) check container's logs docker logs CONTAINER_ID (get CONTAINER_ID from previous step)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment