How to Install Hadoop on Ubuntu (Single-Node Setup)
Install Apache Hadoop on one Ubuntu machine for learning and testing: Java, a hadoop user, SSH to localhost, four configuration files, and a first job.
3 min readBy Daniel
Reviewed by the AmazingRDP technical team

Hadoop is hungry for memory and disk. See our dedicated servers. See Cheap Dedicated Servers from $38.99
Apache Hadoop stores very large amounts of data across many machines (HDFS) and runs computations on it where it lies (YARN and MapReduce). Before building a cluster, people install it on a single machine in "pseudo-distributed" mode: every Hadoop service runs, each as its own process, on one host. That is what this guide sets up. It is for learning and testing, not for production data.
What you need
- Ubuntu 22.04 or later with
sudorights. - At least 4 GB of memory; 8 GB is comfortable. Hadoop starts five Java processes.
- A few gigabytes of free disk space.
1. Install Java
Hadoop 3 runs on Java 8 or 11. Newer Java versions are supported only by newer Hadoop releases; the project's site lists which.
sudo apt update
sudo apt install openjdk-11-jdk
java -version
More on Java versions in installing Java on Ubuntu.
2. A user for Hadoop, and SSH to itself
Hadoop's start scripts log in to each node with SSH, even when the only node is this one.
sudo adduser hadoop
sudo apt install openssh-server
sudo -iu hadoop
ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
ssh localhost exit
The last line must succeed without asking for a password. The remaining steps are done as the user hadoop.
3. Download and unpack
On hadoop.apache.org, open Download, choose the current stable release, and copy the link of the binary archive.
wget PASTE-THE-LINK-HERE
tar xzf hadoop-*.tar.gz
mv hadoop-*/ hadoop
4. Environment variables
Add to the end of ~/.bashrc:
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export HADOOP_HOME=$HOME/hadoop
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
source ~/.bashrc
Set the same JAVA_HOME line in ~/hadoop/etc/hadoop/hadoop-env.sh; the start scripts read it there.
5. Four configuration files
All are in ~/hadoop/etc/hadoop/. In each, put the properties between the <configuration> tags.
core-site.xml (where the file system lives):
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
hdfs-site.xml (one copy of each block, since there is one machine):
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
mapred-site.xml (run jobs on YARN):
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapreduce.application.classpath</name>
<value>$HADOOP_HOME/share/hadoop/mapreduce/*:$HADOOP_HOME/share/hadoop/mapreduce/lib/*</value>
</property>
yarn-site.xml:
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
6. Format and start
hdfs namenode -format
start-dfs.sh
start-yarn.sh
jps
Format once only; doing it again erases the file system. jps should list five processes: NameNode, DataNode, SecondaryNameNode, ResourceManager and NodeManager.
7. Look at it, and run a job
| Web page | Shows |
|---|---|
http://localhost:9870 | HDFS: capacity, live nodes, a file browser |
http://localhost:8088 | YARN: running and finished jobs |
hdfs dfs -mkdir -p /user/hadoop/input
hdfs dfs -put $HADOOP_HOME/etc/hadoop/*.xml /user/hadoop/input
hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar wordcount /user/hadoop/input /user/hadoop/output
hdfs dfs -cat /user/hadoop/output/part-r-00000 | head
The example counts the words in Hadoop's own configuration files. To stop everything: stop-yarn.sh, then stop-dfs.sh.
On a remote server: keep the ports closed
Hadoop's web pages and service ports have no login in this setup. Anyone who can reach them can read and write your data and run programs on the machine, and exposed Hadoop installations are a known target. Do not open ports 9870, 8088, 9000 or the others in the firewall. Reach the web pages through an SSH tunnel from your own computer:
ssh -L 9870:localhost:9870 -L 8088:localhost:8088 hadoop@203.0.113.10
Then browse to http://localhost:9870. See the Ubuntu firewall guide and SSH hardening.
Problems
| Sign | Cause |
|---|---|
| "JAVA_HOME is not set" | The line is missing in hadoop-env.sh |
| Start scripts ask for a password or fail with "Permission denied" | SSH to localhost is not set up (step 2) |
DataNode is missing from jps | The NameNode was formatted a second time. Stop everything, clear Hadoop's data folder under /tmp, format once, start again. This loses the test data |
| Jobs hang at 0 percent | Too little memory. Close other programs or use a larger machine: see monitoring with htop |
| Everything is gone after a restart | By default data sits under /tmp, which Ubuntu clears. Set hadoop.tmp.dir in core-site.xml to a permanent folder |
From here to a real cluster
A production cluster spreads these services over several machines, keeps three copies of every block, and needs authentication switched on. That is a project of its own. For experiments with more data than a laptop holds, one large machine is the next step: see our dedicated servers.
Questions
How do I install Hadoop on Ubuntu?
Install Java, create a hadoop user with SSH access to localhost, unpack the Hadoop archive, edit four configuration files, format the NameNode and run start-dfs.sh and start-yarn.sh.
How much RAM does Hadoop need?
At least 4 GB for a single-node test setup; 8 GB is more comfortable.
Which Java version does Hadoop need?
Hadoop 3 runs on Java 8 or 11. Check the project's compatibility page before using a newer Java.
How do I check that Hadoop is running?
Run jps. It should list NameNode, DataNode, SecondaryNameNode, ResourceManager and NodeManager.