Standalone, pseudo-distributed and fully distributed modes

The Hadoop you download can run as a simple local program, as a one-machine cluster, or as a real multi-machine cluster. Which one you get depends on a handful of settings. This lesson runs the same job in all three modes on a real Hadoop 3.5.0 install, shows what jps and the configuration report in each, and explains when each mode is used at work.

Module 4 · Setup⏱ 24 minBeginnerReal Hadoop 3.5.0 outputCluster PlaygroundRuns in your browser (Python)8 practice problems
1 The story

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.

Standalone 1 Java process local files, no HDFSno daemons, no YARN Pseudo-distributed NameNode · DataNodeSecondaryNameNodeResourceManagerNodeManager all daemons on one machine Fully distributed masters worker 1 worker 2 worker 3 daemons spread over machines Same files, same commands. Only a few configuration values decide the mode. myphatshala.in
Kabir

No NameNode, no DataNode. So where did your job run?

Riya

But it worked… it even wrote _SUCCESS.

Arjun Sir

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.

Riya

Then how do I get the real thing?

Arjun Sir

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.

2 Definition

Hadoop's three run modes

Formal definition (write this in exams)

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.

In simple words

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

ModeHow Hadoop is set up to run: local, one-machine cluster, or many-machine cluster.
DaemonA long-running background process, e.g. NameNode or NodeManager. Each Hadoop daemon is its own JVM.
JVMJava Virtual Machine: one running Java program. jps lists them.
fs.defaultFSThe default file system: file:/// (local disk) or hdfs://host:port.
LocalJobRunnerRuns map and reduce tasks inside the same single process, used in standalone mode.
workers fileetc/hadoop/workers: one host name per line; the start scripts start DataNodes and NodeManagers there.
Formathdfs namenode -format: creates an empty HDFS namespace. Done once per new cluster.
jpsLists running Java processes. The quickest way to see which mode you are really in.

The settings that decide the mode (Hadoop 3.5.0)

fs.defaultFSStandalone file:/// (default) · Pseudo hdfs://localhost:9000 · Fully hdfs://<namenode-host>:8020
mapreduce.framework.nameStandalone local (default) · Pseudo and fully yarn
dfs.replicationDefault 3 · Pseudo 1 (there is only one DataNode) · Fully 3
workers fileDefault localhost · Fully: one worker host name per line
Verified withhdfs getconf -confKey … on a real install (output in Part 4)

Modes at three levels

Pick your level. New to this? Start at Beginner and climb.

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 … reads input/ from your Linux folder, runs all tasks in one JVM, and writes output/ back to the Linux folder.
  • Pseudo: you edit core-site.xml, hdfs-site.xml, mapred-site.xml, yarn-site.xml; format the NameNode; run start-dfs.sh and start-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; the workers file 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 is file:///.
  • 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. Set dfs.namenode.name.dir and dfs.datanode.data.dir for 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.

3 Types and ways to use it

The three modes side by side

Standalone (local)Pseudo-distributedFully distributed
Machines11Many (or many containers)
Java processes1 (only while a job runs)One per daemon: 5–6Masters on their own nodes; DataNode + NodeManager on each worker
File systemLocal Linux filesHDFS (one DataNode)HDFS (many DataNodes)
Job runs onLocalJobRunnerYARNYARN
ReplicationNot used13 (default)
SSH needed?NoYes, to localhost (for start scripts)Yes, master to every worker (or a cluster manager)
Fault toleranceNoneNone: one nodeYes: lose a node, keep the data
Used forDebugging map/reduce logicLearning, demos, small testsProduction

Ways people get each mode

Unpack and run

Standalone needs nothing but the tarball and Java. The fastest way to test a MapReduce program.

Standalone

Edit four XML files

Pseudo-distributed on Ubuntu or WSL: the classic learning setup, and the one in Lesson 4.3.

Pseudo

Docker 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?).

4 Step by step

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.

  1. Standalone: run an example job on local files

    cd ~/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 output
    1 dfsadmin _SUCCESS part-r-00000
    The grep example counts words matching dfs[a-z.]+ in Hadoop's own XML files. input and output are ordinary Linux folders.
  2. Standalone: prove there is no cluster

    jps
    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 …
    No daemons. The default file system is the local disk, so hadoop fs -ls / shows the Linux root folder, owned by root, not an HDFS folder.
  3. Pseudo-distributed: change the settings

    <configuration>
        <property>
            <name>fs.defaultFS</name>
            <value>hdfs://localhost:9000</value>
        </property>
    </configuration>
    <configuration>
        <property>
            <name>dfs.replication</name>
            <value>1</value>
        </property>
    </configuration>
    These two files are exactly what the official Apache single-node guide uses. mapred-site.xml and yarn-site.xml (to run jobs on YARN) are shown in Lesson 4.3 and explained in Lesson 4.4.
  4. Pseudo-distributed: format and start

    hdfs namenode -format
    start-dfs.sh
    start-yarn.sh
    jps
    Storage 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 NodeManager
    Five daemons, five JVMs, one machine (here named vm). The numbers are process IDs and will differ on your machine.
  5. Pseudo-distributed: same job, now on HDFS and YARN

    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.replication
    The job now runs through YARN (it has a job ID). The result has a second line, dfs.replication, because the hdfs-site.xml you just edited is one of the input files: the data changed, not the program.
  6. Fully distributed: many nodes

    docker compose up -d --scale datanode=3
    docker compose exec namenode hdfs dfsadmin -printTopology
    docker compose exec namenode hdfs getconf -confKey dfs.replication
    Rack: /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 3
    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 the workers file.

