I help teams fix systemic engineering issues: processes, architecture, and clarity.
→ See how I work with teams.
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
fsimagefiles - 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.