Java客户端无法连接Zookeeper和HBase

标签 java hbase apache-zookeeper

我编写了一个简单的 HBase 客户端程序来在我的 HBase 集群(1 个主服务器和 3 个区域服务器)中执行 CRUD 操作。 Zookeeper实例仅在主服务器中运行,仲裁包括所有4台服务器。集群运行良好,可以使用YCSB客户端进行读/写(意味着服务器/zookeeper端没有任何问题)。

现在,在 eclipse 类路径中,我添加了所有 HBase 库和 hbase-0.94.7.jar(其中包含 hbase-default.xml 文件)。我还在项目中添加了集群中的原始 hbase-site.xml 文件。

最初,我使用未修改的 hbase-default.xml 运行客户端代码,我发现客户端正在尝试与 Zookeeper 实例的本地主机进行通信。从而忽略 hbase-site.xml。

然后我修改了保存Master/Zookpeer服务器公共(public)IP地址的3个参数并再次尝试。这次我收到以下错误,客户端不断尝试与 Zookeeper 及其其他仲裁成员连接。

我拥有 Zookeeper 仲裁中的所有 4 台服务器,假设它们的 IP 地址是:

  • W.W.W.W//HBase 主服务器和 Zookeeper 服务器

  • X.X.X.X//HBase RS 和 Zookeeper 仲裁成员

  • Y.Y.Y.Y//HBase RS 和 Zookeeper 仲裁成员

  • Z.Z.Z.Z//HBase RS 和 Zookeeper 仲裁成员

<小时/>
13/06/19 13:06:23 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=W.W.W.W:2181,X.X.X.X:2181,Y.Y.Y.Y:2181,Z.Z.Z.Z:2181 sessionTimeout=180000 watcher=hconnection

13/06/19 13:06:23 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 5828@Kamal-VAIO

13/06/19 13:06:24 INFO zookeeper.ClientCnxn: Opening socket connection to server W.W.W.W:2181. Will not attempt to authenticate using SASL (unknown error)

13/06/19 13:06:25 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect

java.net.ConnectException: Connection refused: no further information
<小时/>
13/06/19 13:06:25 WARN zookeeper.RecoverableZooKeeper: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid

13/06/19 13:06:25 INFO util.RetryCounter: Sleeping 2000ms before retry #1...

13/06/19 13:06:25 INFO zookeeper.ClientCnxn: Opening socket connection to server X.X.X.X:2181. Will not attempt to authenticate using SASL (unknown error)

13/06/19 13:06:26 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect

java.net.ConnectException: Connection refused: no further information
<小时/>

...等等

最佳答案

问题已解决。

解决方案:

  1. 右键单击 Eclipse 中的项目
  2. 转到“属性”
  3. 选择 Java 构建路径
  4. 前往图书馆
  5. 点击“添加类文件夹”
  6. 添加一个名为conf的新文件夹
  7. 按全部确定
  8. 将我的 hbase-site.xml 复制到 conf 文件夹中
  9. 还将我的 HBase 集群的 IP 主机列表添加到 Win 7 主机文件中并保存。
  10. 运行hbase代码,客户端可以成功连接Zookeeper和HBase master。

注意:第10步是必须的,否则客户端将从Zookeeper实例获取主机名并且无法解析它们。

非常感谢大家。

关于Java客户端无法连接Zookeeper和HBase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17184705/

相关文章:

hadoop - hbase 未以伪分布式模式运行

kubernetes - 在 Kubernetes 中部署应用程序时如何定义资源限制并计算消耗?

java - Zookeeper检查外部资源可用性

java - 如何找到哪个消费者分配给kafka中主题的哪个分区?

java - 如何将字节[]存储到android/java中的单个变量中

java - 输出字符串中元音数量最多的单词

java - 在 Spring security 3.0 中使用基于组的访问控制

java - @RequestMapping ("/main")在 netbeans spring 4 中不起作用,但在 spring 3 中起作用

hadoop - 尝试确认我对HBase和MapReduce行为的理解

hadoop - 当我使用自己的 TableInputFormat 时 TableMapper 出现 ClassNotFoundException