问题描述
限时送ChatGPT账号..我编写了一个简单的 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 服务器的公共 IP 地址的 3 个参数并再次尝试.这次我收到以下错误,其中客户端不断尝试与 Zookeeper 及其其他仲裁成员连接.
我拥有 Zookeeper 仲裁中的所有 4 个服务器,假设它们的 IP 地址是:
W.W.W.W//HBase master 和 Zookeeper Server
X.X.X.X//HBase RS 和 Zookeeper 仲裁成员
Y.Y.Y.Y//HBase RS 和 Zookeeper Quorum Member
Z.Z.Z.Z//HBase RS 和 Zookeeper Quorum Member
<小时><前>13/06/19 13:06:23 INFO zookeeper.ZooKeeper:启动客户端连接,connectString=W.W.W.W:2181,X.X.X.X:2181,Y.Y.Y.Y:2181,Z.Z.Z.Z:2181 sessionTimeout0 watcherhion00000013/06/19 13:06:23 INFO zookeeper.RecoverableZooKeeper:这个进程的标识符是5828@Kamal-VAIO13/06/19 13:06:24 INFO zookeeper.ClientCnxn:打开与服务器 W.W.W.W:2181 的套接字连接.不会尝试使用 SASL 进行身份验证(未知错误)13/06/19 13:06:25 WARN zookeeper.ClientCnxn:会话 0x0 为服务器空,意外错误,关闭套接字连接并尝试重新连接java.ConnectException:连接被拒绝:没有更多信息<小时><前>13/06/19 13:06:25 警告 zookeeper.RecoverableZooKeeper:可能是暂时的 ZooKeeper 异常:org.apache.zookeeper.KeeperException$ConnectionLossException:KeeperErrorCode = ConnectionLoss for/hbase/hbaseid19 年 6 月 13 日 13:06:25 信息 util.RetryCounter:重试 #1 前休眠 2000 毫秒...13/06/19 13:06:25 INFO zookeeper.ClientCnxn:打开与服务器 X.X.X.X:2181 的套接字连接.不会尝试使用 SASL 进行身份验证(未知错误)13/06/19 13:06:26 WARN zookeeper.ClientCnxn:会话 0x0 为服务器空,意外错误,关闭套接字连接并尝试重新连接java.ConnectException:连接被拒绝:没有更多信息
<小时>
...等等
解决方案问题已解决.
解决方案:
右键单击 Eclipse 中的项目转到属性选择 Java 构建路径前往图书馆点击添加类文件夹添加一个名为 conf 的新文件夹全部按OK将我的 hbase-site.xml 复制到 conf 文件夹中还将我的 HBase 集群的 ip-host 列表添加到 Win 7 主机文件中并保存.运行 hbase 代码,客户端可以成功连接到 Zookeeper 和 HBase master.注意:步骤 10 是必须的,否则客户端将从 Zookeeper 实例中获取主机名并且无法解析它们.
非常感谢大家.
I wrote a simple HBase client program to perform CRUD operations in my HBase cluster (1 Master and 3 Region Server). The Zookeeper instance is only running in the master server and the quorum includes all the 4 servers. The cluster is running fine and can perform read/write using YCSB client (means there are nothing wrong in the server/zookeeper side).
Now in the eclipse classpath I have added all the HBase libs and hbase-0.94.7.jar (which contains the hbase-default.xml file). I have also added the original hbase-site.xml file from the cluster in the project.
Initially, I ran the client code using the unmodified hbase-default.xml and what I've found that the client is trying to communicate with the localhost for zookeeper instance. And thus ignoring the hbase-site.xml.
Then I've modified the 3 parameters which holds the public IP address of the Master/Zookpeer server and tried again. This time I am getting the below error where the client is continuously trying to connect with the Zookeeper and its other quorum members.
I have all the 4 servers in the Zookeeper quorum and lets say their IP addresses are:
W.W.W.W // HBase master and Zookeeper Server
X.X.X.X // HBase RS and Zookeeper Quorum Member
Y.Y.Y.Y // HBase RS and Zookeeper Quorum Member
Z.Z.Z.Z // HBase RS and Zookeeper Quorum Member
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.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.ConnectException: Connection refused: no further information
... and so on
解决方案The Problem has been solved.
Solution:
Right Click on the Project in Eclipse Go to Properties Select Java Build Path Go to Libraries Click Add Class Folder Add a new folder named conf Press all OK Copy my hbase-site.xml into the conf folder Also add the ip-host lists of my HBase cluster into Win 7 hosts file and save. Run the hbase codes and the client can successfully connect to Zookeeper and HBase master.NOTE: Step 10 is must, otherwise the client will get the hostnames from the Zookeeper instance and will not able to resolve them.
Many thanks everyone.
这篇关于Java客户端连接Zookeeper和HBase失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论