Hadoop Revisited, Part I: Tutorial and Cheat Sheet
It's time to get back to the basics and review the main key concepts of Hadoop so that we have a solid foundation when working with it.
Join the DZone community and get the full member experience.
Join For FreeIn this series, we are going to scan through some Hadoop main concepts. Hadoop is a well-known platform, and we are not going to "rediscover" it here. However, we are going to review its key concepts. After being stormed by so many platforms (i.e. Storm, Spark, and Kafka), it's time to get back to the basics and review so that we have a solid ground on Hadoop key concepts.
Our plan:
Name the basic key concepts.
Scan Hadoop job management main concepts, again focusing on the few most important concepts.
Learn the three most-used Hadoop
fs
commands and see how to use them.
1. Basic Key Concepts
Every mapper communicates with all reducers (potentially sending data to all of them). Here are some key terms to help you:
Shuffle
: Communication from mappers to reducers.Block Size
: Files (of any and every size) are split into blocks.- If you want your result to reside in a single file (can't be multiple blocks) you need a single reducer.
Partitioner
: Splits themap
result to thereducer
the withhash
so that the same keys always reach the same reducers.
Lastly, in order to edit Hadoop configurations, all you need to do is access the configurations in the folder /etc/hadoop/conf
.
2. Hadoop Job Management
A core concept of Hadoop is its famous job management. Here are the main things to remember about it:
- The master sends the actual
jar
to be executed to data nodes. - Hadoop sends data from
mappers
toreducers
even beforemappers
finish in order to havereducers
ready to start working. hadoop jar
is the command that will run yourjar
.- You should have already uploaded it to the Hadoop cluster with
-put
.
- You should have already uploaded it to the Hadoop cluster with
- Show a list of running jobs with
mapred job -list
.
Step 3: Hadoop Main Commands
Here are the most commonly used commands in Hadoop and their usages. (I have chosen the top three commands that I use.)
hadoop fs -cat
. Usage:hadoop fs -cat URI [URI...]
. Copies source path to stdout. We print to console a file andgrep
search for a string. You can combine this with other bash command lines likewc -l
to count the number of lines containing these results.hadoop fs -get
. With this command, we get a remote file to a local file system. The below commands fetch fromuser/hadoop/file
e in your local file system for a file namedlocalfile
and a remote file namedfile
.hadoop fs -ls
. This is simply thels
Hadoop file system with very similar arguments to the bash one. The main option is-R
, which recursively lists all subdirectories encountered.ls
returns the stats on the file with the following format:
$ hadoop fs -cat hdfs://myhadoop/file0000 | grep "somestring i search for"
hadoop fs -get /user/hadoop/file localfile
hadoop fs -get hdfs://nn.example.com/user/hadoop/file localfile
# list all files under /myuser/hadoop/
hadoop fs -ls /myuser/hadoop/
Summary
In this first post, we have scanned Hadoop main concepts, job management, and main command line utils. In the next post, we are going to write our first map reduce
job while also looking at its key concepts to build a solid ground. See ya there!
Opinions expressed by DZone contributors are their own.
Comments