一、异常现象
启动hbase的时,hbase的日志中可以发现:
代码语言:javascript复制 Waiting for dfs to exit safe mode...
然后就抛异常了
代码语言:javascript复制2018-03-22 17:00:28,994 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:00:39,000 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:00:49,005 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:00:59,007 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:01:09,020 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:01:19,026 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:01:29,036 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:01:39,044 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:01:49,054 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:01:59,059 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:02:09,064 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:02:19,066 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:02:29,074 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:02:39,076 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:02:49,083 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:02:59,088 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:03:09,090 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:03:19,096 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:03:29,107 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:03:39,117 INFO [rayner:46905.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode...
2018-03-22 17:03:39,676 ERROR [main] master.HMasterCommandLine: Master exiting
java.lang.RuntimeException: Master not initialized after 200000ms seconds
at org.apache.hadoop.hbase.util.JVMClusterUtil.startup(JVMClusterUtil.java:230)
at org.apache.hadoop.hbase.LocalHBaseCluster.startup(LocalHBaseCluster.java:414)
at org.apache.hadoop.hbase.master.HMasterCommandLine.startMaster(HMasterCommandLine.java:228)
at org.apache.hadoop.hbase.master.HMasterCommandLine.run(HMasterCommandLine.java:138)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.hadoop.hbase.util.ServerCommandLine.doMain(ServerCommandLine.java:127)
at org.apache.hadoop.hbase.master.HMaster.main(HMaster.java:2806)
2018-03-22 17:03:39,692 INFO [Shutdown] mortbay.log: Shutdown hook executing
2018-03-22 17:03:39,698 INFO [Shutdown] mortbay.log: Stopped SelectChannelConnector@0.0.0.0:42281
2018-03-22 17:03:39,702 INFO [Shutdown] mortbay.log: Shutdown hook complete
2018-03-22 17:03:42,769 INFO [main] util.VersionInfo: HBase 1.4.2
2018-03-22 17:03:42,777 INFO [main] util.VersionInfo: Source code repository git://onyx/data/apurtell/src/hbase revision=b4ec89059cc3a7416c2012bb1a9d31f1cd34b78c
2018-03-22 17:03:42,777 INFO [main] util.VersionInfo: Compiled by apurtell on Wed Feb 21 14:25:53 PST 2018
2018-03-22 17:03:42,777 INFO [main] util.VersionInfo: From source with checksum fbdf23947e780221d5ac0785f11e9def
二、异常原因
原来是Hadoop在刚启动的时候,还处在安全模式造成的。
代码语言:javascript复制[coder@h1 hadoop-0.20.2]$ bin/ hadoop dfsadmin -safemode get
Safe mode is ON
[coder@h1 hadoop-0.20.2]$
三、异常解决
可等Hadoop退出安全模式后再执行HBase命令,或者手动退出Hadoop的安全模式
代码语言:javascript复制[root@Hadoop-NN-01 hadoop-2.6.0-cdh5.6.0]$ bin/ hadoop dfsadmin -safemode leave
Safe mode is OFF
现在再执行HBase的命令就没有问题了。
四、知识点总结
hadoop dfsadmin-safemode 命令参数说明:
代码语言:javascript复制enter - 进入安全模式
leave - 强制NameNode离开安全模式
get - 返回安全模式是否开启的信息
wait - 等待,一直到安全模式结束。
真正的原因是hbase没有真正关闭。
正确的关闭步骤:
(1) 先关闭hadoop,
(2) kill -9杀掉顽固进程
(3) 关闭 hbase
五、参考资料
1.Util.FSUtils: Waiting for dfs to exit safe mode
2.安装hbase后,启动服务正常,但停止服务时出现很诡异的现象