Skip to main content

Don’t Put Hadoop or HBase Temp Directories in /tmp: Protecting Your Metadata

Struggling with delivery, architecture alignment, or platform stability?

I help teams fix systemic engineering issues: processes, architecture, and clarity.
→ See how I work with teams.


Many early Hadoop installations lost HDFS metadata because temporary directories were left under /tmp, which is routinely cleaned by Linux on reboot. This article explains why hadoop.tmp.dir and hbase.tmp.dir must point to a stable path, how this impacts NameNode edit logs and checkpoints, and what a safe configuration looks like today for both Hadoop and HBase clusters.

In early Hadoop 0.20 clusters, it was common to leave the default hadoop.tmp.dir configuration unchanged. On many Linux systems, however, /tmp is automatically cleaned during reboot. If your Hadoop or HBase temp directories live there, you risk losing critical metadata when the operating system wipes that directory.

For the SecondaryNameNode and related components, this can mean the loss of:

  • Recent edit logs
  • Checkpointed fsimage files
  • Other temporary metadata needed for recovery

If these files are removed, the NameNode may not be able to replay its edits after a crash, leading to a failed restart or a painful recovery process.

Configuring a Safe hadoop.tmp.dir

The first step is to move hadoop.tmp.dir to a stable location outside /tmp. Use a path on a persistent filesystem with enough capacity and proper backup or snapshot policies.

Example entry for core-site.xml:

<property> <name>hadoop.tmp.dir</name> <value>/var/lib/hadoop/tmp/${user.name}</value> </property> 

You can choose any appropriate base directory, such as:

  • /var/lib/hadoop/tmp
  • /data1/hadoop/tmp
  • A dedicated mount attached to your storage system

After updating the configuration, restart the SecondaryNameNode (and other Hadoop daemons as required) so they start using the new, persistent location.

Configuring a Safe hbase.tmp.dir

The same principle applies to HBase. Leaving hbase.tmp.dir under /tmp is risky for cluster stability. Update hbase-site.xml with a persistent path:

<property> <name>hbase.tmp.dir</name> <value>/var/lib/hbase/tmp/${user.name}</value> </property> 

Again, choose a directory on durable storage with sufficient capacity. Restart your HBase services after the change so they use the new locations.

Modern Perspective: Still Relevant?

Even with modern Hadoop distributions, NameNode HA, and cloud-based storage, the core idea remains important:

  • Avoid storing any critical metadata or temp data on ephemeral locations that OS tools or init scripts may wipe.
  • Ensure that temp directories used by Hadoop and HBase live on stable volumes.
  • Monitor disk usage and include these paths in your backup or snapshot strategy where appropriate.

Misconfigured temp directories are still a surprisingly common source of metadata loss, especially in test or ad-hoc clusters that later grow into production-critical systems.

By moving hadoop.tmp.dir and hbase.tmp.dir away from /tmp, you significantly reduce the risk of losing checkpoints, edit logs or other files required for a clean restart after a crash or reboot.

If you need help with distributed systems, backend engineering, or data platforms, check my Services.

Most read articles

Why Is Customer Obsession Disappearing?

Many companies trade real customer-obsession for automated, low-empathy support. Through examples from Coinbase, PayPal, GO Telecommunications and AT&T, this article shows how reliance on AI chatbots, outsourced call centers, and KPI-driven workflows erodes trust, NPS and customer retention. It argues that human-centric support—treating support as strategic investment instead of cost—is still a core growth engine in competitive markets. It's wild that even with all the cool tech we've got these days, like AI solving complex equations and doing business across time zones in a flash, so many companies are still struggling with the basics: taking care of their customers. The drama around Coinbase's customer support is a prime example of even tech giants messing up. And it's not just Coinbase — it's a big-picture issue for the whole industry. At some point, the idea of "customer obsession" got replaced with "customer automation," and no...

How to scale MySQL perfectly

When MySQL reaches its limits, scaling cannot rely on hardware alone. This article explains how strategic techniques such as caching, sharding and operational optimisation can drastically reduce load and improve application responsiveness. It outlines how in-memory systems like Redis or Memcached offload repeated reads, how horizontal sharding mechanisms distribute data for massive scale, and how tools such as Vitess, ProxySQL and HAProxy support routing, failover and cluster management. The summary also highlights essential practices including query tuning, indexing, replication and connection management. Together these approaches form a modern DevOps strategy that transforms MySQL from a single bottleneck into a resilient, scalable data layer able to grow with your application. When your MySQL database reaches its performance limits, vertical scaling through hardware upgrades provides a temporary solution. Long-term growth, though, requires a more comprehensive approach. This invo...

What the Heck is Superposition and Entanglement?

This post is about superposition and interference in simple, intuitive terms. It describes how quantum states combine, how probability amplitudes add, and why interference patterns appear in systems such as electrons, photons and waves. The goal is to give a clear, non mathematical understanding of how quantum behavior emerges from the rules of wave functions and measurement. If you’ve ever heard the words superposition or entanglement thrown around in conversations about quantum physics, you may have nodded politely while your brain quietly filed them away in the "too confusing to deal with" folder.  These aren't just theoretical quirks; they're the foundation of mind-bending tech like Google's latest quantum chip, the Willow with its 105 qubits. Superposition challenges our understanding of reality, suggesting that particles don't have definite states until observed. This principle is crucial in quantum technologies, enabling phenomena like quantum comp...