Giter Club home page Giter Club logo

zookeeper_kafka_example_setup's Introduction

zookeeper_kafka_example_setup

An example methodology for setting up a Kafka and Zookeeper system

##############################################################

Spin-up Zookeeper and Kafka broker using docker-compose

############################################################## The docker-compose file spins up a single Zookeeper and a single Kafka broker.

$ docker-compose -f docker-compose.yml pull $ docker-compose up -d

Create topic called 'JOSH_TOPIC_1'

$ docker exec zookeeper_kafka_example_setup_kafka_1 kafka-topics
--create
--topic JOSH_TOPIC_1
--zookeeper 127.0.0.1:32181
--partitions 1
--replication-factor 1

Start a console consumer on topic 'JOSH_TOPIC_1'

$ docker exec zookeeper_kafka_example_setup_kafka_1 kafka-console-consumer
--bootstrap-server 127.0.0.1:9093
--topic JOSH_TOPIC_1
--partition 0
--from-beginning

Create interactive console producer on topic 'JOSH_TOPIC_1'

$ docker exec -it zookeeper_kafka_example_setup_kafka_1 bash $ kafka-console-producer --topic JOSH_TOPIC_1 --broker-list 127.0.0.1:9093

Use 'kafka-python' script to send message to topic 'JOSH_TOPIC_1'

$ python3 producer_example.py

See: https://kafka-python.readthedocs.io/en/master/usage.html for more details.

#####################################

Set up without docker-compose

#####################################

Set up a zookeeper

$ docker pull confluentinc/cp-zookeeper:latest $ docker run --restart unless-stopped -d --net=host --name=zookeeper-1
-e ZOOKEEPER_SERVER_ID=1 -e ZOOKEEPER_CLIENT_PORT=32181
-e ZOOKEEPER_TICK_TIME=2000 -e ZOOKEEPER_INIT_LIMIT=5
-e ZOOKEEPER_SYNC_LIMIT=2
confluentinc/cp-zookeeper:latest

Set up a kafka broker.

$ docker pull confluentinc/cp-kafka:latest $ docker run -d --restart unless-stopped --net=host --name=kafka-1
-e KAFKA_ZOOKEEPER_CONNECT=127.0.0.1:32181
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9093
-e KAFKA_GROUP_MAX_SESSION_TIMEOUT_MS=600000
-e KAFKA_BROKER_ID=1
confluentinc/cp-kafka:latest

Create a topic.

$ docker exec kafka-1 kafka-topics --create --topic JOSH_TOPIC_1
--zookeeper 127.0.0.1:32181 --partitions 3 --replication-factor 1

Check topics.

$ docker exec kafka-1 kafka-topics --describe --zookeeper 127.0.0.1:32181

The output will be like:

Topic:JOSH_TOPIC_1 PartitionCount:3 ReplicationFactor:1 Configs: Topic: JOSH_TOPIC_1 Partition: 0 Leader: 1 Replicas: 1 Isr: 1 Topic: JOSH_TOPIC_1 Partition: 1 Leader: 1 Replicas: 1 Isr: 1 Topic: JOSH_TOPIC_1 Partition: 2 Leader: 1 Replicas: 1 Isr: 1 Topic:__confluent.support.metrics PartitionCount:1 ReplicationFactor:1 Configs:retention.ms=31536000000 Topic: __confluent.support.metrics Partition: 0 Leader: 1 Replicas: 1 Isr: 1

zookeeper_kafka_example_setup's People

Contributors

joshuamhtsang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.