Install a Multi-Node Hadoop Cluster Step by Step

Big Data and Hadoop Administrator 20 min min read Updated: Nov 16, 2026 Intermediate
Install a Multi-Node Hadoop Cluster Step by Step
Intermediate Topic 2 of 4

Lab Layout

HostRoles
master1NameNode, ResourceManager, JobHistory Server
worker1DataNode, NodeManager
worker2DataNode, NodeManager
worker3DataNode, NodeManager

Four Linux VMs with 4 GB RAM each are enough. All nodes must pass the OS preparation checklist from the previous lessons (FQDN, chrony, ulimit, Java, hdfs user).

Step 1: Install Hadoop on Every Node

bash # as root on each node (use Ansible or a loop) cd /opt wget https://dlcdn.apache.org/hadoop/common/hadoop-3.4.3/hadoop-3.4.3.tar.gz # or the current 3.5.x release wget https://dlcdn.apache.org/hadoop/common/hadoop-3.4.3/hadoop-3.4.3.tar.gz.sha512 sha512sum -c hadoop-3.4.3.tar.gz.sha512 # always verify the download tar -xzf hadoop-3.4.3.tar.gz && ln -s hadoop-3.4.3 hadoop chown -R hdfs:hadoop /opt/hadoop-3.4.3 cat > /etc/profile.d/hadoop.sh <<'EOF' export HADOOP_HOME=/opt/hadoop export HADOOP_CONF_DIR=/etc/hadoop/conf export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin EOF mkdir -p /etc/hadoop && cp -r /opt/hadoop/etc/hadoop /etc/hadoop/conf

Step 2: Create Data and Log Directories

bash # masters mkdir -p /data/nn1 /data/nn2 && chown -R hdfs:hadoop /data/nn1 /data/nn2 && chmod 700 /data/nn1 /data/nn2 # workers (one dir per disk in production) mkdir -p /data/disk1/dn && chown -R hdfs:hadoop /data/disk1/dn && chmod 700 /data/disk1/dn # logs and pids mkdir -p /var/log/hadoop /var/run/hadoop && chown -R hdfs:hadoop /var/log/hadoop /var/run/hadoop

Step 3: Configuration (Same Files on All Nodes)

xml <!-- core-site.xml --> <configuration> <property><name>fs.defaultFS</name><value>hdfs://master1.hadoop.example.com:8020</value></property> <property><name>hadoop.tmp.dir</name><value>/data/tmp</value></property> <property><name>io.file.buffer.size</name><value>131072</value></property> </configuration>
xml <!-- hdfs-site.xml --> <configuration> <property><name>dfs.replication</name><value>3</value></property> <property><name>dfs.blocksize</name><value>134217728</value></property> <property><name>dfs.namenode.name.dir</name><value>file:///data/nn1,file:///data/nn2</value></property> <property><name>dfs.datanode.data.dir</name><value>file:///data/disk1/dn</value></property> <property><name>dfs.namenode.http-address</name><value>master1.hadoop.example.com:9870</value></property> <property><name>dfs.hosts.exclude</name><value>/etc/hadoop/conf/dfs.exclude</value></property> </configuration>
xml <!-- yarn-site.xml --> <configuration> <property><name>yarn.resourcemanager.hostname</name><value>master1.hadoop.example.com</value></property> <property><name>yarn.nodemanager.aux-services</name><value>mapreduce_shuffle</value></property> <property><name>yarn.nodemanager.resource.memory-mb</name><value>3072</value></property> <property><name>yarn.nodemanager.resource.cpu-vcores</name><value>2</value></property> <property><name>yarn.scheduler.maximum-allocation-mb</name><value>3072</value></property> <property><name>yarn.nodemanager.local-dirs</name><value>/data/disk1/yarn/local</value></property> <property><name>yarn.nodemanager.log-dirs</name><value>/data/disk1/yarn/logs</value></property> <property><name>yarn.log-aggregation-enable</name><value>true</value></property> <property><name>yarn.nodemanager.hostname</name><value>${yarn.nodemanager.hostname}</value></property> </configuration>
Last property: Remove yarn.nodemanager.hostname unless you really need it. It is shown only to remind you that NodeManagers must be able to resolve and register with a correct host name.
xml <!-- mapred-site.xml --> <configuration> <property><name>mapreduce.framework.name</name><value>yarn</value></property> <property><name>mapreduce.jobhistory.address</name><value>master1.hadoop.example.com:10020</value></property> <property><name>mapreduce.jobhistory.webapp.address</name><value>master1.hadoop.example.com:19888</value></property> <property><name>yarn.app.mapreduce.am.env</name><value>HADOOP_MAPRED_HOME=/opt/hadoop</value></property> <property><name>mapreduce.map.env</name><value>HADOOP_MAPRED_HOME=/opt/hadoop</value></property> <property><name>mapreduce.reduce.env</name><value>HADOOP_MAPRED_HOME=/opt/hadoop</value></property> </configuration>
bash # /etc/hadoop/conf/workers worker1.hadoop.example.com worker2.hadoop.example.com worker3.hadoop.example.com # /etc/hadoop/conf/hadoop-env.sh export JAVA_HOME=/usr/lib/jvm/java-17-openjdk export HADOOP_LOG_DIR=/var/log/hadoop export HADOOP_PID_DIR=/var/run/hadoop