hdfs namenode -format erases the HDFS namespace. Run it once when you create a cluster, never on a cluster that holds data you need.

5 See it happen

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 → pseudo → fully distributed 6 steps
What you see riya@vm : ~/hadoop-3.5.0 $ hadoop jar …examples-3.5.0.jar \ grep input output 'dfs[a-z.]+'$ cat output/*1 dfsadmin $ jps9241 Jps$ hdfs getconf -confKey fs.defaultFSfile:///No daemons, local files. $ nano etc/hadoop/core-site.xml fs.defaultFS = hdfs://localhost:9000$ nano etc/hadoop/hdfs-site.xml dfs.replication = 1$ hdfs namenode -format… successfully formatted. $ start-dfs.sh ; start-yarn.sh ; jps5283 NameNode5384 DataNode5584 SecondaryNameNode6120 ResourceManager6221 NodeManager6567 Jps $ hadoop jar … grep input output …Job job_…_0001 completed successfully$ hdfs dfs -cat output/*1 dfsadmin1 dfs.replication $ hdfs dfsadmin -printTopologyRack: /default-rack 172.18.0.4:9866 (…datanode-1) In Service 172.18.0.6:9866 (…datanode-3) In Service 172.18.0.7:9866 (…datanode-2) In ServiceThree DataNodes, three addresses. myphatshala.in
Behind the screen Riya's machine one JVMmap + reduce inside Linux diskinput/ output/ the program reads and writes ordinary folders no NameNode, no DataNode, no YARNthe JVM exits when the job ends Riya's machine (localhost) HDFS YARN empty namespace(formatted)not startedsettings now point to hdfs://localhost:9000 NameNode · DataNodeSecondaryNameNodeResourceManagerNodeManager 5 daemons = 5 separate JVMsall on one machine, talking over localhost job container1 copy of each block: lose the disk, lose the data mastersNameNodeResourceManager datanode-1172.18.0.4 datanode-2172.18.0.7 datanode-3172.18.0.6 each block stored on 3 nodeslose a node, keep the data myphatshala.in

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.

6 Real-world use

Which mode, where?

local modeunit tests

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.

Sample data→Local run in tests→Then the cluster
CI pipelinemini 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.

Code change→One-node cluster test→Merge
containers

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.

One laptop→Many containers→Real distributed behaviour
dev · testprodall fully distributed

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.

Dev cluster→Test cluster→Production

Simplified; organisations differ in tools and policies.

7 Run the code

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)}")
fresh unpack -> standalone Riya's WSL -> pseudo-distributed Docker cluster -> fully distributed (NameNode on namenode)
  • 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 // is localhost:9000 → before : is localhost.
  • "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.sh
fs.defaultFS : file:/// mapreduce.framework.name : local daemons on this machine : none MODE: standalone (local files, no daemons)

Nothing 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.sh
Starting namenodes on [localhost] Starting datanodes Starting secondary namenodes [vm] Starting resourcemanager Starting nodemanagers fs.defaultFS : hdfs://localhost:9000 mapreduce.framework.name : yarn daemons on this machine : DataNode NameNode NodeManager ResourceManager SecondaryNameNode MODE: pseudo-distributed (every daemon on this machine)

Five 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.sh
fs.defaultFS : hdfs://namenode mapreduce.framework.name : yarn daemons on this machine : NameNode MODE: fully distributed (NameNode at namenode) fs.defaultFS : hdfs://namenode mapreduce.framework.name : yarn daemons on this machine : DataNode MODE: fully distributed (NameNode at namenode)

Each 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.

8 Line by line

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.

Example 1BeginnerLearning · resources

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?

Input
5 daemons × 1 GB · OS 2 GB · 1 GB per container · 8 GB and 16 GB
Expected output
8 GB laptop: 1 GB free -> 1 container(s) at once
16 GB laptop: 9 GB free -> 9 container(s) at once

Approach

  1. Fixed memory = daemons + OS.
  2. Free memory = RAM − fixed.
  3. 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.

Example 2IntermediateRisk · data safety

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.

Input
2% yearly disk failure · one disk vs three copies · repair within 1 day
Expected output
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

  1. One copy: data is lost if that one disk fails: 2%.
  2. Three copies: all three must fail within the same day of repair. Per-day failure chance = 2% / 365.
  3. 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.

Example 3AdvancedAdmin · consistency

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.

Input
nn1, dn1, dn3: hdfs://nn1:8020, 3 · dn2: hdfs://localhost:9000, 1
Expected output
expected: ('hdfs://nn1:8020', '3') (3 of 4 nodes)
MISMATCH on dn2 -> ('hdfs://localhost:9000', '1')

Approach

  1. Build one key per node from the settings.
  2. Count how many nodes share each key; the most common is the expected one.
  3. 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.

9 Quiz and revision

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, workers file.
  • Pseudo: hdfs://localhost:9000; fully: hdfs://<namenode-host>:8020.
  • Check with jps and hdfs getconf -confKey fs.defaultFS.
  • hdfs namenode -format once 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.

P1Easy

Local or HDFS?

For each fs.defaultFS value, print "local files" or "HDFS".

Input
file:/// · hdfs://localhost:9000 · hdfs://namenode
Expected output
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")
file:/// -> local files hdfs://localhost:9000 -> HDFS hdfs://namenode -> HDFS

How it works: Only file:/// is the local disk; both hdfs:// values use HDFS.

P2Easy

Port or default?

Print the NameNode port for hdfs://localhost:9000 and hdfs://namenode (the default RPC port is 8020).

Input
hdfs://localhost:9000 · hdfs://namenode
Expected output
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)
hdfs://localhost:9000 -> port 9000 hdfs://namenode -> port 8020

How it works: 9000 is written explicitly in the pseudo setup; without a port, Hadoop uses 8020.

P3Easy

Name the daemons

Given the jps output of a pseudo-distributed machine, list the daemons (skip Jps itself).

Input
5584 SecondaryNameNode · 5283 NameNode · 6567 Jps · 6120 ResourceManager · 5384 DataNode · 6221 NodeManager
Expected output
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))
5 daemons: DataNode, NameNode, NodeManager, ResourceManager, SecondaryNameNode

How it works: 5 daemons: DataNode, NameNode, NodeManager, ResourceManager, SecondaryNameNode (the real jps output from Part 4).

P4Medium

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.

Input
{} · {NameNode, DataNode, …} · {DataNode, NodeManager}
Expected output
[] -> 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))
[] -> standalone ['DataNode', 'NameNode', 'ResourceManager'] -> pseudo-distributed ['DataNode', 'NodeManager'] -> node of a fully distributed cluster

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).

P5Medium

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?

Input
4 TB · replication 1 and 3 · 25% free
Expected output
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")
replication 1: 5.3 TB raw disk replication 3: 16.0 TB raw disk

How it works: About 5.3 TB with one copy and 16 TB with three. Replication triples the disk you buy.

P6Medium

Pseudo to fully: what to change

Given a pseudo-distributed configuration, produce the fully distributed one for a NameNode host nn1 and 3 workers.

Input
fs.defaultFS=hdfs://localhost:9000 · dfs.replication=1 · workers=localhost
Expected output
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]}")
fs.defaultFS : hdfs://localhost:9000 -> hdfs://nn1:8020 dfs.replication : 1 -> 3 workers : ['localhost'] -> ['worker1', 'worker2', 'worker3']

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.

P7Business problem

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?

Input
3 failed attempts · 15 min on cluster · 1 min local · 1 final cluster run
Expected output
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")
cluster only 60 min, local first 18 min, saved 42 min

How it works: 60 minutes against 18: 42 minutes saved per bug, and the shared cluster is not wasted on broken jobs.

P8Advanced

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.

Input
w1: hdfs://nn1:8020 · w2: hdfs://localhost:9000 · w3: hdfs://nn1:8020 · w4: file:///
Expected output
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)
will not join: ['w2', 'w4']

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.

Learning · conceptsFresher

“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, and hdfs getconf -confKey fs.defaultFS prints file:///.
  • For a one-node cluster, set fs.defaultFS=hdfs://localhost:9000, dfs.replication=1, YARN settings, format the NameNode, then start-dfs.sh and start-yarn.sh.
Admin · HDFSFresher

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=1 in hdfs-site.xml for new files, and change existing files with hdfs dfs -setrep -w 1 /path.
  • Explain that this is only acceptable for test data: one copy means no protection.
Admin · cluster buildExperienced

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 leftover localhost value (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/logs for errors such as “Incompatible clusterIDs” (an old data folder from another cluster).
  • Make sure the host is in the workers file (and in any include file) and the configuration is the same as on other nodes.
Engineering · testingExperienced

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.