现象描述:
搭建好hbase集群并启动集群后发现,HMaster在启动后几秒内自动关闭,HRegionServer运行正常。
错误日志:
2016-11-16 17:12:02,061 FATAL [hadoop1:16000.activeMasterManager] master.HMaster: Failed to become active master
java.net.ConnectException: Call From hadoop1/192.168.2.1 to hadoop1:8020 failed on connection exception: java.net.ConnectException: Connection refused; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at org.apache.hadoop.ipc.Client.call(Client.java:1382)
... 29 more
2016-11-16 17:12:02,062 FATAL [hadoop1:16000.activeMasterManager] master.HMaster: Unhandled exception. Starting shutdown.
java.net.ConnectException: Call From hadoop1/192.168.2.1 to hadoop1:8020 failed on connection exception: java.net.ConnectException: Connection refused; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at org.apache.hadoop.net.NetUtils.wrapException(NetUtils.java:730)
at org.apache.hadoop.ipc.Client.call(Client.java:1415)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102)
错误分析:
从上面的日志可以看出,在连接hadoop1:8020时出错,我们知道8020是hdfs的默认端口,但是我们在配置hadoop集群时在core-site.xml中将hdfs的默认端口改为了9000:
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop1:9000/</value>
</property>
再观察我们的hbase-site.xml文件:
<configuration>
<!-- 指定hbase在HDFS上存储的路径 -->
<property>
<name>hbase.rootdir</name>
<value>hdfs://hadoop1/hbase</value>
</property>
</configuration>
不难发现,这时候我们并没有指定hdfs的端口,因此,在hbase启动后它会去找hdfs的默认端口8020,于是就导致了上面的错误。
解决方案:
在配置hbase.rootdir属性时显式指定hdfs的端口为9000,配置文件修改如下:
<configuration>
<!-- 指定hbase在HDFS上存储的路径 -->
<property>
<name>hbase.rootdir</name>
<value>hdfs://hadoop1:9000/hbase</value>
</property>
</configuration>
接下来,重启hbase,问题解决。