Step 4: Format the NameNode (Once Only)

bash sudo -u hdfs hdfs namenode -format -clusterId prod-cluster-01
Never re-format a cluster with data: Formatting creates a new namespace and a new clusterID. DataNodes with the old ID will refuse to join, and old metadata is erased.

Step 5: Start the Services

bash # on master1, as hdfs (or use systemd units) sudo -u hdfs start-dfs.sh sudo -u yarn start-yarn.sh sudo -u mapred mapred --daemon start historyserver # check on each node jps

Step 6: Create Standard HDFS Directories

bash sudo -u hdfs hdfs dfs -mkdir -p /tmp /user /apps /mr-history /app-logs sudo -u hdfs hdfs dfs -chmod 1777 /tmp sudo -u hdfs hdfs dfs -chmod 755 /user /apps sudo -u hdfs hdfs dfs -chmod 1777 /mr-history /app-logs # a home directory for each user sudo -u hdfs hdfs dfs -mkdir /user/alice && sudo -u hdfs hdfs dfs -chown alice:alice /user/alice

Step 7: Verify

bash hdfs dfsadmin -report | head -20 # 3 live datanodes yarn node -list # 3 RUNNING nodemanagers sudo -u alice hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar pi 4 1000 sudo -u alice hdfs dfs -put /etc/hosts /user/alice/ && hdfs dfs -ls /user/alice
CheckExpected
NameNode UI http://master1:98703 live DataNodes, no missing blocks
ResourceManager UI http://master1:80883 active nodes, job finished
JobHistory http://master1:19888Pi job listed

Troubleshooting First Start

SymptomCheck
DataNode not registeringFirewall, clusterID mismatch in /data/disk1/dn/current/VERSION, DNS
NodeManager UNHEALTHYDisk full or yarn.nodemanager.local-dirs permission
Permission denied creating filesHDFS directory ownership and umask
Job stays ACCEPTEDNo resources: lower container sizes or check NodeManager memory settings

Run Services with systemd (Recommended)

ini # /etc/systemd/system/hadoop-datanode.service [Unit] Description=Hadoop DataNode After=network.target [Service] User=hdfs Group=hadoop Environment=HADOOP_CONF_DIR=/etc/hadoop/conf ExecStart=/opt/hadoop/bin/hdfs datanode Restart=on-failure LimitNOFILE=128000 [Install] WantedBy=multi-user.target

Conclusion

Prepare every node, deploy identical config, format the NameNode once, start HDFS, YARN and the history server, create standard directories and verify with dfsadmin -report and a sample job.

Quick Summary: install -> config -> format once -> start -> mkdir standard dirs -> test job.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators