Giter Club home page Giter Club logo

gads11-nyc-hadoopcluster's Introduction

GADS11-NYC-HadoopCluster

=======

This project uses Vagrant to provision a 5 node virtual Hadoop cluster.

Getting the cluster running

Basic HDFS usage

Confirm your Vagrant cluster is running.
vagrant status

Log into the gateway client node.
vagrant ssh gw

Go to lab folder.

cd /vagrant/lab
ls

Explore HDFS.

hadoop fs -ls /
hdfs dfs -ls /  
hdfs dfs -ls /user/vagrant

Copy files from client node into HDFS.

hdfs dfs -copyFromLocal wordcounter.py
hdfs dfs -mkdir input_wc
hdfs dfs -copyFromLocal shakespeare.txt input_wc/shakespeare.txt
hdfs dfs -mkdir input_grep
hdfs dfs -copyFromLocal grep_errors.log input_grep/grep_errors.log
hdfs dfs -ls

Use fsck command for insight into how file is stored in HDFS.

hdfs fsck /user/vagrant/input_wc/shakespeare.txt
hdfs fsck /user/vagrant/input_grep/grep_errors.log

Streaming MapReduce with Python

Word count example (the hello world of MapReduce)

Let's expolore our data and Python script first

less shakespeare.txt
wc shakespeare.txt
less wordcounter.py

Let's look at some JAR's. This is the standard format of MR programs (Java).

ll /usr/lib/hadoop-mapreduce/
hadoop jar /usr/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar

Let's run a MapReduce job!!

hadoop jar /usr/lib/hadoop-mapreduce/hadoop-streaming.jar -files "wordcounter.py" -mapper "python wordcounter.py map" -reducer "python wordcounter.py reduce" -input "input_wc" -output "output_wc"

Look at the output.

hdfs dfs -ls output_wc
hdfs dfs -copyToLocal output_wc/part-00000 word_counts.txt
wc word_counts.txt
less word_counts.txt

Distributed grep Lab

Write a MR job that looks through the grep_errors.log file and only outputs ERROR lines. When you've finished your script, copy it into HDFS.

hdfs dfs -copyFromLocal grep.py

Then run with something like this:

hadoop jar /usr/lib/hadoop-mapreduce/hadoop-streaming.jar -files "grep.py" -mapper "python grep.py map" -reducer "python grep.py reduce" -input "input_grep" -output "output_grep"

If you have to rerun and get "folder already exist errors", you probably need this:

hdfs dfs -rm -r output_grep

gads11-nyc-hadoopcluster's People

Contributors

omalley avatar seanpquig avatar sumitg avatar

Watchers

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