Java客户机无法连接到Zookeeper和HBase

时间:2020-12-20 09:50:01

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).

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

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.

现在,在eclipse类路径中,我添加了所有的HBase libs和HBase -0.94.7。jar(包含hbase-default)。xml文件)。我还添加了最初的hbase站点。项目中的集群中的xml文件。

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.

最初,我使用未修改的hbase-default运行客户端代码。xml和我发现的客户端正在尝试与localhost进行zookeeper实例的通信。因此忽略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.

然后我修改了3个参数,它保存了主/Zookpeer服务器的公共IP地址,并再次尝试。这一次,我得到了下面的错误,客户端不断尝试连接Zookeeper和它的其他quorum成员。

I have all the 4 servers in the Zookeeper quorum and lets say their IP addresses are:

我有Zookeeper quorum的所有4个服务器,我们说他们的IP地址是:

  • W.W.W.W // HBase master and Zookeeper Server

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

  • X.X.X.X // HBase RS and Zookeeper Quorum Member

    X.X.X.X / HBase RS和Zookeeper管理员Quorum成员

  • Y.Y.Y.Y // HBase RS and Zookeeper Quorum Member

    Y.Y.Y.Y / HBase RS和动物管理员Quorum成员

  • Z.Z.Z.Z // HBase RS and Zookeeper Quorum Member

    Z.Z.Z.Z // HBase RS和Zookeeper管理员Quorum成员


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

... and so on

…等等

1 个解决方案

#1


2  

The Problem has been solved.

问题已经解决了。

Solution:

  1. Right Click on the Project in Eclipse
  2. 在Eclipse中右键单击项目
  3. Go to Properties
  4. 去属性
  5. Select Java Build Path
  6. 选择Java构建路径
  7. Go to Libraries
  8. 去图书馆
  9. Click Add Class Folder
  10. 单击Add类文件夹
  11. Add a new folder named conf
  12. 添加一个名为conf的新文件夹
  13. Press all OK
  14. 媒体都好
  15. Copy my hbase-site.xml into the conf folder
  16. 我的hbase-site副本。xml到conf文件夹
  17. Also add the ip-host lists of my HBase cluster into Win 7 hosts file and save.
  18. 还可以将HBase集群的ip-host列表添加到Win 7主机文件并保存。
  19. Run the hbase codes and the client can successfully connect to Zookeeper and HBase master.
  20. 运行hbase代码,客户端可以成功连接到Zookeeper和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.

注意:步骤10是必须的,否则客户端将从Zookeeper实例获取主机名,并不能解决它们。

Many thanks everyone.

非常感谢每一个人。

#1


2  

The Problem has been solved.

问题已经解决了。

Solution:

  1. Right Click on the Project in Eclipse
  2. 在Eclipse中右键单击项目
  3. Go to Properties
  4. 去属性
  5. Select Java Build Path
  6. 选择Java构建路径
  7. Go to Libraries
  8. 去图书馆
  9. Click Add Class Folder
  10. 单击Add类文件夹
  11. Add a new folder named conf
  12. 添加一个名为conf的新文件夹
  13. Press all OK
  14. 媒体都好
  15. Copy my hbase-site.xml into the conf folder
  16. 我的hbase-site副本。xml到conf文件夹
  17. Also add the ip-host lists of my HBase cluster into Win 7 hosts file and save.
  18. 还可以将HBase集群的ip-host列表添加到Win 7主机文件并保存。
  19. Run the hbase codes and the client can successfully connect to Zookeeper and HBase master.
  20. 运行hbase代码,客户端可以成功连接到Zookeeper和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.

注意:步骤10是必须的,否则客户端将从Zookeeper实例获取主机名,并不能解决它们。

Many thanks everyone.

非常感谢每一个人。