Over a million developers have joined DZone.

Hadoop Revisited, Part I: Tutorial and Cheat Sheet

DZone's Guide to

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.

· Big Data Zone
Free Resource

See how the beta release of Kubernetes on DC/OS 1.10 delivers the most robust platform for building & operating data-intensive, containerized apps. Register now for tech preview.

In 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:

  1. Name the basic key concepts.

  2. Scan Hadoop job management main concepts, again focusing on the few most important concepts.

  3. 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 the map result to the reducer the with hash 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 to reducers even before mappers finish in order to have reducers ready to start working.
  • hadoop jar is the command that will run your jar.
    • You should have already uploaded it to the Hadoop cluster with -put.
  • 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.)

  1. hadoop fs -cat. Usage: hadoop fs -cat URI [URI...]. Copies source path to stdout. We print to console a file and grep search for a string. You can combine this with other bash command lines like wc -l to count the number of lines containing these results. 
  2. $ hadoop fs -cat hdfs://myhadoop/file0000 | grep "somestring i search for"
  3. hadoop fs -get. With this command, we get a remote file to a local file system. The below commands fetch from user/hadoop/filee in your local file system for a file named localfile and a remote file named file

  4. hadoop fs -get /user/hadoop/file localfile
    hadoop fs -get hdfs://nn.example.com/user/hadoop/file localfile
  5. hadoop fs -ls. This is simply the ls 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:
  6. # list all files under /myuser/hadoop/
    hadoop fs -ls /myuser/hadoop/


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!

New Mesosphere DC/OS 1.10: Production-proven reliability, security & scalability for fast-data, modern apps. Register now for a live demo.

hadoop ,big data ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}