Hbase 绑定多网卡的问题

 我的HBASE 集群的节点上有两个网卡,一个是集群内部使用的网卡,一个用来和外网传输数据。             

但是部署安装完成后 hbase regionserver 启动后60020端口一直绑定内网网卡,这就导致外网无法访问hbase 集群;

DEBUG的出错信息:

 

2014-06-10 16:11:47.230-[main-DEBUG]org.apache.hadoop.ipc.RpcClient:Connecting to xxxxxxxxxxxxxxxx-yarn12/192.169.2.34:60020
2014-06-10 16:11:48.136-[main-DEBUG]org.apache.hadoop.ipc.RpcClient:IPC Client (29569230) connection to xxxxxxxxxxxxxxxx-yarn12/192.169.2.34:60020: Connection refused: no further information
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:206)
at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:529)
at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:493)
at org.apache.hadoop.hbase.ipc.RpcClient$Connection.setupConnection(RpcClient.java:576)
at org.apache.hadoop.hbase.ipc.RpcClient$Connection.setupIOstreams(RpcClient.java:861)
at org.apache.hadoop.hbase.ipc.RpcClient.getConnection(RpcClient.java:1540)
at org.apache.hadoop.hbase.ipc.RpcClient.call(RpcClient.java:1429)
at org.apache.hadoop.hbase.ipc.RpcClient.callBlockingMethod(RpcClient.java:1658)
at org.apache.hadoop.hbase.ipc.RpcClient$BlockingRpcChannelImplementation.callBlockingMethod(RpcClient.java:1716)
at org.apache.hadoop.hbase.protobuf.generated.ClientProtos$ClientService$BlockingStub.get(ClientProtos.java:27308)
at org.apache.hadoop.hbase.protobuf.ProtobufUtil.getRowOrBefore(ProtobufUtil.java:1407)
at org.apache.hadoop.hbase.client.HTable$2.call(HTable.java:701)
at org.apache.hadoop.hbase.client.HTable$2.call(HTable.java:699)
at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:120)
at org.apache.hadoop.hbase.client.HTable.getRowOrBefore(HTable.java:705)
at org.apache.hadoop.hbase.client.MetaScanner.metaScan(MetaScanner.java:144)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.prefetchRegionCache(HConnectionManager.java:1107)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:1167)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:1059)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:1016)
at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:326)
at org.apache.hadoop.hbase.client.HTable.(HTable.java:310)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getTable(HConnectionManager.java:712)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getTable(HConnectionManager.java:694)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getTable(HConnectionManager.java:684)
2014-06-10 16:11:48.136-[main-DEBUG]org.apache.hadoop.ipc.RpcClient:IPC Client (29569230) connection to xxxxxxxxxxxxxxxx-yarn12/192.169.2.34:60020 from xxxx: closed



。查看netstat -ntpl 后 发现 60020 绑定到hosts里面配置的内网IP

tcp        0      0 :::60010                    :::*                        LISTEN      12774/java          
tcp        0      0 ::ffff:192.169.2.34:60020   :::*                        LISTEN      12138/java          
tcp        0      0 :::50060                    :::*                        LISTEN      12288/java  


查看org.apache.hadoop.hbase.regionserver.HRegionServer 中的构造函数 发现代码如下:

 // Server to handle client requests.
    String hostname = conf.get("hbase.regionserver.ipc.address",
      Strings.domainNamePointerToHostName(DNS.getDefaultHost(
        conf.get("hbase.regionserver.dns.interface", "default"),
        conf.get("hbase.regionserver.dns.nameserver", "default"))));
    int port = conf.getInt(HConstants.REGIONSERVER_PORT,
      HConstants.DEFAULT_REGIONSERVER_PORT);
    // Creation of a HSA will force a resolve.
    InetSocketAddress initialIsa = new InetSocketAddress(hostname, port);
    if (initialIsa.getAddress() == null) {
      throw new IllegalArgumentException("Failed resolve of " + initialIsa);
    }

发现 InetSocketAddress这里面获取IP的方式是解析hosts文件里面第一个和本机hostname对应的IP然后绑定。

所以在hbase-site.xml 里面配置 hbase.regionserver.ipc.address 为0.0.0.0 。并重启regionserver, netstat 后:

tcp        0      0 :::60020                    :::*                        LISTEN      11300/java 
解决问题。











你可能感兴趣的:(hbase,hbase,hbase多网卡)