Safe mode can happen in 2 ways.
- One is we can forcefully switch namenode to safemode
- Another is namenode automatically enters into the safemode because of some issues.
We forcefully put namenode to safemode for performing maintenance activities. So that people will not write anything into the filesystem.
In your case the 2nd thing happened. The possible reasons for namenode going to safemode are.
- Unreported datanodes which will cause missing blocks and if the
missing blocks are greater than a limit, namenode will go to safemode
- 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
- If the storage of namenode is full. Then namenode will go to safemode
- If the namenode lacks physical memory, it will enter into safemode
- If the cluster storage is full, namenode will enter into safemode