Code Monkey home page Code Monkey logo

kafka-101-playground's Introduction

Kafka 101 Playground

The purpose of this simple project is to provide a quick way to start an arbitrary number of Kafka servers, relying on a single ZooKeeper server, and creating a Kafka topic on the cluster.

This has only been tested on MacOS. It might work on a random UNIX system. It won't work on any Windows system (unless you have a bash shell on it).

Usage

  • -r flag: replication factor i.e. the number of Kafka servers that will be spun up
  • -t flag: name of the topic that will be created
  • -c flag: location of the configuration directory - the configuration directory is expected to contain a zookeper.properties file and a tpl subdirectory containing a server.tpl.properties file

Example

By issuing the command

./quickstart_kafka.sh -r 3 -t mytopic -c conf

the script will start 1 ZooKeeper server, 3 Kafka servers, and will then create a topic named mytopic:


replication factor: 3
topic name: mytopic
config location: conf

Starting ZooKeeper server...
Giving ZooKeeper 10 seconds to spin up...
...done sleeping

Starting 3 separate Kafka servers...
   generating properties file server-0.properties for server 0
   replacing placeholders in file conf/server-0.properties
   starting server 0

   generating properties file server-1.properties for server 1
   replacing placeholders in file conf/server-1.properties
   starting server 1

   generating properties file server-2.properties for server 2
   replacing placeholders in file conf/server-2.properties
   starting server 2

All ZooKeeper and Kafka servers started, you can terminate them all by issuing the following command:

kill 11274 11618 11625 11638 && rm -rf /tmp/zookeeper && rm -rf /tmp/kafka-logs

or you can execute the 'kill_and_cleanup.sh' file that was generated by this script

Creating topic 'mytopic' with replication_factor '3' and port '9092' at localhost
Topic 'mytopic' has been created

the script also generates a kill_and_cleanup.sh file for removing all servers (through the kill command) and wiping the /tmp directories in one swoop.

Once the server(s) have been started, we can test that Kafka is actually working by:

  1. starting a consumer
kafka-console-consumer --bootstrap-server localhost:9092 --topic mytopic --from-beginning
  1. starting a producer and issuing some messages
kafka-console-producer --broker-list localhost:9092 --topic mytopic
> my
> kafka
> cluster
> is
> working
  1. verify that the consumer is actually receiving the messages

kafka-101-playground's People

Stargazers

 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.