Hadoop Security Mode
When the Distributed File System is started, there will be security mode at the beginning. When the Distributed File System is in security mode, the content in the file system cannot be modified or deleted, until the Security Mode ends. The security mode is mainly used to check the validity of data blocks on each DataNode when the system starts, and to copy or delete some data blocks as required by the policy. You can also enter security mode through commands during runtime. In practice, when the system starts, an error message indicating that the file cannot be modified in security mode is displayed when you modify or delete the file. You only need to wait for a while. SafeModeException
When running a hadoop program, the following error is reported:
Org. apache. hadoop. dfs. SafeModeException: Cannot delete/user/hadoop/input. Name node is in safe mode.
Let's analyze this error and understand it literally: "Name node is in safe mode ."
Now we know that we need to solve this problem. I want to keep Hadoop in safe mode. Can I solve it without waiting? The answer is yes,
Enter the following in the Hadoop directory:
$ Bin/hadoop dfsadmin-safemode leave
That is to say, disable the Hadoop security mode and solve the problem.
Safemode Mode
When NameNode is started, it first enters the security mode. If the proportion of the block lost by datanode reaches a certain level (1-dfs.safemode.threshold.pct), the system will remain in the security mode, that is, read-only status. Dfs. safemode. threshold. pct (default value: 0.999f) indicates that when HDFS is started, if the number of blocks reported by DataNode reaches 0.999 times the number of blocks recorded by metadata, the security mode can be left; otherwise, the read-only mode is used. If it is set to 1, HDFS is always in SafeMode.
The following line extracts logs from NameNode startup (block reporting ratio 1 reaches the threshold of 0.9990)
The ratio of reported blocks 1.0000 has reached the threshold0.9990. Safe mode will be turned off automatically in 18seconds.
1. Modify dfs. safemode. threshold. pct to a smaller value. The default value is 0.999.
2. hadoop dfsadmin-safemode leave Command Force exit
Hadoop dfsadmin-safemode command
Format: Usage: java DFSAdmin [-safemode enter | leave | get | wait]
You can use dfsadmin-safemode value to operate the security mode. The value parameter is described as follows:
Enter-enter security mode
Leave-force NameNode to exit safe Mode
Get-returned information about whether the security mode is enabled
Wait-wait until the end of security mode.
From the guisu Column