我们在使用Hadoop的时候发现Hadoop有一个比较烦人的东西就是安全模式,尤其是在自己的测试环境中,常发生在使用hive并且优化了hive之后,基本每次操作完,下次进入hive都会由于hadoop进入安全模式,而导致失败,下面我给大家两种处理方式,希望对大家有帮助
第一种,修改安全阈值
<property>
<name>dfs.safemode.threshold.pct</name>
<value>1</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>
把上面这个配置添加到hdfs-site.xml中,对安全阀值进行设置,属性值默认为0.999f,我们把它设为1,不进行安全检查,这种凡是不是很友好,但是最方便
第二种,shell
#!/bin/bash
hadoop dfsadmin -safemode leave
准备一个shell脚本在每次启动集群之后运行它