首页 > 代码库 > hadoop1安全异常:The ratio of reported blocks 1.0000 has reached the threshold 0.9990.

hadoop1安全异常:The ratio of reported blocks 1.0000 has reached the threshold 0.9990.

hadoop启动时报如下错误:错误分别在namenode和jobTracker日志文件都有

org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot delete /usr/hadoop/tmp/mapred/system. Name node is in safe mode.

The ratio of reported blocks 1.0000 has reached the threshold 0.9990. Safe mode will be turned off automatically in 27 seconds.

at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.deleteInternal(FSNamesystem.java:1992)

at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.delete(FSNamesystem.java:1972)

at org.apache.hadoop.hdfs.server.namenode.NameNode.delete(NameNode.java:792)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:563)

at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1388)

at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1384)

at java.security.AccessController.doPrivileged(Native Method)

at javax.security.auth.Subject.doAs(Subject.java:396)

at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1083)

at org.apache.hadoop.ipc.Server$Handler.run(Server.java:1382)


原因:

hadoop默认情况下在安全模式运行。可以通过下面hadoop dfsadmin -safemode 参数,查看相关的状态和设置安全模块是否启用。

enter  进入安全模式
leave  强制NameNode离开安全模式
get     返回安全模式是否开启的信息

wait     等待,一直到安全模式结束。

解决办法有二种:

    《1》可能运行命令hadoop dfsadmin -safemode leave 离开安全模式,但是每次都需要手动去设置。

    《2》通过配置dfs.safemode.threshold.pct的参数。默认情况下是0.9990f。这个配置可以在hdfs-defalut.xml中找到。我们可以把这个参数配置为0,永久关闭安全模式。

hadoop中的hdfs-site.xml添加如下配置:

        <property>

                <name>dfs.safemode.threshold.pct</name>

                <value>0f</value>

                <description>

                        Specifies the percentage of blocks that should satisfy

                        the minimal replication requirement defined by dfs.replication.min.

                        Values less than or equal to 0 mean not to wait for any particular

                        percentage of blocks before exiting safemode.

                        Values greater than 1 will make safe mode permanent.

                </description>

        </property>  

重启NameNode就可以了。

本文出自 “JAVAWEB” 博客,请务必保留此出处http://472053211.blog.51cto.com/3692116/1577108

hadoop1安全异常:The ratio of reported blocks 1.0000 has reached the threshold 0.9990.