window 7 下用MyEclipse编写Java程序连接HBase时遇到的问题

在连接HBase之前需要设置其基本配置信息,通常通过两种方式,一种是直接在工程中添加hbase-site.xml的配置文件,一种是通过Java代码直接设置,如

cfg.set("hbase.rootdir", "hdfs://master:9000/hbase");
cfg.set("hbase.master", "hdfs://master:60000");
cfg.set("hbase.zookeeper.quorum", "slave1,slave2,slave3");

如果不是通过ip地址直接设置的,需要在windows系统的hosts文件中添加主机名称和ip地址映射关系

在实际读取HBase时可能会出现下面错误


警告: 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(SocketChannelImpl.java:735)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)


十二月 22, 2015 3:37:30 下午 org.apache.zookeeper.ClientCnxn$SendThread logStartConnect
信息: Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
15/12/22 15:37:30 WARN zookeeper.RecoverableZooKeeper: Possibly transient ZooKeeper, quorum=localhost:2181, exception=org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
15/12/22 15:37:30 INFO util.RetryCounter: Sleeping 1000ms before retry #0...
十二月 22, 2015 3:37:31 下午 org.apache.zookeeper.ClientCnxn$SendThread run
警告: 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(SocketChannelImpl.java:735)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)

at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)


解决方法:在hosts文件中添加下面代码

##connect to zookeeper server
ip地址 localhost.localdomain localhost

其中IP地址是指zookeeper所在服务器的ip地址,通常zookeeper不只一台,指定其中任意一台即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值