Giter Club home page Giter Club logo

hadoop-docker's Introduction

hadoop-docker

Docker container for quickstart with Hadoop.

Ubuntu

The Ubuntu version uses the official images as a base. Steps to create a Docker container:

  • create Dockerfile
  • run docker build (e.g. docker build --tag=ngeorge/ubuntu-hadoop-quickstart .)
  • push to docker hub docker push ngeorge/ubuntu-hadoop-quickstart
  • run the container: docker run -it ngeorge/ubuntu-hadoop-quickstart

Installing Hadoop

Generally this follows these instructions. Steps are:

  • install wget, ssh, pdsh, and git (apt install wget ssh pdsh git -y)
  • install Java 8 (apt install apt install openjdk-8-jdk -y)
  • set the JAVA_HOME environment variable (export JAVA_HOME=/usr); the Java executable is installed at /usr/bin/java; Hadoop will look for it at JAVA_HOME/bin/java
  • download and unzip Hadoop (wget http://apache.claz.org/hadoop/common/hadoop-3.1.2/hadoop-3.1.2.tar.gz, tar -zxvf hadoop-3.1.2.tar.gz -C /opt)
  • add hadoop to our path so we can run it from anywhere: export PATH=/opt/hadoop-3.1.2/bin:$PATH

Test running Hadoop within the container

Uses mapreduce streaming with Python files:

docker run -it ngeorge/ubuntu-hadoop-quickstart

git clone https://github.com/Regis-University-Data-Science/simple_Hadoop_MapReduce_example.git

wget http://norvig.com/ngrams/shakespeare.txt

Move text file to HDFS:

$ hdfs dfs -mkdir /shakespeare
$ hdfs dfs -mkdir /shakespeare/input
$ hdfs dfs -copyFromLocal shakespeare.txt /shakespeare/input
$ hdfs dfs -ls /shakespeare/input

Run the MapReduce Python code:

$ cd simple_Hadoop_MapReduce_example
$ mapred streaming \
    -mapper mapper.py \
    -reducer reducer.py \
    -input /shakespeare/input \
    -output /shakespeare/output

Check results:

hdfs dfs -ls /shakespeare/output

hdfs dfs -cat /shakespeare/output/part-00000

Copy to local disk:

hdfs dfs -copyToLocal /shakespeare/output/part-00000 result

View sorted word count: sort -gr -k 2 result | head

To share data between the docker container and the host OS, use volumes:

docker run -v path_in:container_path -it

hadoop-docker's People

Contributors

nategeorge avatar

Watchers

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