Git Product home page Git Product logo

kafka-spark-streaming-example's Introduction

kafka · spark streaming example

Build Status

This is a simple dashboard example on Kafka and Spark Streaming

Prerequisites

Java 1.8 or newer version required because lambda expression used for few cases

  1. Java >= 1.8 (Oracle JDK has been tested)
  2. Maven >= 3
  3. Apache Spark >= 2.0.2
  4. Kafka >= 0.10.1.0

Installation

First of all, clone the git repository,

$ git clone [email protected]:trK54Ylmz/kafka-spark-streaming-example.git

after you need to use Maven for creating uber jar files,

$ mvn clean package -DskipTests

until that moment we had created jar files and now we'll install Kafka and MySQL,

$ wget http://www-us.apache.org/dist/kafka/0.10.1.0/kafka_2.11-0.10.1.0.tgz
$ # or wget http://www-eu.apache.org/dist/kafka/0.10.1.0/kafka_2.11-0.10.1.0.tgz
$ tar -xf kafka_2.11-0.10.1.0.tgz
$ cd kafka_2.11-0.10.1.0
$ nohup ./bin/zookeeper-server-start.sh ./config/zookeeper.properties > /tmp/kafka-zookeeper.out 2>&1 &
$ nohup ./bin/kafka-server-start.sh ./config/server.properties > /tmp/kafka-server.out 2>&1 &

Kafka is ready we can continue to install MySQL,

$ sudo apt-get install mysql-server # for Ubuntu, Debian
$ sudo yum install mysql-server && sudo systemctl start mysqld # for CentOS, RHEL
$ brew install mysql && mysql.server restart # for macOS

and finally create MySQL database and table,

CREATE DATABASE IF NOT EXISTS dashboard_test;

USE dashboard_test;

CREATE TABLE IF NOT EXISTS events (
 market VARCHAR(24) NOT NULL DEFAULT '',
 rate FLOAT DEFAULT NULL,
 dt DATETIME NOT NULL,
 PRIMARY KEY (market, dt)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

Usage

1 - Start the Spark streaming service and it'll process events from Kafka topic to MySQL,

$ cd kafka-spark-streaming-example
$ java -Dconfig=./config/common.conf -jar streaming/target/spark-streaming-0.1.jar

2 - Start the Kafka producer and it'll write events to Kafka topic,

$ java -Dconfig=./config/common.conf -jar producer/target/kafka-producer-0.1.jar

3 - Start the web server so you can see the dashboard

$ java -Dconfig=./config/common.conf -jar web/target/web-0.1.jar

4 - If everything look fine, please enter the dashboard address,

open http://localhost:8080 # default value : 8080

screen

kafka-spark-streaming-example's People

Contributors

trk54ylmz avatar

Watchers

James Cloos avatar Peter Evans avatar  avatar

Forkers

eter-evans

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.