One download, three ways to run it
Riya's WSL Ubuntu now has Java 17 and SSH. She unpacks hadoop-3.5.0.tar.gz, runs the built-in grep example, and it finishes in seconds with a _SUCCESS file. “Done! I have a Hadoop cluster.” Kabir types jps on her machine. The only Java process listed is Jps itself.
No NameNode, no DataNode. So where did your job run?
But it worked… it even wrote _SUCCESS.
It worked in standalone mode. Out of the box, Hadoop runs the whole job inside one Java process and reads plain files from your Linux folder. No HDFS, no YARN, no daemons. Perfect for checking that your MapReduce logic is right; useless for big data.
Then how do I get the real thing?
Change three settings and Hadoop starts every daemon on your own laptop, each in its own Java process: pseudo-distributed mode. It behaves like a cluster with one node. And when the same settings point to other machines, with a list of workers, it's fully distributed, like the clusters at work. One download, three modes. Today you'll run all three and see exactly what changes.
Hadoop's three run modes
Hadoop can run in three modes. Standalone (local) mode is the default after unpacking: Hadoop runs as a single Java process, uses the local file system (fs.defaultFS = file:///) and runs MapReduce with the local job runner (mapreduce.framework.name = local); no daemons are started. Pseudo-distributed mode runs every daemon on one machine, each in a separate JVM, with HDFS (fs.defaultFS = hdfs://localhost:9000, dfs.replication = 1) and YARN (mapreduce.framework.name = yarn), simulating a one-node cluster. Fully distributed mode runs the master daemons and worker daemons on separate machines, with configuration pointing to the master hosts, a workers file listing the worker hosts, and normal replication (default 3). This is the mode used in production.
Standalone: Hadoop as a simple program on your files, for testing code. Pseudo-distributed: a full, tiny cluster on one computer, for learning. Fully distributed: a real cluster on many computers, for work.
Words you'll meet in this lesson
jps lists them.file:/// (local disk) or hdfs://host:port.etc/hadoop/workers: one host name per line; the start scripts start DataNodes and NodeManagers there.hdfs namenode -format: creates an empty HDFS namespace. Done once per new cluster.The settings that decide the mode (Hadoop 3.5.0)
| fs.defaultFS | Standalone file:/// (default) · Pseudo hdfs://localhost:9000 · Fully hdfs://<namenode-host>:8020 |
|---|---|
| mapreduce.framework.name | Standalone local (default) · Pseudo and fully yarn |
| dfs.replication | Default 3 · Pseudo 1 (there is only one DataNode) · Fully 3 |
| workers file | Default localhost · Fully: one worker host name per line |
| Verified with | hdfs getconf -confKey … on a real install (output in Part 4) |
Modes at three levels
Beginner A cricket match three ways
- Standalone is practising alone in the nets: you check your shots, but it isn't a match.
- Pseudo-distributed is a match where one person plays every position, running from bowler to keeper. All the rules apply, just on one body.
- Fully distributed is a real team: each player on their own position, and if one gets injured, a substitute comes in.
Intermediate What actually changes
- Standalone:
hadoop jar …readsinput/from your Linux folder, runs all tasks in one JVM, and writesoutput/back to the Linux folder. - Pseudo: you edit
core-site.xml,hdfs-site.xml,mapred-site.xml,yarn-site.xml; format the NameNode; runstart-dfs.shandstart-yarn.sh; files now live in HDFS and jobs go through YARN. - Fully: the same files point to the master's host name instead of
localhost; theworkersfile lists the workers; the same configuration is copied to every node. - The commands you type (
hdfs dfs -put,hadoop jar) are the same in pseudo and fully distributed modes.
Advanced Details that catch people out
- In standalone mode,
hadoop fs -ls /lists your Linux root folder, because the default file system isfile:///. - Pseudo mode needs
dfs.replication = 1: with the default 3 and one DataNode, every block would be reported as under-replicated. - Without settings, the NameNode keeps its data in
/tmp/hadoop-<user>, which may be cleaned on reboot. Setdfs.namenode.name.diranddfs.datanode.data.dirfor anything you want to keep. - Fully distributed on one physical machine is possible with containers (Docker) or VMs: each container is a separate “machine” with its own host name and IP.
- Unit tests often use a MiniDFSCluster / MiniYARNCluster: an in-process mini cluster, a fourth “mode” used only by developers.
Exam tip: For “Explain the modes of Hadoop installation”, draw a three-column table: standalone (single JVM, local FS, no daemons, for debugging), pseudo-distributed (all daemons on one machine in separate JVMs, HDFS replication 1, for learning/testing), fully distributed (masters and workers on separate machines, replication 3, for production). Add the key property that changes: fs.defaultFS.
The three modes side by side
| Standalone (local) | Pseudo-distributed | Fully distributed | |
|---|---|---|---|
| Machines | 1 | 1 | Many (or many containers) |
| Java processes | 1 (only while a job runs) | One per daemon: 5–6 | Masters on their own nodes; DataNode + NodeManager on each worker |
| File system | Local Linux files | HDFS (one DataNode) | HDFS (many DataNodes) |
| Job runs on | LocalJobRunner | YARN | YARN |
| Replication | Not used | 1 | 3 (default) |
| SSH needed? | No | Yes, to localhost (for start scripts) | Yes, master to every worker (or a cluster manager) |
| Fault tolerance | None | None: one node | Yes: lose a node, keep the data |
| Used for | Debugging map/reduce logic | Learning, demos, small tests | Production |
Ways people get each mode
Unpack and run
Standalone needs nothing but the tarball and Java. The fastest way to test a MapReduce program.
StandaloneEdit four XML files
Pseudo-distributed on Ubuntu or WSL: the classic learning setup, and the one in Lesson 4.3.
PseudoDocker Compose
Several containers on one PC, each a “node”: a real multi-node cluster for practice.
Fully (practice)Real servers or cloud VMs
Installed with a cluster manager or automation; this is what companies run.
Fully (production)Whatever mode you think you are in, check with two commands: jps (which daemons are running?) and hdfs getconf -confKey fs.defaultFS (local files or HDFS?).
Run the same job in all three modes
Every output below is from a real run of Hadoop 3.5.0 on Ubuntu 24.04 with OpenJDK 17. Full installation commands are in Lesson 4.3; here we focus on what changes between the modes.
Standalone: run an example job on local files
Thecd ~/hadoop-3.5.0 mkdir input && cp etc/hadoop/*.xml input hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.5.0.jar \ grep input output 'dfs[a-z.]+' cat output/* ls output1 dfsadmin _SUCCESS part-r-00000grepexample counts words matchingdfs[a-z.]+in Hadoop's own XML files.inputandoutputare ordinary Linux folders.Standalone: prove there is no cluster
No daemons. The default file system is the local disk, sojps hdfs getconf -confKey fs.defaultFS hdfs getconf -confKey mapreduce.framework.name hadoop fs -ls /9241 Jps file:/// local drwxr-xr-x - root root 4096 2026-10-21 05:12 /bin drwxr-xr-x - root root 4096 2026-10-21 05:12 /etc drwxr-xr-x - root root 4096 2026-10-21 05:12 /home …hadoop fs -ls /shows the Linux root folder, owned byroot, not an HDFS folder.Pseudo-distributed: change the settings
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://localhost:9000</value> </property> </configuration>These two files are exactly what the official Apache single-node guide uses.<configuration> <property> <name>dfs.replication</name> <value>1</value> </property> </configuration>mapred-site.xmlandyarn-site.xml(to run jobs on YARN) are shown in Lesson 4.3 and explained in Lesson 4.4.Pseudo-distributed: format and start
Five daemons, five JVMs, one machine (here namedhdfs namenode -format start-dfs.sh start-yarn.sh jpsStorage directory /tmp/hadoop-riya/dfs/name has been successfully formatted. Starting namenodes on [localhost] Starting datanodes Starting secondary namenodes [vm] Starting resourcemanager Starting nodemanagers 5584 SecondaryNameNode 5283 NameNode 6567 Jps 6120 ResourceManager 5384 DataNode 6221 NodeManagervm). The numbers are process IDs and will differ on your machine.Pseudo-distributed: same job, now on HDFS and YARN
The job now runs through YARN (it has a job ID). The result has a second line,hdfs getconf -confKey fs.defaultFS hdfs getconf -confKey dfs.replication hdfs dfs -mkdir -p /user/riya/input hdfs dfs -put etc/hadoop/*.xml input hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.5.0.jar \ grep input output 'dfs[a-z.]+' hdfs dfs -cat output/*hdfs://localhost:9000 1 … INFO mapreduce.Job: Job job_1792559666229_0001 completed successfully … 1 dfsadmin 1 dfs.replicationdfs.replication, because thehdfs-site.xmlyou just edited is one of the input files: the data changed, not the program.Fully distributed: many nodes
Three DataNodes, each a separate container with its own IP address, and replication back to 3. On real servers the only difference is that each DataNode is a separate computer, listed in thedocker compose up -d --scale datanode=3 docker compose exec namenode hdfs dfsadmin -printTopology docker compose exec namenode hdfs getconf -confKey dfs.replicationRack: /default-rack 172.18.0.4:9866 (mpcluster-datanode-1.mpcluster_default) In Service 172.18.0.6:9866 (mpcluster-datanode-3.mpcluster_default) In Service 172.18.0.7:9866 (mpcluster-datanode-2.mpcluster_default) In Service 3workersfile.
hdfs namenode -format erases the HDFS namespace. Run it once when you create a cluster, never on a cluster that holds data you need.
From one process to a cluster
On the left, the real terminal output at each step. On the right, the processes and machines behind it.
- Standalone. The example job runs and prints a result. It looks like Hadoop is “working”.
- But
jpsshows no daemons, and the default file system isfile:///: the job ran as one ordinary program on local files. - Pseudo-distributed. Two settings change: HDFS on
localhost:9000and replication 1. Then a one-time format. - The start scripts launch five daemons.
jpsnow lists each one as a separate Java process. - The same job runs through YARN, reading and writing HDFS. (The extra result line comes from the edited
hdfs-site.xmlin the input.) - Fully distributed. On the Docker practice cluster, three DataNodes report in, each on its own address.
- One Java process reads
input/from the Linux disk, runs map and reduce inside itself, and writesoutput/. - Nothing keeps running afterwards. There is no HDFS to store data in and no YARN to schedule work.
- The configuration now points to HDFS on this machine. Formatting creates an empty namespace for the NameNode.
- HDFS daemons and YARN daemons start, each in its own JVM. It is a real cluster, with exactly one node.
- YARN runs the job in containers. With replication 1, each block exists once, so there is no protection against a disk failure.
- Masters and workers live on separate machines (here, containers with separate IPs). Replication 3 spreads every block over three nodes.
Try it yourself: from one node to many
The playground starts as a one-node cluster, like pseudo-distributed mode, with replication 1. Break it, then grow it and see what changes.
Which mode, where?
1. Developers test logic locally
Before a MapReduce or Spark job reaches the cluster, developers run it in local mode on a small sample, often inside automated tests. Bugs in the logic show up in seconds, without waiting for a cluster.
2. Integration tests on a one-node cluster
Build pipelines start a pseudo-distributed cluster or an in-process mini cluster, run the job end to end against real HDFS and YARN APIs, check the output, and shut it down.
3. Multi-node clusters in containers
Teams use Docker Compose or Kubernetes to start throw-away multi-node clusters for development and training. The Apache Hadoop project itself publishes the apache/hadoop images used in this course.
4. Production: always fully distributed
Companies run several fully distributed clusters: a small one for development, one for testing upgrades, and the large production cluster. Changes move through them in that order.
Simplified; organisations differ in tools and policies.
Work out the mode from the settings
The mode is decided by a few configuration values. This function reads them (here typed in as dictionaries, exactly as hdfs getconf printed them on our three test machines) and names the mode.
def mode(conf):
fs = conf.get("fs.defaultFS", "file:///")
if fs.startswith("file:"):
return "standalone"
host = fs.split("//")[1].split(":")[0]
if host in ("localhost", "127.0.0.1"):
return "pseudo-distributed"
return "fully distributed (NameNode on " + host + ")"
machines = {
"fresh unpack": {},
"Riya's WSL": {"fs.defaultFS": "hdfs://localhost:9000", "dfs.replication": "1"},
"Docker cluster": {"fs.defaultFS": "hdfs://namenode", "dfs.replication": "3"},
}
for name, conf in machines.items():
print(f"{name:15} -> {mode(conf)}")fs = conf.get("fs.defaultFS", "file:///")If the setting is missing, Hadoop uses its default:file:///, the local disk. That is why a fresh unpack is standalone.host = fs.split("//")[1].split(":")[0]hdfs://localhost:9000→ after//islocalhost:9000→ before:islocalhost."Docker cluster": {"fs.defaultFS": "hdfs://namenode", "dfs.replication": "3"},No port means the default NameNode RPC port, 8020.
Run it on your machine: which mode am I in?
This script asks Hadoop for its settings and lists the running daemons, then names the mode. Save it as which_mode.sh (Hadoop's bin must be on your PATH). The three outputs below are from real runs.
Standalone: a fresh unpack
#!/usr/bin/env bash
# which_mode.sh: which Hadoop mode is this machine in?
fs=$(hdfs getconf -confKey fs.defaultFS 2>/dev/null)
fw=$(hdfs getconf -confKey mapreduce.framework.name 2>/dev/null)
daemons=$(jps | awk '$2 != "Jps" {print $2}' | sort | tr '\n' ' ')
echo "fs.defaultFS : $fs"
echo "mapreduce.framework.name : $fw"
echo "daemons on this machine : ${daemons:-none}"
case "$fs" in
file:*) echo "MODE: standalone (local files, no daemons)" ;;
hdfs://localhost*|hdfs://127.0.0.1*) echo "MODE: pseudo-distributed (every daemon on this machine)" ;;
hdfs://*) echo "MODE: fully distributed (NameNode at ${fs#hdfs://})" ;;
esac
# In the terminal:
# bash which_mode.shNothing configured, nothing running. Jobs still work, inside one JVM, on local files.
Pseudo-distributed: after start-dfs.sh and start-yarn.sh
start-dfs.sh
start-yarn.sh
bash which_mode.shFive daemons on one machine. Your machine name will appear instead of vm.
Fully distributed: on the Docker practice cluster
docker cp which_mode.sh mpcluster-namenode-1:/tmp/
docker exec mpcluster-namenode-1 bash /tmp/which_mode.sh
docker cp which_mode.sh mpcluster-datanode-1:/tmp/
docker exec mpcluster-datanode-1 bash /tmp/which_mode.shEach container runs only its own role: the master container has just the NameNode, a worker container has just a DataNode. The cluster is set up in Lesson 4.3.
Deciding the mode, one line at a time
Follow Riya's pseudo-distributed setting through the function and watch how the host name is cut out of the address.
Worked examples: real problems, solved and traced in memory
Three questions people really answer when choosing or checking a mode: what fits on a laptop, what a one-node cluster risks, and how to check that every node of a real cluster has the same configuration. Each runs live and is traced in memory.
Can my laptop run pseudo-distributed mode?
Problem statement
In pseudo-distributed mode, give each of the five daemons 1 GB of heap, keep 2 GB for the operating system and the WSL/IDE, and allow 1 GB per task container. For laptops with 8 GB and 16 GB of RAM, how many containers can run at once?
5 daemons × 1 GB · OS 2 GB · 1 GB per container · 8 GB and 16 GB
8 GB laptop: 1 GB free -> 1 container(s) at once 16 GB laptop: 9 GB free -> 9 container(s) at once
Approach
- Fixed memory = daemons + OS.
- Free memory = RAM − fixed.
- Containers = whole GB left.
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.
What does replication 1 really risk?
Problem statement
A team keeps 2 TB of test data on a pseudo-distributed node (replication 1, one disk). Assume a disk has a 2% chance of failing in a year. Compare the chance of losing data within a year with a 3-node cluster at replication 3, assuming failures are independent and a failed disk is replaced and re-replicated within a day.
2% yearly disk failure · one disk vs three copies · repair within 1 day
replication 1: 2.00% chance of loss per year replication 3: 0.00000002% chance of loss per year about 111,020,833 times safer
Approach
- One copy: data is lost if that one disk fails: 2%.
- Three copies: all three must fail within the same day of repair. Per-day failure chance = 2% / 365.
- Approximate: first failure (about 3 × 2% in a year), then both others fail the same day.
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.
Do all nodes have the same configuration?
Problem statement
In fully distributed mode, every node must have the same core settings. A script collected fs.defaultFS and dfs.replication from four nodes. Find the nodes that differ from the majority.
nn1, dn1, dn3: hdfs://nn1:8020, 3 · dn2: hdfs://localhost:9000, 1
expected: ('hdfs://nn1:8020', '3') (3 of 4 nodes)
MISMATCH on dn2 -> ('hdfs://localhost:9000', '1')Approach
- Build one key per node from the settings.
- Count how many nodes share each key; the most common is the expected one.
- Report every node whose key differs.
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.2 in one screen
- Standalone: default; one JVM; local files (
file:///); no daemons; for debugging. - Pseudo-distributed: all daemons on one machine, each its own JVM; HDFS + YARN; replication 1; for learning.
- Fully distributed: masters and workers on separate machines; replication 3; for production.
- Mode settings:
fs.defaultFS,mapreduce.framework.name,dfs.replication,workersfile. - Pseudo:
hdfs://localhost:9000; fully:hdfs://<namenode-host>:8020. - Check with
jpsandhdfs getconf -confKey fs.defaultFS. hdfs namenode -formatonce per new cluster: it wipes the namespace.- Docker Compose gives a fully distributed cluster on one PC: each container is a node.
Interview and viva questions
What are the modes of Hadoop?
Standalone (local) mode: a single JVM with the local file system and no daemons, used for debugging. Pseudo-distributed mode: all Hadoop daemons run on one machine in separate JVMs with HDFS and YARN, used for learning and testing. Fully distributed mode: daemons run on separate master and worker machines, used in production.
What is the default mode of Hadoop?
Standalone (local) mode. Without configuration, fs.defaultFS is file:/// and mapreduce.framework.name is local.
What is the difference between standalone and pseudo-distributed mode?
Standalone runs everything inside one Java process on local files, with no HDFS or YARN. Pseudo-distributed runs the real daemons (NameNode, DataNode, ResourceManager, NodeManager…) as separate processes on one machine, so jobs use HDFS and YARN just as on a cluster.
Which configuration files change between modes?
core-site.xml (fs.defaultFS), hdfs-site.xml (dfs.replication and storage folders), mapred-site.xml (mapreduce.framework.name=yarn) and yarn-site.xml (ResourceManager host, shuffle service), plus the workers file for fully distributed mode.
Can I run fully distributed mode on one laptop?
Yes, with containers or virtual machines: each container or VM is a separate node with its own host name and IP. The Docker practice cluster in Lesson 4.3 does exactly this.
Why do I need to format the NameNode?
Formatting creates an empty HDFS namespace (the fsimage and a new cluster ID) in the NameNode's storage folder. It is done once when creating a cluster; formatting again erases the namespace and makes existing DataNodes incompatible.
Is pseudo-distributed mode fault tolerant?
No. There is one DataNode and one copy of each block, so a disk failure loses data and a crash stops everything.
Practice problems
Short exercises on reading settings, counting daemons and checking configurations, all runnable in the browser.
Local or HDFS?
For each fs.defaultFS value, print "local files" or "HDFS".
file:/// · hdfs://localhost:9000 · hdfs://namenode
file:/// -> local files hdfs://localhost:9000 -> HDFS hdfs://namenode -> HDFS
Show solution and explanation
for fs in ["file:///", "hdfs://localhost:9000", "hdfs://namenode"]:
print(fs, "->", "local files" if fs.startswith("file:") else "HDFS")How it works: Only file:/// is the local disk; both hdfs:// values use HDFS.
Port or default?
Print the NameNode port for hdfs://localhost:9000 and hdfs://namenode (the default RPC port is 8020).
hdfs://localhost:9000 · hdfs://namenode
hdfs://localhost:9000 -> port 9000 hdfs://namenode -> port 8020
Show solution and explanation
for fs in ["hdfs://localhost:9000", "hdfs://namenode"]:
hostport = fs.split("//")[1]
port = hostport.split(":")[1] if ":" in hostport else "8020"
print(fs, "-> port", port)How it works: 9000 is written explicitly in the pseudo setup; without a port, Hadoop uses 8020.
Name the daemons
Given the jps output of a pseudo-distributed machine, list the daemons (skip Jps itself).
5584 SecondaryNameNode · 5283 NameNode · 6567 Jps · 6120 ResourceManager · 5384 DataNode · 6221 NodeManager
5 daemons: DataNode, NameNode, NodeManager, ResourceManager, SecondaryNameNode
Show solution and explanation
jps = """5584 SecondaryNameNode
5283 NameNode
6567 Jps
6120 ResourceManager
5384 DataNode
6221 NodeManager"""
names = sorted(line.split()[1] for line in jps.splitlines() if not line.endswith(" Jps"))
print(len(names), "daemons:", ", ".join(names))How it works: 5 daemons: DataNode, NameNode, NodeManager, ResourceManager, SecondaryNameNode (the real jps output from Part 4).
Guess the mode from jps
Write a function that guesses the mode from the set of daemons on a machine: none → standalone; NameNode and DataNode together → pseudo-distributed; otherwise → part of a fully distributed cluster.
{} · {NameNode, DataNode, …} · {DataNode, NodeManager}[] -> standalone ['DataNode', 'NameNode', 'ResourceManager'] -> pseudo-distributed ['DataNode', 'NodeManager'] -> node of a fully distributed cluster
Show solution and explanation
def guess(daemons):
if not daemons:
return "standalone"
if {"NameNode", "DataNode"} <= daemons:
return "pseudo-distributed"
return "node of a fully distributed cluster"
for d in [set(), {"NameNode", "DataNode", "ResourceManager"}, {"DataNode", "NodeManager"}]:
print(sorted(d), "->", guess(d))How it works: A worker of a real cluster runs only DataNode and NodeManager; seeing the NameNode and a DataNode together on one machine suggests pseudo mode (small real clusters sometimes do this too, so check fs.defaultFS).
Raw disk for 3 copies
A team will store 4 TB of data. How much raw disk is needed with replication 1 (pseudo) and replication 3 (fully), keeping 25% of the disk free?
4 TB · replication 1 and 3 · 25% free
replication 1: 5.3 TB raw disk replication 3: 16.0 TB raw disk
Show solution and explanation
data = 4
for repl in [1, 3]:
raw = data * repl / 0.75
print(f"replication {repl}: {raw:.1f} TB raw disk")How it works: About 5.3 TB with one copy and 16 TB with three. Replication triples the disk you buy.
Pseudo to fully: what to change
Given a pseudo-distributed configuration, produce the fully distributed one for a NameNode host nn1 and 3 workers.
fs.defaultFS=hdfs://localhost:9000 · dfs.replication=1 · workers=localhost
fs.defaultFS : hdfs://localhost:9000 -> hdfs://nn1:8020 dfs.replication : 1 -> 3 workers : ['localhost'] -> ['worker1', 'worker2', 'worker3']
Show solution and explanation
pseudo = {"fs.defaultFS": "hdfs://localhost:9000", "dfs.replication": "1", "workers": ["localhost"]}
fully = dict(pseudo)
fully["fs.defaultFS"] = "hdfs://nn1:8020"
fully["dfs.replication"] = "3"
fully["workers"] = ["worker1", "worker2", "worker3"]
for k in pseudo:
print(f"{k:16}: {pseudo[k]} -> {fully[k]}")How it works: Three things change: the NameNode address, the replication factor and the workers list. The same files are then copied to every node.
Time saved by testing locally first
A developer's job has a bug found only after 3 attempts. Each cluster attempt takes 15 minutes (queue + run); a local-mode attempt on sample data takes 1 minute. How much time does testing locally first save if the 3 failing attempts are local and only the final run uses the cluster?
3 failed attempts · 15 min on cluster · 1 min local · 1 final cluster run
cluster only 60 min, local first 18 min, saved 42 min
Show solution and explanation
cluster_only = 4 * 15
local_first = 3 * 1 + 15
print(f"cluster only {cluster_only} min, local first {local_first} min, saved {cluster_only - local_first} min")How it works: 60 minutes against 18: 42 minutes saved per bug, and the shared cluster is not wasted on broken jobs.
Find the misconfigured worker
Workers report the NameNode address they use. List the workers that will not join the cluster whose NameNode is hdfs://nn1:8020.
w1: hdfs://nn1:8020 · w2: hdfs://localhost:9000 · w3: hdfs://nn1:8020 · w4: file:///
will not join: ['w2', 'w4']
Show solution and explanation
expected = "hdfs://nn1:8020"
workers = {"w1": "hdfs://nn1:8020", "w2": "hdfs://localhost:9000",
"w3": "hdfs://nn1:8020", "w4": "file:///"}
bad = [w for w, fs in workers.items() if fs != expected]
print("will not join:", bad)How it works: w2 looks for a NameNode on itself and w4 has no HDFS setting at all (standalone defaults), so neither registers with nn1.
Real-world scenario questions (asked in company interviews)
Interviewers use the modes to check whether you understand what a cluster really is, not just the names.
“My job ran, so my Hadoop cluster works”
A fresher says they installed Hadoop and ran the example job successfully. When asked, jps shows only “Jps”.
The interviewer is checking: can you tell standalone mode from a real cluster?
Show a strong answer
- The job ran in standalone mode: one JVM, local files, no HDFS or YARN.
- Proof: no daemons in
jps, andhdfs getconf -confKey fs.defaultFSprintsfile:///. - For a one-node cluster, set
fs.defaultFS=hdfs://localhost:9000,dfs.replication=1, YARN settings, format the NameNode, thenstart-dfs.shandstart-yarn.sh.
Every block is under-replicated on the test machine
On a single-machine setup, hdfs fsck / reports all blocks as under-replicated.
The interviewer is checking: do you connect replication to the number of DataNodes?
Show a strong answer
- Replication is probably still the default 3 while there is only one DataNode.
- Set
dfs.replication=1inhdfs-site.xmlfor new files, and change existing files withhdfs dfs -setrep -w 1 /path. - Explain that this is only acceptable for test data: one copy means no protection.
A new DataNode never appears in the NameNode UI
You add a fourth worker to a fully distributed cluster. Its DataNode process is running, but the NameNode still shows 3 live DataNodes.
The interviewer is checking: a systematic check of configuration and connectivity.
Show a strong answer
- On the new node, check
hdfs getconf -confKey fs.defaultFS: a leftoverlocalhostvalue (pseudo config) is common. - Check that the NameNode host name resolves and port 8020 is reachable from the worker.
- Read the DataNode log in
$HADOOP_HOME/logsfor errors such as “Incompatible clusterIDs” (an old data folder from another cluster). - Make sure the host is in the
workersfile (and in any include file) and the configuration is the same as on other nodes.
Which mode would you use for which stage?
A team lead asks how you would test a new MapReduce job before it runs on the production cluster.
The interviewer is checking: do you know the purpose of each mode?
Show a strong answer
- Unit tests in local mode on small samples: fast feedback on logic.
- Integration tests on a one-node or mini cluster: real HDFS and YARN APIs, file formats and configuration.
- A run on a fully distributed test cluster with realistic data size, then production.
- Each stage catches different problems: logic, integration, then scale and performance.