Three things Hadoop needs before it will even start
Riya downloads Hadoop 3.5.0 onto her Windows laptop, double-clicks the file, and nothing useful happens. Kabir tries on his old Ubuntu laptop: start-dfs.sh prints ERROR: JAVA_HOME is not set and could not be found three times. Then Permission denied (publickey,password). They come to Arjun Sir, frustrated. “Hadoop is broken!”
Hadoop isn't broken. It's standing on three legs, and each of you is missing one.
Which ones?
Riya, Hadoop is built for Linux. On Windows you'll use WSL, which gives you a real Ubuntu inside Windows. Kabir, Hadoop's daemons are Java programs, and the start scripts couldn't find your Java because JAVA_HOME wasn't set where they look. And that “Permission denied” is SSH: start-dfs.sh logs in to every node, even when the only node is your own laptop, and it needs to do that without a password.
So: Linux, Java, SSH.
Exactly. Today we prepare all three, check them with one script, and learn just enough Linux to feel at home. In the next two lessons, the actual install will then just work. Every error message you saw today has a one-line fix, and you'll know it.
Hadoop's prerequisites
Apache Hadoop requires: (1) a supported operating system, in practice Linux (GNU/Linux is the supported production platform; on Windows, WSL 2 or a virtual machine provides a Linux environment); (2) a Java Development Kit of a supported version: for Hadoop 3.5 the server daemons require JDK 17 (clients support JDK 17 and 21), while Hadoop 3.3 and 3.4 run on Java 8 or 11; the JAVA_HOME environment variable must point to it, typically set in etc/hadoop/hadoop-env.sh; and (3) SSH with an sshd service running and passwordless key-based login from the master to every node (including localhost), because the cluster start/stop scripts use SSH to launch remote daemons.
You need a Linux machine (or Ubuntu inside Windows), Java 17 installed and its location written in Hadoop's settings, and SSH set up so your computer can log in to itself without asking for a password. Then Hadoop's start scripts can do their job.
Words you'll meet in this lesson
jps./usr/lib/jvm/java-17-openjdk-amd64.export NAME=value.bin and sbin so hdfs works anywhere.export lines here so they persist.~/.ssh/authorized_keys) that allow login without a password.What you need (Hadoop 3.5.0, practice setup)
| Operating system | Ubuntu 22.04/24.04, or Windows 10/11 with WSL 2 + Ubuntu, or macOS (works, but less common) |
|---|---|
| Java | OpenJDK 17 for Hadoop 3.5 (the official apache/hadoop:3.5.0 Docker image also uses Java 17). For Hadoop 3.3/3.4: Java 8 or 11. |
| RAM | 8 GB minimum to run all daemons comfortably on one machine; 16 GB is pleasant |
| Disk | about 2 GB for Hadoop itself (0.6 GB download, 1.3 GB unpacked) plus space for your data and logs; keep 10 GB+ free |
| Packages | openjdk-17-jdk-headless, openssh-server, openssh-client (and wget or curl) |
| Download | hadoop-3.5.0.tar.gz from dlcdn.apache.org, about 580 MB; verify its SHA-512 checksum |
Source for the Java requirement: the Apache Hadoop “Hadoop Java Versions” wiki page. Always check it before installing a new release.
Prerequisites at three levels
Beginner Cooking needs a kitchen, gas and a key
- Linux is the kitchen Hadoop was designed for. Windows users borrow a Linux kitchen through WSL.
- Java is the gas: no daemon can “cook” without it, and Hadoop must know which cylinder to use (
JAVA_HOME). - SSH is a master key: the head chef (start script) walks into every room (node) to switch things on, without knocking each time.
Intermediate The Linux you actually need
- Move around:
pwd,ls -l,cd,mkdir -p. - Files:
cat,less,nano(to edit XML),cp,mv,tar -xzf. - Install software:
sudo apt update,sudo apt install …. - Variables:
export JAVA_HOME=…,echo $JAVA_HOME, add lines to~/.bashrc, thensource ~/.bashrc. - Processes:
jps(Java processes),ps aux | grep java,kill. - Logs:
tail -fon files in$HADOOP_HOME/logs.
Advanced Why SSH, and when you don't need it
start-dfs.shreads theworkersfile and runsssh <host> hdfs --daemon start datanodefor each host. On one machine, the only host islocalhost, so SSH still runs.- You can skip SSH by starting each daemon yourself:
hdfs --daemon start namenode,hdfs --daemon start datanode,yarn --daemon start resourcemanager… This is how containers and cluster managers start Hadoop. - Keys must be protected:
~/.sshshould be700andauthorized_keys600, orsshdrefuses them. - In production, Hadoop runs as dedicated service users (
hdfs,yarn,mapred), and configuration management or Cloudera Manager/Ambari handles start-up, not hand-made keys. - Hadoop 3.5's requirement of JDK 17 for servers is a real break from older releases; a cluster upgrade usually starts with a Java upgrade.
Exam tip: For “List the prerequisites for installing Hadoop”, write: Linux OS (or a Linux VM/WSL), Java (JDK) of a supported version with JAVA_HOME set (in hadoop-env.sh), SSH with passwordless login to all nodes, enough RAM and disk, and the Hadoop binary tarball. One line on why each is needed earns full marks.
Four ways to get a Linux environment for Hadoop
| Native Ubuntu | WSL 2 on Windows | Docker (any OS) | Virtual machine | |
|---|---|---|---|---|
| Set-up effort | Low if you already use Linux | Low: one command in PowerShell | Low: Docker Desktop + one file | Medium: install VirtualBox + Ubuntu |
| Feels like | A real server | A real Ubuntu terminal inside Windows | A ready-made multi-node cluster | A separate computer |
| Learn installation steps? | Yes | Yes | No: images come pre-installed | Yes |
| Multi-node practice | Hard on one PC | Hard | Easy (3 DataNodes in seconds) | Possible with several VMs, heavy |
| RAM needed | 8 GB+ | 8 GB+ | 8 GB+ (16 better) | 12 GB+ |
| Used in this course | Lesson 4.3 | Lesson 4.3 | Lesson 4.3 (main practice cluster) | Not covered |
Which Java for which Hadoop?
Hadoop 3.5.x
Servers (NameNode, DataNode, YARN…) require JDK 17. Clients support JDK 17 and 21.
This courseHadoop 3.3 / 3.4
Java 8, and Java 11 as a runtime. Many company clusters still run these.
Common at workHadoop 3.0–3.2
Java 8.
OlderHadoop 2.x
Java 7 or 8. Out of maintenance: upgrade.
LegacyInstall the JDK (with jps and javac), not just a JRE. jps is your most-used Hadoop debugging command, and you'll compile Java MapReduce jobs from Module 8.
Prepare a fresh Ubuntu (or WSL) for Hadoop
Windows only: install WSL 2 with Ubuntu
Restart when asked, open “Ubuntu” from the Start menu and create a Linux user name and password. From now on, every command runs in that Ubuntu terminal.wsl --install -d Ubuntu-24.04Install Java 17 and SSH
sudo apt update sudo apt install -y openjdk-17-jdk-headless openssh-server openssh-client wgetheadlessmeans no graphical parts, which servers don't need.openssh-serverprovidessshd, which the start scripts connect to.Find where Java lives
java -version readlink -f $(which java)openjdk version "17.0.20.1" 2026-08-18 OpenJDK Runtime Environment (build 17.0.20.1+1-1-24.04-Ubuntu) OpenJDK 64-Bit Server VM (build 17.0.20.1+1-1-24.04-Ubuntu, mixed mode, sharing) /usr/lib/jvm/java-17-openjdk-amd64/bin/javaJAVA_HOMEis that path without/bin/java:/usr/lib/jvm/java-17-openjdk-amd64. The exact update number on your machine will differ.Set variables permanently
Then runexport JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 export HADOOP_HOME=$HOME/hadoop-3.5.0 export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbinsource ~/.bashrc.HADOOP_HOMEpoints to where you'll unpack Hadoop in Lesson 4.3; addingbinandsbintoPATHlets you typehdfsandstart-dfs.shfrom any folder.Start the SSH server
On WSL, services don't always start automatically: run this each time you open Ubuntu (or enable systemd in WSL). Passwordless keys are set up in Lesson 4.3, right before the firstsudo service ssh startstart-dfs.sh.
Kabir's three errors: what he sees, and what is really missing
Every message on the left is real output from Hadoop 3.5.0 on Ubuntu 24.04. On the right: which leg was missing.
- Fresh Ubuntu: Java isn't installed at all. Ubuntu even suggests the install command.
- After installing OpenJDK 17,
java -versionworks. - But
start-dfs.shstill says JAVA_HOME is not set (this is real Hadoop 3.5.0 output). Why, ifjavaworks? - Because the start script launches daemons over SSH in a new, non-interactive shell. Setting
JAVA_HOMEinhadoop-env.shfixes it for every daemon. - SSH to
localhostis refused: no key is authorised and password logins aren't allowed for scripts. - Create a key pair and authorise it: now SSH works without a password, and the start scripts can do their job.
- Linux is there, but the Java leg is missing entirely.
- Installing the JDK fixes Java for Kabir's own terminal.
- Start scripts launch daemons through SSH in a new non-interactive shell. It doesn't load his terminal settings, so the daemons can't find Java.
hadoop-env.shis read by every Hadoop command and daemon, whatever shell starts it. SettingJAVA_HOMEthere fixes the leg for good.- The SSH leg:
sshdis running but has no authorised key for Kabir, so scripted logins fail. - With a key pair in
authorized_keys, all three legs are in place.
Prerequisites at work
1. Upgrades start with Java
Moving a cluster to Hadoop 3.5 means moving every server to JDK 17 first, and checking that Hive, Spark and custom jobs work on it. Java versions are often the longest part of an upgrade plan.
2. Automating prerequisites on hundreds of servers
Platform teams don't install Java and SSH keys by hand. Tools like Ansible (or the cluster manager) install the same JDK, users, keys and kernel settings on every node, so all nodes are identical.
3. Laptops of data engineers
Many engineers on Windows laptops use WSL 2 for daily data work: Hadoop and Spark clients, Python, Git, Docker. It gives the same Linux commands as the servers they deploy to.
4. Service users instead of personal accounts
In production, NameNode and DataNodes run as the hdfs user, YARN as yarn, and history as mapred. Each has only the permissions it needs, which limits damage if one is compromised.
Simplified; organisations differ in tools and policies.
A prerequisite checker in Python
Real tools such as Ambari and Cloudera Manager run host checks before installing anything. This small version reads facts about a machine (here typed in as a dictionary) and reports what is missing. Run it, then try the challenges.
machine = {
"os": "Ubuntu 24.04.5 LTS",
"java": 'openjdk version "17.0.20.1" 2026-08-18',
"java_home": "/usr/lib/jvm/java-17-openjdk-amd64",
"ram_gb": 7.8,
"disk_free_gb": 19,
"ssh_server": True,
"passwordless_ssh": False,
}
def java_major(line):
version = line.split('"')[1] # 17.0.20.1
first = version.split(".")[0] # 17
return int(first)
problems = []
if java_major(machine["java"]) < 17:
problems.append("Hadoop 3.5 needs Java 17")
if not machine["java_home"]:
problems.append("JAVA_HOME is not set")
if machine["ram_gb"] < 8:
problems.append("less than 8 GB RAM: run fewer daemons")
if machine["disk_free_gb"] < 10:
problems.append("less than 10 GB free disk")
if not machine["ssh_server"]:
problems.append("install openssh-server")
if not machine["passwordless_ssh"]:
problems.append("set up passwordless SSH keys")
print("Java major version:", java_major(machine["java"]))
for p in problems:
print("FIX:", p)
print("Ready!" if not problems else f"{len(problems)} thing(s) to fix")"java": 'openjdk version "17.0.20.1" 2026-08-18',This is the exact first line thatjava -versionprinted on our test machine.version = line.split('"')[1] # 17.0.20.1Splitting on the double quote gives three pieces; the version is the middle one.first = version.split(".")[0] # 17The major version is the part before the first dot. (Old Java 8 printed1.8.0_…; challenge 3 handles that.)if machine["ram_gb"] < 8:7.8 GB shows up as “less than 8” because the operating system reserves a little memory. Hadoop still runs; you just run fewer things at once.print("Ready!" if not problems else f"{len(problems)} thing(s) to fix")An empty list counts as False in Python, sonot problemsmeans “nothing to fix”.
Run it on your machine: is it ready for Hadoop?
This shell script checks everything from Part 4 in one go. Save it in your Ubuntu or WSL home folder as check_prereqs.sh and run it before and after the install steps. Both outputs below are from a real run on a fresh Ubuntu 24.04 machine.
Before: a fresh Ubuntu 24.04
#!/usr/bin/env bash
# check_prereqs.sh: is this Linux / WSL machine ready for Hadoop 3.5?
echo "== Operating system"; grep PRETTY_NAME /etc/os-release | cut -d= -f2
echo "== CPU cores"; nproc
echo "== Memory"; free -h | awk '/Mem:/ {print $2 " total, " $7 " available"}'
echo "== Free disk in HOME"; df -h "$HOME" | awk 'NR==2 {print $4 " free"}'
echo "== Java"; if command -v java >/dev/null; then java -version 2>&1 | head -1; else echo "NOT INSTALLED"; fi
echo "== JAVA_HOME"; echo "${JAVA_HOME:-not set}"
echo "== SSH client"; command -v ssh >/dev/null && echo "installed" || echo "NOT INSTALLED"
echo "== SSH server"; (command -v sshd >/dev/null || [ -x /usr/sbin/sshd ]) && echo "installed" || echo "NOT INSTALLED"
echo "== Passwordless SSH to localhost"
if ssh -o BatchMode=yes -o ConnectTimeout=3 localhost true 2>/dev/null; then echo "OK"; else echo "NOT YET (set up keys in Lesson 4.3)"; fi
# In the Ubuntu / WSL terminal:
# bash check_prereqs.shA brand-new Ubuntu has no Java and no SSH. The memory and disk lines will show your own machine's numbers.
After: the steps from Part 4 done
sudo apt install -y openjdk-17-jdk-headless openssh-server openssh-client
source ~/.bashrc
sudo service ssh start
# keys from Lesson 4.3, then:
bash check_prereqs.shEvery line is now green. The last line needs the SSH keys from Lesson 4.3; it is included here so you can re-use the same script later. Your Java patch number may be newer than 17.0.20.1.
Reading a version string, one step at a time
Follow the real java -version line through the parser and watch each variable change in memory.
Worked examples: real problems, solved and traced in memory
Three jobs a Hadoop admin really does before installing: checking a list of machines, sizing memory for the daemons, and generating the environment lines every node needs. Each runs live and is traced in memory.
Which lab machines are ready?
Problem statement
A college lab has four machines. Each needs Java 17 or newer, at least 8 GB RAM and 20 GB of free disk to join the Hadoop practice cluster. List which are ready and what each of the others is missing.
lab1: Java 17, 16 GB, 120 GB · lab2: Java 11, 16 GB, 80 GB · lab3: Java 17, 4 GB, 50 GB · lab4: Java 21, 32 GB, 10 GB
lab1: ready lab2: needs Java 17 lab3: needs RAM lab4: needs disk
Approach
- Store each machine as a tuple of (java, ram, disk).
- Check the three rules and collect what fails.
- Print “ready” or the list of problems.
Solution: run it live
What happens in memory, step by step
Recorded from a real Python run: press Next to execute one line at a time. Watch variables change in each frame, and lists and dictionaries (numbered #1, #2 …) fill up as objects.
Will the daemons fit in RAM?
Problem statement
A pseudo-distributed setup runs NameNode, DataNode, SecondaryNameNode, ResourceManager, NodeManager and the JobHistory Server on one 8 GB laptop. Each daemon is given a 1 GB Java heap, the operating system needs 2 GB, and each task container needs 1 GB. How many containers can run at once?
8 GB RAM · 6 daemons × 1 GB · OS 2 GB · 1 GB per container
Daemons + OS use 8 GB, 0 GB left -> 0 containers at a time
Approach
- Add up daemon heaps and the OS.
- Subtract from total RAM.
- Whole containers that fit = floor(left / 1 GB).
Solution: run it live
What happens in memory, step by step
Recorded from a real Python run: press Next to execute one line at a time. Watch variables change in each frame, and lists and dictionaries (numbered #1, #2 …) fill up as objects.
Generate the environment lines for every node
Problem statement
A team sets up 5 worker nodes. Each node's ~/.bashrc needs JAVA_HOME, HADOOP_HOME and a PATH line, and the Java folder differs by CPU type: amd64 on Intel/AMD machines, arm64 on ARM machines. Generate the lines for each node from a table, the way automation tools do.
w1–w3: amd64 · w4–w5: arm64 · Hadoop in /opt/hadoop-3.5.0
# w1 export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 export HADOOP_HOME=/opt/hadoop-3.5.0 export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin # w2 export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 export HADOOP_HOME=/opt/hadoop-3.5.0 export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin # w3 export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 export HADOOP_HOME=/opt/hadoop-3.5.0 export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin # w4 export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64 export HADOOP_HOME=/opt/hadoop-3.5.0 export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin # w5 export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64 export HADOOP_HOME=/opt/hadoop-3.5.0 export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
Approach
- Keep the per-node difference (CPU type) in data.
- Build the lines from one template.
- Print them per node so they can be copied or pushed by a tool.
Solution: run it live
What happens in memory, step by step
Recorded from a real Python run: press Next to execute one line at a time. Watch variables change in each frame, and lists and dictionaries (numbered #1, #2 …) fill up as objects.
Check yourself
Quick revision
Lesson 4.1 in one screen
- Hadoop needs three things: Linux, Java and SSH.
- Java: Hadoop 3.5 servers need JDK 17 (clients 17 or 21); Hadoop 3.3/3.4 run on Java 8 or 11.
JAVA_HOME= the folder abovebin/java, e.g./usr/lib/jvm/java-17-openjdk-amd64.- Set JAVA_HOME in
~/.bashrcand inetc/hadoop/hadoop-env.sh(SSH sessions skip your shell settings). - SSH: start scripts log in to every host in
workers, evenlocalhost. Keys must be passwordless. - Windows: use WSL 2 + Ubuntu or Docker. Linux PC: Ubuntu LTS directly.
- Install:
sudo apt install -y openjdk-17-jdk-headless openssh-server openssh-client wget. - Practical minimum: 8 GB RAM (16 GB comfortable), ~20 GB free disk.
- Check with
java -version,echo $JAVA_HOME,ssh localhost, andjpsafter start-up.
Interview and viva questions
Can Hadoop run on Windows?
Hadoop can be built for Windows, but it needs extra native files (winutils) and is not how companies run it. For learning, use WSL 2 with Ubuntu or Docker on Windows; in production, Hadoop runs on Linux.
Which Java should I install for Hadoop?
Match the Hadoop version. Hadoop 3.5 requires JDK 17 on the server side (clients may use 17 or 21). Hadoop 3.3 and 3.4 support Java 8 and 11 at runtime. Check the “Hadoop Java Versions” page on the Apache wiki for the version you install.
Why does Hadoop need SSH?
Only the convenience start and stop scripts (start-dfs.sh, start-yarn.sh) use it: they SSH into every host listed in the workers file to start or stop the daemons. Daemons can also be started on each node directly with “hdfs --daemon start datanode”, which is what service managers and containers do.
What is the difference between the JDK and the JRE?
The JRE only runs Java programs. The JDK adds development and diagnostic tools such as javac, jps and jstack. Install the JDK: jps is used constantly to check Hadoop daemons, and some tools need javac.
How do I find JAVA_HOME on Ubuntu?
Run readlink -f $(which java). It prints something like /usr/lib/jvm/java-17-openjdk-amd64/bin/java; JAVA_HOME is that path without the final /bin/java.
How much RAM do I need to practise Hadoop?
8 GB is a practical minimum for a single-machine (pseudo-distributed) setup with small jobs; 16 GB is comfortable. Each daemon is a separate Java process with its own heap, and each task runs in its own container.
Why “headless” Java?
The headless package leaves out graphical (desktop) libraries. Servers have no screen, so headless is smaller and has fewer security updates to track.
How do companies prepare hundreds of nodes?
They do not type commands by hand. A standard operating-system image, configuration management (Ansible, Puppet, Chef) or a cluster manager (Cloudera Manager, Ambari historically) installs the same Java, users, SSH keys, limits and settings on every node, and runs host checks before adding a node.
Practice problems
Small, practical exercises around versions, paths, memory and checks. Each can be run in the browser.
Strip /bin/java
Given the path /usr/lib/jvm/java-17-openjdk-amd64/bin/java, print JAVA_HOME.
/usr/lib/jvm/java-17-openjdk-amd64/bin/java
/usr/lib/jvm/java-17-openjdk-amd64
Show solution and explanation
p = "/usr/lib/jvm/java-17-openjdk-amd64/bin/java"
print(p.removesuffix("/bin/java"))How it works: JAVA_HOME is /usr/lib/jvm/java-17-openjdk-amd64: the folder that contains bin/java.
Major version
Print the major version from the line openjdk version "17.0.20.1" 2026-08-18.
openjdk version "17.0.20.1" 2026-08-18
17
Show solution and explanation
line = 'openjdk version "17.0.20.1" 2026-08-18'
print(int(line.split('"')[1].split(".")[0]))How it works: 17: the text between the quotes is 17.0.20.1, and the part before the first dot is 17.
Java for the version
Write a function that returns the server-side Java versions for Hadoop "3.4" and "3.5".
"3.4" · "3.5"
3.4 -> [8, 11] 3.5 -> [17]
Show solution and explanation
def java_for(hadoop):
return {"3.3": [8, 11], "3.4": [8, 11], "3.5": [17]}[hadoop]
print("3.4 ->", java_for("3.4"))
print("3.5 ->", java_for("3.5"))How it works: Hadoop 3.4 runs on Java 8 or 11; Hadoop 3.5 servers require JDK 17.
Parse free -h
The memory line from free -h is "Mem: 7.8Gi 512Mi 6.9Gi 2.0Mi 418Mi 7.1Gi". Print the total and available values (columns 2 and 7).
Mem: 7.8Gi 512Mi 6.9Gi 2.0Mi 418Mi 7.1Gi
total 7.8Gi available 7.1Gi
Show solution and explanation
cols = "Mem: 7.8Gi 512Mi 6.9Gi 2.0Mi 418Mi 7.1Gi".split()
print("total", cols[1], "available", cols[6])How it works: total 7.8Gi, available 7.1Gi. Python counts from 0, so column 2 is index 1 and column 7 is index 6, exactly what the awk in check_prereqs.sh prints.
Check a bashrc
Given the lines of a ~/.bashrc, report which of JAVA_HOME, HADOOP_HOME and PATH are exported.
export JAVA_HOME=… · alias ll=…
JAVA_HOME set HADOOP_HOME MISSING PATH MISSING
Show solution and explanation
bashrc = ["alias ll='ls -l'",
"export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"]
for var in ["JAVA_HOME", "HADOOP_HOME", "PATH"]:
found = any(l.startswith(f"export {var}=") for l in bashrc)
print(var, "set" if found else "MISSING")How it works: JAVA_HOME is set; HADOOP_HOME and PATH are missing. Add them as in Part 4, step 4.
Free-disk rule
A machine has 19 GB free. The Hadoop 3.5.0 download (0.6 GB) plus the unpacked folder (1.3 GB) plus at least 10 GB for HDFS data and logs are needed. Is there enough space, and how much is left over?
19 GB free · 0.6 + 1.3 + 10 GB
need 11.9 GB, enough: True, spare 7.1 GB
Show solution and explanation
need = 0.6 + 1.3 + 10
print(f"need {need:.1f} GB, enough: {19 >= need}, spare {19 - need:.1f} GB")How it works: About 11.9 GB is needed, so 19 GB is enough with about 7.1 GB to spare. (The sizes are from the real 3.5.0 tarball and its unpacked folder.)
Setup time saved by automation
Setting up one node by hand takes 45 minutes. An automated image takes 2 hours to build once and 5 minutes per node. For 40 nodes, how many hours does automation save?
45 min/node by hand · 2 h + 5 min/node automated · 40 nodes
by hand 30.0 h, automated 5.3 h, saved 24.7 h
Show solution and explanation
by_hand = 40 * 45 / 60
auto = 2 + 40 * 5 / 60
print(f"by hand {by_hand:.1f} h, automated {auto:.1f} h, saved {by_hand - auto:.1f} h")How it works: By hand 30 h, automated about 5.3 h: about 24.7 hours saved, and every node is identical, which matters more than the time.
Mixed-version cluster check
An upgrade plan to Hadoop 3.5 lists nodes and their Java versions. Print the nodes that would fail to start as servers and those that may only be clients.
nn1: 17 · dn1: 11 · dn2: 17 · edge1: 21
nn1 server Java 17: OK dn1 server Java 11: UPGRADE JAVA dn2 server Java 17: OK edge1 client Java 21: OK
Show solution and explanation
nodes = {"nn1": ("server", 17), "dn1": ("server", 11),
"dn2": ("server", 17), "edge1": ("client", 21)}
for name, (role, java) in nodes.items():
ok = java == 17 if role == "server" else java in (17, 21)
print(f"{name:6} {role:6} Java {java}: {'OK' if ok else 'UPGRADE JAVA'}")How it works: Only dn1 (a server on Java 11) must be upgraded before moving to 3.5. The edge node on Java 21 is fine as a client.
Real-world scenario questions (asked in company interviews)
Setup problems are a favourite in support and admin interviews: the interviewer shows an error and asks what you would check.
“java -version works, but start-dfs.sh says JAVA_HOME is not set”
A new team member runs start-dfs.sh and gets “localhost: ERROR: JAVA_HOME is not set and could not be found.” three times. In the same terminal, java -version prints Java 17.
The interviewer is checking: do you know that the daemons are started through SSH sessions that may not read your shell settings?
Show a strong answer
- java being on the PATH is not the same as JAVA_HOME being set, and the start script runs commands over SSH, which may not load ~/.bashrc.
- Find the folder with
readlink -f $(which java)and remove/bin/java. - Set
export JAVA_HOME=…in$HADOOP_HOME/etc/hadoop/hadoop-env.sh, so every daemon gets it. - Re-run start-dfs.sh and confirm with
jps.
“Permission denied (publickey,password)”
start-dfs.sh prints “localhost: Permission denied (publickey,password).” for the NameNode, DataNode and SecondaryNameNode.
The interviewer is checking: do you understand passwordless SSH and the files involved?
Show a strong answer
- The script tried to log in to localhost without a password and was refused.
- Check the SSH server is running (
sudo service ssh status). - Create a key with
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsaand append the public key to~/.ssh/authorized_keys; setchmod 600on that file. - Test with
ssh localhost true: it must return without asking anything.
Planning a move from Hadoop 3.4 to 3.5
Your company runs Hadoop 3.4 on Java 11 across 60 nodes and wants to upgrade to 3.5.
The interviewer is checking: do you know that 3.5 changes the Java requirement, and do you plan for it?
Show a strong answer
- Hadoop 3.5 servers require JDK 17, so Java must be upgraded on every server node first; clients can use 17 or 21.
- Check every application and library that runs inside the cluster (UDFs, custom jars, Spark/Hive versions) for Java 17 compatibility.
- Upgrade a test cluster first, then roll out with the standard image or configuration management, so no node is missed.
- Keep a rollback plan and run host checks before and after.
“I only have a Windows laptop. How do I practise?”
A student with an 8 GB Windows laptop asks how to set up Hadoop for practice.
The interviewer is checking: can you suggest a realistic, low-cost setup?
Show a strong answer
- Install WSL 2 with Ubuntu 24.04 (
wsl --install -d Ubuntu-24.04); it is a real Linux kernel on Windows. - Inside Ubuntu, install JDK 17 and SSH, set JAVA_HOME, and run Hadoop in pseudo-distributed mode.
- With 8 GB, keep jobs small and stop daemons you are not using; Docker images are an alternative if Docker Desktop is available.
- Native Windows Hadoop is not worth the trouble for learning.