Configuration files and web UIs

Every Hadoop behaviour you will tune later, from replication to task memory, is a configuration property. This lesson explains the layers those properties come from, which value wins, and how to ask a running daemon what it is really using. It also tours the web UIs and the /conf and /jmx endpoints that engineers open first when something looks wrong. All outputs and screenshots are from a real Hadoop 3.5.0 cluster.

Module 4 · Setup⏱ 28 minBeginner → IntermediateReal cluster outputCluster PlaygroundRuns in your browser (Python)8 practice problems
1 The story

Who decides the value: the jar, the file, or you?

Kabir's Docker cluster has dfs.replication=3 in its settings. He uploads a file with -D dfs.replication=2 and gets 2 copies. Then he marks the setting final, sure it can't be changed now, uploads again with -D dfs.replication=2, and still gets 2. Riya asks: “If a final setting can be changed, what does final even mean?”

1. Built-in defaults: *-default.xml inside the jars (about 1,700 settings) 2. Your site files: etc/hadoop/*-site.xml 3. Client / job: -D name=value the value on top wins overrides Most problems with a setting come down to “which layer did this value come from?” myphatshala.in
Arjun Sir

Think of it in layers. Hadoop ships with a default for every one of its settings, inside its jar files. Your *-site.xml files override those defaults. And a client or job can set a value on top, for its own work, with -D.

Kabir

And final?

Arjun Sir

final protects a value against configuration files loaded later, for example the job.xml that comes with every submitted job. Your -D didn't load a file; it set the value directly in your own client, so it still won. That's exactly what we saw: 2 copies.

Riya

So how do I know which value a daemon is really using?

Arjun Sir

Ask it. Each daemon's web UI has a /conf page that lists every setting and which file it came from. Today: the files in etc/hadoop, the layers, the settings you'll change most, and the web UIs you'll open every day.

2 Definition

Hadoop configuration and web UIs

Formal definition (write this in exams)

Hadoop configuration is a set of name–value properties loaded in layers by the Configuration class: read-only defaults (core-default.xml, hdfs-default.xml, yarn-default.xml, mapred-default.xml, packaged in the jars), then site files in $HADOOP_CONF_DIR (by default $HADOOP_HOME/etc/hadoop: core-site.xml, hdfs-site.xml, yarn-site.xml, mapred-site.xml), then values set by programs or on the command line (-D). A later resource overrides an earlier one unless the earlier one marked the property <final>true</final>. Shell scripts (hadoop-env.sh, yarn-env.sh, mapred-env.sh) set environment variables such as JAVA_HOME and heap sizes; workers lists worker hosts. Each daemon also runs an embedded web server (NameNode 9870, DataNode 9864, ResourceManager 8088, NodeManager 8042, JobHistory Server 19888) with status pages and the /conf, /jmx and /logs endpoints.

In simple words

Hadoop has a default for everything. You change what you need in four XML files. A single command can change a setting just for itself. And every daemon has a web page where you can see its state and the settings it is really using.

Words you'll meet in this lesson

PropertyOne setting: a <name> and a <value> inside <property>.
*-default.xmlHadoop's built-in defaults, inside the jars. Read them, never edit them.
*-site.xmlYour overrides, in etc/hadoop.
HADOOP_CONF_DIRThe folder Hadoop reads site files from. Point it elsewhere to use another configuration.
final<final>true</final>: later configuration files cannot override this property.
-D name=valueSets a property for one command or job only.
/confA daemon's web page listing every property, its value and its source file.
/jmxA daemon's metrics as JSON, used by monitoring tools.

Defaults checked in Hadoop 3.5.0's *-default.xml

fs.defaultFSfile:/// (core-default.xml)
hadoop.tmp.dir/tmp/hadoop-${user.name}; dfs.namenode.name.dir defaults to file://${hadoop.tmp.dir}/dfs/name
dfs.replication · dfs.blocksize3 · 134217728 (128 MB)
dfs.heartbeat.interval3 seconds
mapreduce.framework.namelocal (mapred-default.xml)
NodeManager disk limit90.0% (yarn.nodemanager.disk-health-checker.max-disk-utilization-per-disk-percentage)
Web UI portsNameNode 9870 · SecondaryNameNode 9868 · DataNode 9864 · ResourceManager 8088 · NodeManager 8042 · JobHistory 19888
Other DataNode portsdata transfer 9866 · IPC 9867; NameNode RPC 8020; ResourceManager RPC 8032

Configuration at three levels

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

Beginner School rules, class rules, today's rule

  • The school rulebook (defaults) covers everything: “uniform every day”.
  • Your class teacher (site files) can change some rules for the class: “sports shoes on Friday”.
  • For one event (-D), a rule can change for that day only.
  • A rule marked final by the principal can't be changed by a later notice from a teacher.

Intermediate The files in etc/hadoop

  • core-site.xml: settings shared by everything (default file system, I/O, security).
  • hdfs-site.xml: NameNode and DataNode (replication, block size, storage folders, addresses).
  • yarn-site.xml: ResourceManager and NodeManagers (hosts, memory and cores per node, shuffle service).
  • mapred-site.xml: MapReduce jobs (framework, task memory, history server).
  • hadoop-env.sh / yarn-env.sh / mapred-env.sh: environment (Java, heap sizes, log and PID folders).
  • workers (hosts), capacity-scheduler.xml (YARN queues), log4j.properties (logging).

Advanced Rules that matter in production

  • Server vs client settings: dfs.replication and dfs.blocksize are applied by the client that writes a file; changing the NameNode's file does not change existing files or other clients.
  • Restart to apply: daemons read their site files at start-up. Some settings can be refreshed (hdfs dfsadmin -refreshNodes, yarn rmadmin -refreshQueues); most need a restart.
  • Same files everywhere: every node must have the same configuration; cluster managers push it and track versions.
  • final is for administrators protecting cluster-wide values from job configurations (job.xml), not a lock against code running in the same client.
  • Values can use ${other.property} and ${env.VAR}; units such as 256m or 30s are accepted by many properties.

Exam tip: For “Explain Hadoop configuration files”, list the four site files with one example property each (fs.defaultFS, dfs.replication, yarn.resourcemanager.hostname, mapreduce.framework.name), mention hadoop-env.sh (JAVA_HOME) and workers, and state the rule: site files override the defaults, and final properties cannot be overridden by later resources.

3 Types and ways to use it

Kinds of settings, and the UIs that show them

WhereFormatRead byTypical settings
*-default.xml (in jars)XMLeverythingEvery property with its default; documented online
*-site.xmlXMLdaemons and clientsAddresses, replication, memory, folders
*-env.shShell scriptstart scripts and commandsJAVA_HOME, HADOOP_HEAPSIZE_MAX, log and PID folders
workersOne host per linestart-dfs.sh, start-yarn.shWorker host names
-D on a command-D name=valuethat client or job onlyReplication, block size, job memory, queue
In codeconf.set(…)that programJob-specific settings

The web UIs you'll use

NameNode · 9870

Overview (capacity, live/dead DataNodes, safe mode), Datanodes tab, file browser (Utilities → Browse the file system), logs.

HDFS

ResourceManager · 8088

Applications and their state, nodes, queues and scheduler, links to each job's logs.

YARN

DataNode · 9864, NodeManager · 8042

One worker's own view: its volumes, blocks, containers and logs.

Workers

JobHistory · 19888

Finished MapReduce jobs: counters, tasks, timings. Start it with mapred --daemon start historyserver.

History

Add /conf, /jmx or /logs to any daemon's web address: http://localhost:9870/conf shows every setting the NameNode is using and the file it came from.

4 Step by step

Inspect and change configuration on a running cluster

All outputs are from the Docker practice cluster of Lesson 4.3 (Hadoop 3.5.0, 3 DataNodes). On the Path A install, drop the docker compose exec namenode prefix.

  1. See the files

    ls $HADOOP_HOME/etc/hadoop
    capacity-scheduler.xml kms-log4j.properties configuration.xsl kms-site.xml container-executor.cfg log4j.properties core-site.xml mapred-env.cmd hadoop-env.cmd mapred-env.sh hadoop-env.sh mapred-queues.xml.template hadoop-metrics2.properties mapred-site.xml hadoop-policy.xml shellprofile.d hadoop-user-functions.sh.example ssl-client.xml.example hdfs-rbf-site.xml ssl-server.xml.example hdfs-site.xml user_ec_policies.xml.template httpfs-env.sh workers httpfs-log4j.properties yarn-env.cmd httpfs-site.xml yarn-env.sh kms-acls.xml yarn-site.xml kms-env.sh yarnservice-log4j.properties
    32 entries ship in etc/hadoop. The four site files, the env scripts and workers are the ones you'll edit; the rest configure optional services (KMS, HttpFS, router-based federation).
  2. Ask for the value Hadoop really uses

    docker compose exec namenode hdfs getconf -confKey fs.defaultFS
    docker compose exec namenode hdfs getconf -confKey dfs.replication
    docker compose exec namenode hdfs getconf -confKey dfs.blocksize
    docker compose exec namenode hdfs getconf -confKey dfs.namenode.http-address
    docker compose exec namenode hdfs getconf -confKey dfs.heartbeat.interval
    hdfs://namenode 3 134217728 0.0.0.0:9870 3
    getconf prints the final, merged value: from your site file if set (fs.defaultFS, dfs.replication), otherwise the default (block size, address, heartbeat).
  3. See where each value came from

    curl -s http://localhost:9870/conf | grep -o "<source>[^<]*</source>" | sort | uniq -c | sort -rn
    curl -s http://localhost:9870/conf | grep -o "<property><name>dfs.replication</name>[^/]*</value><final>[a-z]*</final><source>[^<]*</source>"
    542 <source>hdfs-default.xml</source> 523 <source>yarn-default.xml</source> 376 <source>core-default.xml</source> 194 <source>mapred-default.xml</source> 89 <source>hdfs-rbf-default.xml</source> 17 <source>programmatically</source> 5 <source>yarn-site.xml</source> 4 <source>mapred-site.xml</source> 2 <source>hdfs-site.xml</source> <property><name>dfs.replication</name><value>3</value><final>false</final><source>hdfs-site.xml</source>
    The running NameNode knows about 1,750 settings. All but a handful are defaults; only a few come from our site files. “programmatically” means the daemon set the value itself at start-up.
  4. Override for one command with -D

    hdfs dfs -D dfs.replication=2 -put canteen_orders.csv data/copy2.csv
    hdfs dfs -D dfs.blocksize=1048576 -put canteen_orders.csv data/small_blocks.csv
    hdfs dfs -stat "%r %o %b %n" data/*
    hdfs fsck /user/hadoop/data/small_blocks.csv | grep "Total blocks"
    3 134217728 4692009 canteen_orders.csv 2 134217728 4692009 copy2.csv 3 1048576 4692009 small_blocks.csv Total blocks (validated): 5 (avg. block size 938401 B)
    %r = replication, %o = block size, %b = bytes. Same file, three different storage layouts: replication and block size are chosen by the writing client, per file. With 1 MB blocks the 4.5 MB file becomes 5 blocks. (Open a shell with docker compose exec namenode bash; the CSV was copied to /tmp in Lesson 4.3.)
  5. Change an existing file, and test “final”

    hdfs dfs -setrep -w 3 data/copy2.csv
    # a copy of the configuration with dfs.replication marked final
    cp -r /opt/hadoop/etc/hadoop /tmp/fconf
    #   in /tmp/fconf/hdfs-site.xml: <value>3</value><final>true</final>
    HADOOP_CONF_DIR=/tmp/fconf hdfs dfs -D dfs.replication=2 -put canteen_orders.csv data/final_test.csv
    hdfs dfs -stat "%r %n" data/copy2.csv data/final_test.csv
    Replication 3 set: data/copy2.csv Waiting for data/copy2.csv .... done 3 copy2.csv 2 final_test.csv
    -setrep -w changes an existing file and waits until the new copies exist. The second line is the surprise from the story, tested for real: final blocks later configuration files, but -D sets the value directly in the client, so 2 still wins.
  6. Open the web UIs

    In a browser on your PC: http://localhost:9870 (NameNode) and http://localhost:8088 (ResourceManager). Below are the real pages of the practice cluster, cropped.

    NameNode web UI overview of the practice cluster: version 3.5.0, cluster ID, safe mode off, 8 files and blocks, 3 live nodes, 0 dead nodes, 0 under-replicated blocks.
    NameNode UI, Overview tab: version, cluster ID, safe mode, files and blocks, Live Nodes 3, Dead Nodes 0, under-replicated blocks.
    ResourceManager web UI, Nodes page: one active node, Capacity Scheduler, minimum allocation 1024 MB and 1 vcore, maximum 8192 MB and 4 vcores, the node RUNNING with 8 GB and 8 vcores.
    ResourceManager UI, Nodes page: 1 active node offering 8 GB and 8 vcores (YARN's defaults when nothing is configured), Capacity Scheduler, container sizes from 1 GB / 1 vcore up to 8 GB / 4 vcores.
    Screenshots show only the parts used in this course. The same data is available as JSON from /jmx (next step).
  7. Read the same facts as JSON

    curl -s "http://localhost:9870/jmx?qry=Hadoop:service=NameNode,name=FSNamesystemState" \
      | python3 -c "import sys,json; b=json.load(sys.stdin)['beans'][0]; [print(k,'=',b[k]) for k in ['FSState','NumLiveDataNodes','NumDeadDataNodes','FilesTotal','BlocksTotal','UnderReplicatedBlocks']]"
    FSState = Operational NumLiveDataNodes = 3 NumDeadDataNodes = 0 FilesTotal = 8 BlocksTotal = 8 UnderReplicatedBlocks = 0
    This is how monitoring systems watch a cluster: they poll /jmx and raise alerts when, for example, dead DataNodes or under-replicated blocks appear.

After editing a *-site.xml file, restart the daemons that read it (and copy the file to every node). Editing the file alone changes nothing in a running daemon, which is the most common “my setting doesn't work” mistake.

5 See it happen

One property, four layers

Follow dfs.replication through Kabir's experiments. Each terminal line is from the real run in Part 4.

Where does dfs.replication come from? 6 steps
What you see hadoop@namenode : /tmp hdfs-default.xml (inside the jar):<name>dfs.replication</name><value>3</value> $ curl -s localhost:9870/conf | grep …name dfs.replication value 3final false source hdfs-site.xml $ hdfs dfs -D dfs.replication=2 -put \ canteen_orders.csv data/copy2.csv$ hdfs dfs -stat "%r %n" data/copy2.csv2 copy2.csv $ hdfs dfs -setrep -w 3 data/copy2.csvReplication 3 set: data/copy2.csvWaiting for data/copy2.csv .... done /tmp/fconf/hdfs-site.xml:<value>3</value><final>true</final>$ HADOOP_CONF_DIR=/tmp/fconf hdfs dfs \ -D dfs.replication=2 -put … final_test.csv2 final_test.csv $ hdfs dfs -stat "%r %o %n" data/*3 134217728 canteen_orders.csv3 134217728 copy2.csv2 134217728 final_test.csv3 1048576 small_blocks.csvEach file keeps its own setting. myphatshala.in
Behind the screen defaults: hdfs-default.xml = 3 site: hdfs-site.xml = 3 client: -D … = 2 winsonly the default exists winsthe site file overrides the default(same number here, different source) winsthe client sets 2 for its own write NameNodecopy2.csv: 2 → 3 replicassetrep changes the file, not the configuration finalwinsfinal blocks later files (e.g. a job.xml),not a value set directly with -D canteen_orders.csvr3 · 128 MBcopy2.csvr3 · 128 MBfinal_test.csvr2 · 128 MBsmall_blocks.csvr3 · 1 MBstored per file by the NameNode myphatshala.in

Try it yourself: settings in the playground

The upload controls are settings a client sends: Block is dfs.blocksize and Replication is dfs.replication. Change them per upload and compare the files in the NameNode metadata tab.

6 Real-world use

Configuration and UIs at work

config v42→ all nodes

1. Configuration under version control

Site files live in Git or in the cluster manager, with a history of every change. A change is reviewed, pushed to all nodes, and followed by a rolling restart, one node at a time.

Change + review→Push to all nodes→Rolling restart
-D per jobmemory · queue

2. Per-job tuning without touching the cluster

A heavy nightly job asks for more memory per task and a specific queue with -D options, while every other job keeps the cluster defaults.

Cluster defaults→Job overrides→Only that job changes
/jmxalerts

3. Monitoring from /jmx

Monitoring systems (Prometheus exporters, Grafana dashboards, cluster managers) poll the daemons' /jmx endpoints for live DataNodes, capacity, missing blocks and queue usage, and page the on-call engineer when thresholds are crossed.

/jmx→Dashboards→Alerts
:9870 · :8088first look

4. The UIs are the first stop in an incident

When users say “jobs are slow”, engineers open the ResourceManager UI (queues full? nodes lost?) and the NameNode UI (dead DataNodes? safe mode? disk full?) before reading any log.

Complaint→RM + NN UIs→Then logs

Simplified; organisations differ in tools and policies.

7 Run the code

Merge configuration layers like Hadoop does

This program loads three layers in order (defaults, site file, command line) and keeps the last value for each property, unless an earlier layer marked it final and the later layer is a file. It also records the source, like the /conf page.

layers = [
    ("hdfs-default.xml", "file", {"dfs.replication": "3", "dfs.blocksize": "134217728"}, set()),
    ("hdfs-site.xml", "file", {"dfs.replication": "1"}, {"dfs.replication"}),
    ("job.xml", "file", {"dfs.replication": "5", "dfs.blocksize": "268435456"}, set()),
]

conf, source, final = {}, {}, set()
for name, kind, props, finals in layers:
    for key, value in props.items():
        if key in final and kind == "file":
            print(f"ignored {key}={value} from {name} (final)")
            continue
        conf[key], source[key] = value, name
    final |= finals

for key in conf:
    print(f"{key:16} = {conf[key]:>10}  [{source[key]}]")
ignored dfs.replication=5 from job.xml (final) dfs.replication = 1 [hdfs-site.xml] dfs.blocksize = 268435456 [job.xml]
  • ("hdfs-site.xml", "file", {"dfs.replication": "1"}, {"dfs.replication"}),The site file sets replication to 1 and marks it final (the last item is the set of final names).
  • if key in final and kind == "file":A later file cannot override a final property. (Values set directly, like -D, are not files: try challenge 2.)
  • final |= finalsFinals are added only after the layer is loaded, so they protect against later layers.

Run it on your PC: a configuration report from a live NameNode

With your cluster from Lesson 4.3 running, this program reads the NameNode's /conf page and reports how many settings come from each file, plus the value and source of four important ones. Save it as conf_report.py and run it on the same computer.

Where do the NameNode's 1,752 settings come from?

# conf_report.py: which settings is the NameNode really using, and from which file?
import urllib.request
import xml.etree.ElementTree as ET
from collections import Counter

URL = "http://localhost:9870/conf"           # NameNode web UI
root = ET.fromstring(urllib.request.urlopen(URL).read())

props = {}
for p in root.iter("property"):
    props[p.findtext("name")] = (p.findtext("value"), p.findtext("source"))

print(f"{len(props)} properties loaded")
for source, n in Counter(src for _, src in props.values()).most_common():
    print(f"{n:>5}  {source}")

print()
for key in ["fs.defaultFS", "dfs.replication", "dfs.blocksize", "dfs.namenode.name.dir"]:
    value, source = props.get(key, ("(not set)", "-"))
    print(f"{key:24} = {value}   [{source}]")

# In a terminal:
#   python3 conf_report.py
1752 properties loaded 542 hdfs-default.xml 523 yarn-default.xml 376 core-default.xml 194 mapred-default.xml 89 hdfs-rbf-default.xml 17 programmatically 5 yarn-site.xml 4 mapred-site.xml 2 hdfs-site.xml fs.defaultFS = hdfs://namenode [programmatically] dfs.replication = 3 [hdfs-site.xml] dfs.blocksize = 134217728 [hdfs-default.xml] dfs.namenode.name.dir = file://${hadoop.tmp.dir}/dfs/name [hdfs-default.xml]

Real output from the Docker practice cluster. Two surprises worth knowing: fs.defaultFS shows “programmatically” because the NameNode sets it itself at start-up from its own address, and /conf shows ${…} variables unexpanded. On Path A your numbers and sources will differ slightly.

8 Line by line

Which value wins, one line at a time

Follow dfs.replication through three layers and watch conf and src change in memory.

Worked examples: real problems, solved and traced in memory

Three everyday configuration tasks: turning human-friendly sizes into the bytes Hadoop expects, finding differences between two nodes' configurations, and sizing YARN memory for a worker. Each runs live and is traced in memory.

Example 1BeginnerAdmin · units

Write block sizes the way Hadoop stores them

Problem statement

A team wants 64 MB, 128 MB and 256 MB block sizes for three data sets. Print the byte values to put in dfs.blocksize, and how many blocks a 10 GB file would have with each.

Input
64, 128, 256 MB · 10 GB file
Expected output
 64 MB =  67108864 bytes -> 160 blocks
128 MB = 134217728 bytes -> 80 blocks
256 MB = 268435456 bytes -> 40 blocks

Approach

  1. 1 MB = 1024 × 1024 bytes.
  2. Blocks = ceil(file size / block size).
  3. Print both.

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 2IntermediateAdmin · drift

Find configuration drift between two nodes

Problem statement

Jobs fail only on one worker. Compare the settings collected from a good node and the bad node and print every property whose value differs or exists on only one side.

Input
good: replication 3, NM memory 8192, aux mapreduce_shuffle · bad: replication 3, NM memory 2048, no aux
Expected output
yarn.nodemanager.aux-services          good=mapreduce_shuffle  bad=(missing)
yarn.nodemanager.resource.memory-mb    good=8192               bad=2048

Approach

  1. Take the union of property names.
  2. For each, compare values (missing counts as a difference).
  3. Print the differences in a table.

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 3AdvancedCapacity · YARN memory

How much memory should YARN offer on a worker?

Problem statement

A worker has 128 GB RAM. Reserve 8 GB for the operating system, 4 GB for the DataNode and 2 GB for the NodeManager. Set yarn.nodemanager.resource.memory-mb to the rest, and work out how many 4 GB containers fit. (The practice cluster's UI showed the default of 8 GB per node.)

Input
128 GB RAM · OS 8 · DataNode 4 · NodeManager 2 · 4 GB containers
Expected output
yarn.nodemanager.resource.memory-mb = 116736
4 GB containers per node: 28

Approach

  1. Subtract the reserved memory.
  2. Convert to MB for the property.
  3. Containers = YARN memory // container size.

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.4 in one screen

  • Layers: *-default.xml (in jars) → *-site.xml (etc/hadoop) → -D / code. Later wins.
  • final: later configuration files cannot override it (e.g. job.xml). A direct -D still applied in our test.
  • core-site: fs.defaultFS · hdfs-site: replication, block size, dirs · yarn-site: RM host, NM memory, shuffle · mapred-site: framework.
  • hadoop-env.sh: JAVA_HOME, heap · workers: worker hosts · capacity-scheduler.xml: queues.
  • Check values: hdfs getconf -confKey <name> and the daemon's /conf page (shows source).
  • Replication and block size are per file, chosen by the writer; change existing files with hdfs dfs -setrep.
  • UIs: NN 9870 · DN 9864 · SNN 9868 · RM 8088 · NM 8042 · JHS 19888. Endpoints: /conf, /jmx, /logs.
  • Edit → copy to all nodes → restart. Editing alone changes nothing in running daemons.

Interview and viva questions

What are the main configuration files in Hadoop?

core-site.xml (common settings such as fs.defaultFS), hdfs-site.xml (HDFS: replication, block size, storage folders, addresses), yarn-site.xml (YARN: ResourceManager host, NodeManager resources, auxiliary services), mapred-site.xml (MapReduce: framework, task memory, history server), plus hadoop-env.sh, yarn-env.sh and mapred-env.sh for environment variables, and workers for the list of worker hosts.

What is the difference between core-default.xml and core-site.xml?

core-default.xml ships inside Hadoop's jars and holds the default for every core property; it is read-only reference. core-site.xml is your file in etc/hadoop that overrides the defaults you want to change.

What is a final property in Hadoop?

A property marked <final>true</final> cannot be overridden by configuration resources loaded later, for example the job.xml of a submitted job. Administrators use it to protect cluster-wide values. It does not stop a program from setting the value directly in its own configuration object.

How do I check the value of a configuration property?

Use hdfs getconf -confKey <name> for the merged value seen by the client, or open http://<daemon-host>:<port>/conf to see what a running daemon uses, including the source file.

What are the default web UI ports in Hadoop 3?

NameNode 9870, SecondaryNameNode 9868, DataNode 9864, ResourceManager 8088, NodeManager 8042, MapReduce JobHistory Server 19888. (Hadoop 2 used 50070 for the NameNode and 50075 for DataNodes.)

Do I need to restart Hadoop after changing configuration?

Usually yes: daemons read site files at start-up. Some changes can be refreshed without a restart, for example hdfs dfsadmin -refreshNodes for include/exclude lists and yarn rmadmin -refreshQueues for scheduler queues. Client-side settings take effect on the next command.

Can I change the replication of an existing file?

Yes, with hdfs dfs -setrep <n> <path> (-w waits for completion). Changing dfs.replication in hdfs-site.xml only affects files written afterwards by clients that use that file.

Practice problems

Exercises on reading, converting and checking configuration values. Each one runs in the browser.

P1Easy

Which file?

Print which site file each property belongs in.

Input
fs.defaultFS · dfs.replication · yarn.resourcemanager.hostname · mapreduce.framework.name
Expected output
fs.defaultFS -> core-site.xml
dfs.replication -> hdfs-site.xml
yarn.resourcemanager.hostname -> yarn-site.xml
mapreduce.framework.name -> mapred-site.xml
Show solution and explanation
prefix = {"fs.": "core-site.xml", "dfs.": "hdfs-site.xml",
          "yarn.": "yarn-site.xml", "mapreduce.": "mapred-site.xml"}
for key in ["fs.defaultFS", "dfs.replication", "yarn.resourcemanager.hostname", "mapreduce.framework.name"]:
    print(key, "->", next(f for p, f in prefix.items() if key.startswith(p)))
fs.defaultFS -> core-site.xml dfs.replication -> hdfs-site.xml yarn.resourcemanager.hostname -> yarn-site.xml mapreduce.framework.name -> mapred-site.xml

How it works: The prefix usually tells you the file: fs → core, dfs → hdfs, yarn → yarn, mapreduce → mapred. (A few exceptions exist, such as hadoop.* in core-site.)

P2Easy

Port lookup

Print the web UI URL of each daemon on host nn1 (masters) or w1 (workers).

Input
NameNode, ResourceManager on nn1 · DataNode, NodeManager on w1
Expected output
NameNode         http://nn1:9870
ResourceManager  http://nn1:8088
DataNode         http://w1:9864
NodeManager      http://w1:8042
Show solution and explanation
uis = [("NameNode", "nn1", 9870), ("ResourceManager", "nn1", 8088),
       ("DataNode", "w1", 9864), ("NodeManager", "w1", 8042)]
for name, host, port in uis:
    print(f"{name:16} http://{host}:{port}")
NameNode http://nn1:9870 ResourceManager http://nn1:8088 DataNode http://w1:9864 NodeManager http://w1:8042

How it works: Four URLs you will open often; the JobHistory Server adds 19888 when it is running.

P3Easy

Read a stat line

Parse the real line "2 134217728 4692009 copy2.csv" (replication, block size, bytes, name).

Input
2 134217728 4692009 copy2.csv
Expected output
copy2.csv: 2 replicas, 128 MB blocks, 4.5 MB
Show solution and explanation
r, block, size, name = "2 134217728 4692009 copy2.csv".split()
print(f"{name}: {r} replicas, {int(block) // 2**20} MB blocks, {int(size) / 2**20:.1f} MB")
copy2.csv: 2 replicas, 128 MB blocks, 4.5 MB

How it works: copy2.csv: 2 replicas, 128 MB blocks, 4.5 MB of data.

P4Medium

Blocks for each block size

The 4,692,009-byte canteen file was written with 128 MB and 1 MB blocks. How many blocks in each case? (fsck reported 5 for 1 MB.)

Input
4,692,009 bytes · 134217728 and 1048576
Expected output
134217728 -> 1 block(s)
1048576 -> 5 block(s)
Show solution and explanation
import math
for block in [134217728, 1048576]:
    print(block, "->", math.ceil(4692009 / block), "block(s)")
134217728 -> 1 block(s) 1048576 -> 5 block(s)

How it works: 1 block with 128 MB and 5 blocks with 1 MB, matching the real fsck output.

P5Medium

Override order

Apply defaults, then site, then -D options, and print the final values.

Input
defaults {replication 3, blocksize 128m} · site {replication 2} · -D {blocksize 256m}
Expected output
{'dfs.replication': '2', 'dfs.blocksize': '256m'}
Show solution and explanation
conf = {}
for layer in [{"dfs.replication": "3", "dfs.blocksize": "128m"},
              {"dfs.replication": "2"},
              {"dfs.blocksize": "256m"}]:
    conf.update(layer)
print(conf)
{'dfs.replication': '2', 'dfs.blocksize': '256m'}

How it works: Replication 2 (from the site file) and block size 256m (from -D). Each property is decided separately.

P6Medium

Parse a property line

Extract the name, value and source from a real /conf line.

Input
&lt;property&gt;&lt;name&gt;dfs.replication&lt;/name&gt;&lt;value&gt;3&lt;/value&gt;…&lt;source&gt;hdfs-site.xml&lt;/source&gt;
Expected output
{'name': 'dfs.replication', 'value': '3', 'final': 'false', 'source': 'hdfs-site.xml'}
Show solution and explanation
import re
line = "<property><name>dfs.replication</name><value>3</value><final>false</final><source>hdfs-site.xml</source>"
fields = dict(re.findall(r"<(name|value|final|source)>([^<]*)</", line))
print(fields)
{'name': 'dfs.replication', 'value': '3', 'final': 'false', 'source': 'hdfs-site.xml'}

How it works: name dfs.replication, value 3, final false, source hdfs-site.xml: the same fields conf_report.py reads.

P7Business problem

Cost of the 90% disk rule

A 20-node cluster has 12 disks of 4 TB per node. The NodeManager disk check marks a disk bad above 90% use. How much raw capacity (TB) sits in that last 10% across the cluster?

Input
20 nodes × 12 × 4 TB · 10%
Expected output
raw 960 TB, top 10% = 96 TB
Show solution and explanation
raw_tb = 20 * 12 * 4
print(f"raw {raw_tb} TB, top 10% = {raw_tb * 0.10:.0f} TB")
raw 960 TB, top 10% = 96 TB

How it works: 96 TB of 960 TB. That headroom is deliberate: full disks cause failed tasks and slow writes, so admins alert well before 90%.

P8Advanced

Unit-aware sizes

Many properties accept units (k, m, g, t). Convert "128m", "1g", "512k" and "134217728" to bytes.

Input
128m · 1g · 512k · 134217728
Expected output
      128m -> 134,217,728 bytes
        1g -> 1,073,741,824 bytes
      512k -> 524,288 bytes
 134217728 -> 134,217,728 bytes
Show solution and explanation
def to_bytes(v):
    units = {"k": 1, "m": 2, "g": 3, "t": 4}
    if v[-1].lower() in units:
        return int(v[:-1]) * 1024 ** units[v[-1].lower()]
    return int(v)
for v in ["128m", "1g", "512k", "134217728"]:
    print(f"{v:>10} -> {to_bytes(v):,} bytes")
128m -> 134,217,728 bytes 1g -> 1,073,741,824 bytes 512k -> 524,288 bytes 134217728 -> 134,217,728 bytes

How it works: 128m = 134,217,728; 1g = 1,073,741,824; 512k = 524,288; and a plain number is already bytes.

Real-world scenario questions (asked in company interviews)

Configuration questions are about reasoning: where does a value come from, and how do you prove it?

Admin · configFresher

“I changed dfs.replication to 2 but files still have 3 copies”

An admin edited hdfs-site.xml on the NameNode host. New uploads from the edge node still show replication 3 and old files are unchanged.

The interviewer is checking: client-side vs server-side settings.

Show a strong answer
  • Replication is chosen by the writing client per file. The edge node still has its own hdfs-site.xml with 3.
  • Update and distribute the configuration to clients (and all nodes); verify with hdfs getconf -confKey dfs.replication on the edge node.
  • Existing files keep their replication; change them with hdfs dfs -setrep -w 2 /path if needed.
Admin · troubleshootingFresher

“How do you know which value a daemon is using?”

Two engineers disagree about the NodeManager memory setting on a worker.

The interviewer is checking: do you know how to check instead of guessing?

Show a strong answer
  • Open http://<worker>:8042/conf: it shows the value the running NodeManager loaded, and its source file.
  • Compare with the file on disk; if they differ, the daemon was not restarted after the change.
  • The ResourceManager Nodes page also shows each node's total memory and vcores.
Platform · governanceExperienced

Users keep overriding a cluster setting in their jobs

Some teams submit jobs with very large task memory, starving others. The platform team wants to stop job configurations from overriding certain values.

The interviewer is checking: what final does and does not do, and the right tools for limits.

Show a strong answer
  • Mark cluster-wide values final in the site files on the nodes, so a job's job.xml cannot override them there.
  • Know its limit: a client can still set a value directly in its own process, so final is not a security control.
  • Enforce limits on the server side: YARN's maximum allocation (yarn.scheduler.maximum-allocation-mb) and queue capacities in the scheduler.
  • Monitor usage per queue and review exceptions.
Operations · monitoringExperienced

Set up basic monitoring for a new cluster

A small company has just built a Hadoop cluster and has no monitoring yet.

The interviewer is checking: do you know where the metrics come from and what matters?

Show a strong answer
  • Collect metrics from each daemon's /jmx endpoint (or a Prometheus exporter that reads it).
  • Alert on: dead DataNodes, missing or under-replicated blocks, HDFS capacity, safe mode, NodeManagers lost or unhealthy, queue usage and failed applications.
  • Dashboards for trends (capacity growth, job durations) and links to the NameNode and ResourceManager UIs for investigation.