HBase unknown host异常问题解决方法
* HBase client 初始化连接流程# 当使用HBase配置创建HTable对象时,最终会得到与RegionServer服务器的连接,使用该连接对RegionServer服务器上的数据操作# Client先随机选择连接一台zookeeper建立连接,如果连接建立失败,重新获取与其它zookeeper的连接# 从zookeeper服务查询region-server主机名,zook
·
* HBase client 初始化连接流程
# 当使用HBase配置创建HTable对象时,最终会得到与RegionServer服务器的连接,使用该连接对RegionServer服务器上的数据操作
# Client先随机选择连接一台zookeeper建立连接,如果连接建立失败,重新获取与其它zookeeper的连接
# 从zookeeper服务查询region-server主机名,zookeeper会根据RegionServer的负载、状态情况返回一台可用的RegionServer
# Client端使用该主机名与RegionServer建立连接,如果连接失败,会进行重试,直接到超过重试次数或连接建立成功
Master服务启动时,会使用RegionServer的ip反向获取hostname,缓存到内存中,当client从zookeeper查询RegionServer时,会把hostname返回给client。
这里存在一个问题,如果返回的hostname在client端无法解析,client会抛unknown host异常,导致最后一步连接失败。
问题原因,在hbase-site.xml里配置了hbase.master.dns.interface,又在hosts里配置RegionServer ip对应的主机名与dns对应的主机名不致造成。
解决办法是让dns或hosts配置文件中只保留一处RegionServer ip对应的主机名的配置,删掉Master节点中hosts中配置即可
<pre>
java.net.UnknownHostException: unknown host: hbase-node1
at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.<init>(HBaseClient.java:302)
at org.apache.hadoop.hbase.ipc.HBaseClient.createConnection(HBaseClient.java:281)
at org.apache.hadoop.hbase.ipc.HBaseClient.getConnection(HBaseClient.java:1137)
at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:1000)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:150)
at $Proxy4.getProtocolVersion(Unknown Source)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine.getProxy(WritableRpcEngine.java:183)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:335)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:312)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:364)
at org.apache.hadoop.hbase.ipc.HBaseRPC.waitForProxy(HBaseRPC.java:236)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1309)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1265)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1252)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:961)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:856)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:958)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:860)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:817)
at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:234)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:174)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:133)
</pre>
# 当使用HBase配置创建HTable对象时,最终会得到与RegionServer服务器的连接,使用该连接对RegionServer服务器上的数据操作
# Client先随机选择连接一台zookeeper建立连接,如果连接建立失败,重新获取与其它zookeeper的连接
# 从zookeeper服务查询region-server主机名,zookeeper会根据RegionServer的负载、状态情况返回一台可用的RegionServer
# Client端使用该主机名与RegionServer建立连接,如果连接失败,会进行重试,直接到超过重试次数或连接建立成功
Master服务启动时,会使用RegionServer的ip反向获取hostname,缓存到内存中,当client从zookeeper查询RegionServer时,会把hostname返回给client。
这里存在一个问题,如果返回的hostname在client端无法解析,client会抛unknown host异常,导致最后一步连接失败。
问题原因,在hbase-site.xml里配置了hbase.master.dns.interface,又在hosts里配置RegionServer ip对应的主机名与dns对应的主机名不致造成。
解决办法是让dns或hosts配置文件中只保留一处RegionServer ip对应的主机名的配置,删掉Master节点中hosts中配置即可
需要注意的是hbase-site.xml配置dns.interface时,/etc/hosts配置文件应该与dns保持一致
<pre>
java.net.UnknownHostException: unknown host: hbase-node1
at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.<init>(HBaseClient.java:302)
at org.apache.hadoop.hbase.ipc.HBaseClient.createConnection(HBaseClient.java:281)
at org.apache.hadoop.hbase.ipc.HBaseClient.getConnection(HBaseClient.java:1137)
at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:1000)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:150)
at $Proxy4.getProtocolVersion(Unknown Source)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine.getProxy(WritableRpcEngine.java:183)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:335)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:312)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:364)
at org.apache.hadoop.hbase.ipc.HBaseRPC.waitForProxy(HBaseRPC.java:236)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1309)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1265)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getHRegionConnection(HConnectionManager.java:1252)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:961)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:856)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:958)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:860)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:817)
at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:234)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:174)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:133)
</pre>
更多推荐
已为社区贡献1条内容
所有评论(0)