If you encounter the following error while installing with brew, it could probably be due to lack of proper permissions.
Error that encountered during installation of hadoop on MAC:
=======================================================================
$ brew install hadoop
==> Downloading https://www.apache.org/dyn/closer.cgi?path=hadoop/common/hadoop-2.7.2/hadoop-2.7.2.tar.gz
==> Best Mirror http://mirror.symnds.com/software/Apache/hadoop/common/hadoop-2.7.2/hadoop-2.7.2.tar.gz
######################################################################## 100.0%
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink sbin/distribute-exclude.sh
/usr/local/sbin is not writable.
You can try again using:
brew link hadoop
==> Caveats
In Hadoop's config file:
/usr/local/Cellar/hadoop/2.7.2/libexec/etc/hadoop/hadoop-env.sh,
/usr/local/Cellar/hadoop/2.7.2/libexec/etc/hadoop/mapred-env.sh and
/usr/local/Cellar/hadoop/2.7.2/libexec/etc/hadoop/yarn-env.sh
$JAVA_HOME has been set to be the output of:
/usr/libexec/java_home
==> Summary
/usr/local/Cellar/hadoop/2.7.2: 6,304 files, 309.8M, built in 13 minutes 35 seconds
======================================================================
Run the following commands to grant the privileges
$ sudo chown -R $(whoami) /usr/local
$ sudo chown -R $(whoami) /Library/Caches/Homebrew
Once the privileges are granted, now hadoop has to be just linked since it is already installed.
$ brew link hadoop
Linking /usr/local/Cellar/hadoop/2.7.2... 27 symlinks created