GithubHelp home page GithubHelp logo

rbkumar88 / kafka_tutorials Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dbosco/kafka_tutorials

0.0 2.0 0.0 14 KB

Sample code for Kafka

License: Apache License 2.0

Shell 9.73% Java 90.27%

kafka_tutorials's Introduction

kafka_tutorials

Sample code for testing Kafka

Creating eclipse project

mvn eclipse:eclipse

Go to your Eclipse IDE and import exisiting project

Compilation

mvn clean compile package

Running without Kerberos

Go to the server where you have installed Kafka and create the topic

./bin/kafka-topics.sh --zookeeper localhost:2181 --create --topic test101 --partitions 1 --replication-factor 1

First test using Kafka console/CLI utilities

From one window/terminal start the publisher

bin/kafka-console-producer.sh --broker-list `hostname -f`:6667 --topic test101

From another window/terminal start the consumer

bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test101

Make a copy of input.properties and update

bootstrap.servers=<your broker service host>:<your broker service port>

Running producer/publisher

./run_publisher.sh <input.properties>

Running consumer

./run_Consumer.sh <input.properties>

Running with Kerberos

For you running in Kerberos environment, you need to create a principal for the client application. For the principal create a keytab

To create the test topic, go to the Kafka broker server

sudo su - kafka
kinit kafka
bin/kafka-topics.sh --zookeeper `hostname -f`:2181 --create --topic test101 --partitions 1 --replication-factor 1

First test using Kafka console/CLI utilities

From one window/terminal start the publisher

kinit <user principal>
bin/kafka-console-producer.sh --broker-list `hostname -f`:6667 --topic test101 --security-protocol PLAINTEXTSASL

From another window/terminal start the consumer

kinit <user principal> (if different user)
bin/kafka-console-consumer.sh --zookeeper `hostname -f`:2181 --topic test101 --security-protocol PLAINTEXTSASL --from-beginning 
--consumer.config /tmp/consumer.properties --delete-consumer-offsets

Setting up Kerberos client for Kafka

Copy the client user keytab to the client machine

Make a copy of kafka_client_jaas.conf and update the keytab location and principal name

KafkaClient {
      	com.sun.security.auth.module.Krb5LoginModule required
        useKeyTab=true
        storeKey=true
        keyTab="jane.keytab"
        principal="[email protected]";
};

Running Publisher/Producer

./run_publisher_kerberos.sh input.properties kafka_client_jaas.conf

Running consumer

./run_consumer_kerberos.sh input.properties kafka_client_jaas.conf 

kafka_tutorials's People

Contributors

boscodurai avatar dbosco avatar

Watchers

James Cloos avatar Bharath Kumar Ramasubramanian 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.