Skip to content

Instantly share code, notes, and snippets.

@darkrus
darkrus / kafka-zookeeper-acl.md
Last active October 26, 2019 18:33
Kafka with zookeeper ACL authentication

Simple Kafka with Zookeeper ACL authentication

Software installation

yum install wget java-1.8.0-openjdk
mkdir /opt/{kafka,zookeeper}
wget http://ftp.tudelft.nl/apache/zookeeper/current/apache-zookeeper-3.5.6-bin.tar.gz -P /opt/zookeeper
wget http://apache.mirror.triple-it.nl/kafka/2.3.1/kafka_2.12-2.3.1.tgz -P /opt/kafka
tar -xzvf /opt/zookeeper/apache-zookeeper-3.5.6-bin.tar.gz -C /opt/zookeeper/
tar -xzvf /opt/kafka/kafka_2.12-2.3.1.tgz -C /opt/kafka
ln -s /opt/zookeeper/apache-zookeeper-3.5.6-bin /opt/zookeeper/zookeeper

ln -s /opt/kafka/kafka_2.12-2.3.1 /opt/kafka/kafka

#!/usr/bin/env python
from kafka import KafkaConsumer
from kafka import TopicPartition
import time
topic = TopicPartition('test',0)
# Create connection to Kafka broker
consumer = KafkaConsumer(bootstrap_servers='localhost:9092', group_id=None)