Learn Labs
2. Installing Kafka

2.3 Installing a Kafka broker

tar -zxf kafka_2.13-2.7.0.tgz
mv kafka_2.13-2.7.0 /usr/local/kafka
mkdir /tmp/kafka-logs                       # ← never do this in production
export JAVA_HOME=/usr/java/jdk-11.0.10
/usr/local/kafka/bin/kafka-server-start.sh -daemon \
  /usr/local/kafka/config/server.properties

(At press time the current release was 2.8.0 on Scala 2.13.0; examples use 2.7.0.)

Smoke test — create, produce, consume:

# create
kafka-topics.sh --bootstrap-server localhost:9092 --create \
  --replication-factor 1 --partitions 1 --topic test

# describe
kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic test
# Topic:test  PartitionCount:1  ReplicationFactor:1  Configs:
#   Topic: test  Partition: 0  Leader: 0  Replicas: 0  Isr: 0

# produce (Ctrl-C to stop)
kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test
> Test Message 1
> Test Message 2

# consume
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
# Test Message 1
# Test Message 2

--zookeeper is deprecated

Older tooling used a --zookeeper connection string. Deprecated in almost all cases. Current best practice: --bootstrap-server, connecting directly to a broker. In a cluster you can give the host:port of any broker.


On this page