启动Hive报错Name node is in safe mod
启动Hive时报以下错误
[hadoop@hadoop001 bin]$ ./hive
ls: cannot access /home/hadoop/app/spark-2.3.1-bin-2.6.0-cdh5.7.0/lib/spark-assembly-*.jar: No such file or directory
which: no hbase in (/usr/share/grafana/bin:/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin:/home/hadoop/app/spark-2.3.1-bin-2.6.0-cdh5.7.0/bin:/home/hadoop/app/flume/bin:/home/hadoop/app/scala-2.11.8/bin:/home/hadoop/app/sqoop-1.4.6-cdh5.7.0/bin:/usr/local/protobuf/bin:/home/hadoop/app/findbugs-1.3.9/bin:/home/hadoop/app/apache-maven-3.3.9/bin:/home/hadoop/app/hive-1.1.0-cdh5.7.0/bin:/home/hadoop/app/hadoop-2.6.0/bin:/usr/java/jdk1.8.0_45/bin:/usr/java/jdk1.7.0_80/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/hadoop/bin)
Logging initialized using configuration in file:/home/hadoop/app/hive-1.1.0-cdh5.7.0/conf/hive-log4j.properties
Exception in thread "main" java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.hdfs.server.namenode.SafeModeException): Cannot create directory /tmp/hive/hadoop/3a0652b1-a9a1-4930-8abc-dcc20fd6f195. Name node is in safe mode.
The reported blocks 549 needs additional 4 blocks to reach the threshold 0.9990 of total blocks 553.
The number of live datanodes 1 has reached the minimum number 0. Safe mode will be turned off automatically once the thresholds have been reached.
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkNameNodeSafeMode(FSNamesystem.java:1418)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.mkdirsInt(FSNamesystem.java:4290)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.mkdirs(FSNamesystem.java:4265)
解决:
[hadoop@hadoop001 bin]$ hdfs dfsadmin -safemode leave
Safe mode is OFF
[hadoop@hadoop001 bin]$ ./hive
ls: cannot access /home/hadoop/app/spark-2.3.1-bin-2.6.0-cdh5.7.0/lib/spark-assembly-*.jar: No such file or directory
which: no hbase in (/usr/share/grafana/bin:/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin:/home/hadoop/app/spark-2.3.1-bin-2.6.0-cdh5.7.0/bin:/home/hadoop/app/flume/bin:/home/hadoop/app/scala-2.11.8/bin:/home/hadoop/app/sqoop-1.4.6-cdh5.7.0/bin:/usr/local/protobuf/bin:/home/hadoop/app/findbugs-1.3.9/bin:/home/hadoop/app/apache-maven-3.3.9/bin:/home/hadoop/app/hive-1.1.0-cdh5.7.0/bin:/home/hadoop/app/hadoop-2.6.0/bin:/usr/java/jdk1.8.0_45/bin:/usr/java/jdk1.7.0_80/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/hadoop/bin)
Logging initialized using configuration in file:/home/hadoop/app/hive-1.1.0-cdh5.7.0/conf/hive-log4j.properties
WARNING: Hive CLI is deprecated and migration to Beeline is recommended.
hive>
safemode模式
NameNode在启动的时候首先进入安全模式,如果datanode丢失的block达到一定的比例(1-dfs.safemode.threshold.pct),则系统会一直处于安全模式状态即只读状态。
dfs.safemode.threshold.pct(缺省值0.999f)表示HDFS启动的时候,如果DataNode上报的block个数达到了元数据记录的block个数的0.999倍才可以离开安全模式,否则一直是这种只读模式。如果设为1则HDFS永远是处于SafeMode。
下面这行摘录自NameNode启动时的日志(block上报比例1达到了阀值0.9990)
The ratio of reported blocks 1.0000 has reached the threshold 0.9990. Safe mode will be turned off automatically in 18 seconds.
hadoop dfsadmin -safemode leave
有两个方法离开这种安全模式
- 修改dfs.safemode.threshold.pct为一个比较小的值,缺省是0.999。
- hadoop dfsadmin -safemode leave命令强制离开
Safe mode is exited when the minimal replication condition is reached, plus an extension
time of 30 seconds. The minimal replication condition is when 99.9% of the blocks in
the whole filesystem meet their minimum replication level (which defaults to one, and
is set by dfs.replication.min).
安全模式的退出前提 - 整个文件系统中的99.9%(默认是99.9%,可以通过dfs.safemode.threshold.pct设置)的Blocks达到最小备份级别(默认是1,可以通过dfs.replication.min设置)。
dfs.safemode.threshold.pct float 0.999
The proportion of blocks in the system that must meet the minimum
replication level defined by dfs.rep lication.min before the namenode
will exit safe mode. Setting
this value to 0 or less forces the name-node not to start in safe mode.
Setting this value to more than 1 means the namenode never exits safe
mode.
用户可以通过dfsadmin -safemode value 来操作安全模式,参数value的说明如下:
enter - 进入安全模式
leave - 强制NameNode离开安全模式
get - 返回安全模式是否开启的信息
wait - 等待,一直到安全模式结束。