【问题标题】:Unable to connect to remote hbase from java program无法从 java 程序连接到远程 hbase
【发布时间】:2017-06-13 20:05:20
【问题描述】:

您好,我正在尝试从我的 java 程序连接到远程机器中的 hbase。但我收到连接被拒绝错误。在查看错误时,我认为它正在尝试连接到我的本地主机而不是远程机器。

我的配置是这样的-

 HBaseConfiguration conf = new HBaseConfiguration();
    conf.set("hbase.master", "10.219.47.22:60010");
    conf.set("hbase.zookeeper.quorum.", "10.219.47.22:60010");
    conf.set("hbase.zookeeper.property.clientPort", "2181");

我收到以下错误

13/11/15 17:35:08 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
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.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)
13/11/15 17:35:08 INFO zookeeper.ClientCnxn: Opening socket connection to server 127.0.0.1/127.0.0.1:2180. Will not attempt to authenticate using SASL (unknown error)
13/11/15 17:35:08 WARN zookeeper.RecoverableZooKeeper: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/master
13/11/15 17:35:08 INFO util.RetryCounter: The 1 times to retry  after sleeping 2000 ms

还在远程机器上运行 lsof 以检查我的端口 2181 是否打开。我得到了以下结果-

java      18854         root  266u  IPv6 6199707      0t0  TCP 127.0.0.1:47000->127.0.0.1:2181 (CLOSE_WAIT)

【问题讨论】:

    标签: java hbase apache-zookeeper


    【解决方案1】:

    您的 zookeeper quorum ip adderess 10.219.47.22:60010 还指定了一个端口 (60010) 删除它 在法定人数之后你还有一个不必要的.

    conf.set("hbase.zookeeper.quorum", "10.219.47.22"); 
    conf.set("hbase.zookeeper.property.clientPort", "2181");
    

    【讨论】:

      【解决方案2】:

      60010 端口仅用于 web ui 不用于连接。 检查此代码 sn-p 是否可以帮助您:

      Configuration hbaseConfiguration = HBaseConfiguration.create();
      hbaseConfiguration.addResource(new Path("hbase-site.xml");
      

      并在 hbase-site.xml 文件中添加属性,如主节点上 hbase 安装文件夹的 conf 文件夹中的属性。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多