azurehadoop

Run a test job in Hadoop

You can run jobs in Hadoop from the same computer where it is installed.

Hadoop bundles many examples that you can try. For instance, there is an example for obtaining an estimation of the Pi number’s value. You can check it by running the following command:

$ hadoop jar /opt/bitnami/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar pi 10 100

When the job finishes, you will see an output similar to:

Estimated value of Pi is 3.14800000000000000000

In order to show a MapReduce example involving HDFS, you can try running the following commands for showing how many words begin with the letter “c” in a simple tongue twister:

$ echo "can you can a can as a canner can can a can" | hadoop fs -put - /tmp/hdfs-example-input
$ hadoop jar /opt/bitnami/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar grep /tmp/hdfs-example-input /tmp/hdfs-example-output 'c[a-z]+'
$ hadoop fs -cat /tmp/hdfs-example-output/part-r-00000

You will see the job resulted in the following output:

6       can
1       canner
Last modification September 4, 2018