Skip to content

How do I prevent high-disk utilization caused by the NameNode directory on a single primary node cluster on Amazon EMR?

4 minute read
1

I have high-disk utilization on my primary instance in Amazon EMR, and I receive a "NameNode is in safe mode" error message.

Short description

In Amazon EMR clusters with a single primary node, you might see high disk utilization on a primary instance. The primary node’s NameNode accumulates edit files continuously when it runs without high availability. This accumulation occurs because there is no secondary NameNode to manage the files. As edit files grow, they consume available disk space and that might cause NameNode failure and cluster outages. To prevent high disk utilization, run a secondary NameNode on your primary instance.

Resolution

Run a secondary NameNode on the primary instance

To prevent disk space issues through regular checkpointing of FsImage and EditLog files, run a secondary NameNode.

Note: If you run both the primary NameNode and secondary NameNode on your cluster's primary instance, then you might experience higher memory consumption. Make sure that your primary instance has sufficient available memory to use both services.

Run one of the following shell scripts to install the secondary NameNode.

Amazon EMR version 5.30.0 and later:

set -e -x
sudo yum install hadoop-hdfs-secondarynamenode -y
sudo systemctl start hadoop-hdfs-secondarynamenode.service
sudo systemctl status hadoop-hdfs-secondarynamenode.service -l
sudo systemctl enable hadoop-hdfs-secondarynamenode.service

Amazon EMR version 4.0.0 through version 5.29.0:

set -e -x
sudo yum install hadoop-hdfs-secondarynamenode -y
sudo start hadoop-hdfs-secondarynamenode
sudo status hadoop-hdfs-secondarynamenode

Additional troubleshooting steps

Single primary node has high disk utilization

If you see high disk utilization on the primary instance by the directory default:/mnt/namenode/current/, then see the Remove unnecessary files from /mnt section in How do I turn off Safemode for the NameNode service on my Amazon EMR cluster?

When the NameNode goes into SafeMode, the Hadoop Distributed File System (HDFS) becomes read only. Then, the jobs that write the data to HDFS fail.

Note: It's a best practice to back up the edit log files before you manually delete files from /mnt.

To create a new FSImage and exit SafeMode, complete the following steps:

  1. Run the following command to put HDFS into safe mode:

    sudo -u hdfs hdfs dfsadmin -safemode enter

    When HDFS is in safe mode, no data modifications occur during your maintenance operations.

  2. Run the following command to create a checkpoint of the current filesystem state:

    sudo -u hdfs hdfs dfsadmin -saveNamespace
  3. Run the following command to back up the edit logs to Amazon Simple Storage Service (Amazon S3) for storage:

    sudo su - root -c "hdfs dfs -put /mnt/namenode/current/*edits_[0-9]* s3://amzn-s3-demo-bucket/backup-hdfs/"

    Note: Replace amzn-s3-demo-bucket with your Amazon S3 bucket URL. 
    These files contain the record of all changes made to the filesystem.

  4. Run the following command to remove the accumulated edit logs and auxiliary files from the NameNode's local storage:

    sudo su - root -c "rm -f /mnt/namenode/current/*edits_[0-9]*"
  5. Run the following command to remove seen files from the NameNode's local storage:

    sudo su - root -c "rm -f /mnt/namenode/current/seen*"

    Note: The NameNode regenerates seen_txid automatically, so you don't need to back it up.

  6. Run the following command to exit safe mode and to allow the cluster to resume normal operations:

    sudo -u hdfs hdfs dfsadmin -safemode leave

This makes the filesystem writable again and completes your maintenance cycle.

Resolve "NameNode is in safe mode" error

If you continue to receive the "NameNode is in safe mode" error, then see How do I turn off Safemode for the NameNode service on my Amazon EMR cluster?

Resolve "OutOfMemory" error

If you receive the "OutOfMemory" error after you restart the NameNode, then run the free -h command to check free memory on the instance. Then, increase NameNode heap accordingly to resolve the issue. For more information, see the Increase the NameNode Heap size section in How do I resolve the "java.lang.OutOfMemoryError: GC overhead limit exceeded" error in Amazon EMR?

AWS OFFICIALUpdated a month ago