What is Safemode? how to come out of Safemode in Hadoop?

Free Online Certification Courses – Learn Today. Lead Tomorrow. Forums Apache Hadoop What is Safemode? how to come out of Safemode in Hadoop?

Viewing 2 reply threads
  • Author
    Posts
    • #5734
      DataFlair TeamDataFlair Team
      Spectator

      What is Safemode in Hadoop?
      Write the commands to enter and leave Safemode in Hadoop?

    • #5735
      DataFlair TeamDataFlair Team
      Spectator

      Safemode for Namenode is a read-only mode for the HDFS cluster, where it does not allow any modifications to file system or Blocks HDFS cluster is in safemode state during start up because the cluster needs to validate all the blocks and their locations. Once validated, safemode is then disabled.

      Other possible reasons for namenode going to safemode are-

      1) Unreported datanodes which will cause missing blocks and if the missing blocks are greater than a limit, namenode will go to safemode
      2) If the storage of some datanodes got cleared accidently and if no blocks are available in the cluster for those data, namenode will go to safemode, because the metadata corresponding to those blocks will be present in the namenode and it will wait for those blocks to report. Till that time it can’t provide this data to users, so it will be in safemode
      3) If the storage of namenode is full. Then namenode will go to safemode
      4) If the namenode lacks physical memory, it will enter into safemode
      5) If the cluster storage is full, namenode will enter into safemode

      Switch to hdfs user using below command –
      su -hdfs

      Execute below commands as hdfs user –
      Command to enter safe mode –
      hdfs dfsadmin -safemode enter
      Command to leave safe mode –
      hdfs dfsadmin -safemode leave
      Command to get safe mode –
      hdfs dfsadmin -safemode get

    • #5736
      DataFlair TeamDataFlair Team
      Spectator

      Safe Mode in Hadoop is a maintenance state of Name Node during which Name Node doesn’t allow any changes to the file system. During safe mode Hadoop is read only and doesn’t allow the replication or deletion of blocks.

      • 1.Name Node automatically enters into safe mode when its startup.
      • 2 . To leave safe mode , name node need to collect reports for at least a specified threshold percentage of blocks and these blocks should satisfy min replication condition.

      • 3. Once threshold is reached , safe mode will be extended for a configured amount of time to get remaining data nodes to check in. so that name node can starts replicating missing data blocks or deleting over replicated blocks.

      • 4. Once all the blocks reports are collected and namenode done with block replication and adjustment it will leave the safe mode automatically.

      Even though Name node can also be enter manually to do some administration activities by using below HDFS command:
      1. Command to enter into safe mode :-

      hdfs dfsadmin -safemode enter

      2. Command to leave safe mode :-

      hdfs dfsadmin –safemode leave

      3. Command to get the current status of safemode:-

      hdfs dfsadmin -safemode get

Viewing 2 reply threads
  • You must be logged in to reply to this topic.