It is really simple to setup hadoop in Mac. I tried the latest available version at the moment. ( hadoop-2.5.1 ) You can setup hadoop in standalone mode or pseudo-distributed mode in your local machine. By following the below steps you will be able to setup hadoop in your machine in standalone mode.
( you need to install java and ssh beforehand to run hadoop )
- Download the version you need to install from here
- Extract the downloaded packThe extracted directory will be your HADOOP_HOME ( ie: /Users/username/hadoopDir )
- Add HADOOP_HOME to .bash_profile
Export HADOOP_HOME=/Users/userName/hadoop-2.5.1
export PATH=$PATH:$HADOOP_HOME/bin
- Source .bash_profile to affect the new changes
source ~/.bash_profile
Now you should be able to echo HADOOP_HOME in terminal ( echo $HADOOP_HOME ) - Make sure that you can ssh to localhost
ssh localhost
Now your stand alone hadoop setup is ready to use.
I will share a sample code I found on map reduce to test your setup.
import java.io.IOException; import java.util.StringTokenizer; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.Mapper; import org.apache.hadoop.mapreduce.Reducer; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; public class WordCount { public static class TokenizerMapper extends Mapper
Run sample
- Create a jar from the sample
- Create a text file of which you need to count words
- Run
- On a successful execution, you will have the output directory created at the path you specify. And your result will be in output/part-r-00000
- When you run the program again you need to remove the ‘output’ directory or give some other path for the output to be written.
You will see that this is really simple.
You can find steps on setting up hadoop in pseudo-distributed mode in this post










