Step 1 : Install Homebrew

Open terminal and paste this command

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"



Now copy and paste these commands to add homebrew in .bash_pofile

echo ‘eval “$(/opt/homebrew/bin/brew shellenv)”’ >> /Users/ravikanttyagi/.bash_profile


eval “$(/opt/homebrew/bin/brew shellenv)”


Step 2 : Install Hadoop using HomeBrew

brew install hadoop

After installation is completed verify hadoop path


cd /opt/homebrew/Cellar/hadoop/3.3.3/

Step 3 : Update the HADOOP_OPTS environment variable

Open this file, /usr/local/Cellar/hadoop/3.3.3/libexec/etc/hadoop/hadoop-env.sh and paste this line at bottom
export HADOOP_OPTS="-Djava.net.preferIPv4Stack=true -Djava.security.krb5.realm= -Djava.security.krb5.kdc="

To open the file we can use VS Code Editor
So first open VS Code Editor and press : cmd + shift + p
then type on searh bar : shell and click on install code command in path


Now on terminal just type : code hadoop-env.sh


Step 4 : Update core-site.xml

Open this file, /usr/local/Cellar/hadoop/3.3.3/libexec/etc/hadoop/core-site.xml and update as below.


Step 5 : Update hdfs-site.xml

Open this file, /usr/local/Cellar/hadoop/3.3.3/libexec/etc/hadoop/hdfs-site.xml and update as below.


Step 6 : Update mapred-site.xml

Open this file, /usr/local/Cellar/hadoop/3.3.3/libexec/etc/hadoop/mapred-site.xml and update as below.


Step 7 : Update yarn-site.xml

Open this file, /usr/local/Cellar/hadoop/3.3.3/libexec/etc/hadoop/yarn-site.xml and update as below.


Now open system preferences and open Sharing and select Remote Login


Step 8 : Format HDFS and Start Hadoop


hdfs namenode -format



cd /usr/local/Cellar/hadoop/3.3.3/sbin



./start-all.sh

Hadoop will start all services and you can test hadoop

For testing Hadoop open browser and type localhost:9870


Note : If you are facing an error hadoop start-dfs.sh permission denied (publickey password)

So here we need to configure SSH

Run these commands one by one



ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

chmod 0600 ~/.ssh/authorized_keys

Now repeat step 8 and that's it