简体   繁体   English

HBase:Zookeeper告诉远程客户端连接到localhost

[英]HBase: Zookeeper tells remote client to connect to localhost

Super new to HBase/Hadoop here. 这里是HBase / Hadoop的新手。 I got a two-node HBase test cluster up and running, and I'm now trying to connect to that cluster from a remote Java client. 我启动并运行了一个双节点HBase测试集群,现在我正在尝试从远程Java客户端连接到该集群。 Here's where I'm stuck: the client successfully connects to the single-server Zookeeper quorum (running on the same server as the HBase master), but the address passed back to the client by Zookeeper is localhost, and (obviously) the client fails to connect to anything because HBase isn't running locally. 这就是我被困住的地方:客户端成功连接到单服务器Zookeeper仲裁(在与HBase主服务器相同的服务器上运行),但Zookeeper传递回客户端的地址是localhost,(显然)客户端失败连接到任何东西,因为HBase没有在本地运行。 Considering that I can't edit the client-side hosts file for administrative reasons (and in any case I'm not inclined to since that seems like an awful hack), is there a way to get Zookeeper to return a proper IP for the HBase master server? 考虑到我出于管理原因无法编辑客户端主机文件(并且在任何情况下我都不倾向于因为这看起来像是一个糟糕的黑客),有没有办法让Zookeeper返回适当的IP用于HBase主服务器?

Java code: Java代码:

public static final String MASTER_IP = "10.3.248.105";
public static final String ZOOKEEPER_PORT = "2181";

Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", MASTER_IP);
config.set("hbase.zookeeper.property.clientPort", ZOOKEEPER_PORT);

System.out.println("Running connecting test...");

try {
    HBaseAdmin.checkHBaseAvailable(config);
    System.out.println("HBase found!");
    HTable table = new HTable(config, "testTable");
    System.out.println("Table testTable obtained!");
} catch (MasterNotRunningException e) {
    System.out.println("HBase connection failed!");
    e.printStackTrace();
} catch (ZooKeeperConnectionException e) {
    System.out.println("Zookeeper connection failed!");
    e.printStackTrace();
} catch (Exception e) { e.printStackTrace(); }

Error dump: 错误转储:

13/06/27 11:20:25 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=10.3.248.105:2181 sessionTimeout=180000 watcher=hconnection
13/06/27 11:20:25 INFO zookeeper.RecoverableZooKeeper: The identifier of this process is 5896@HQNJVCVM0004
13/06/27 11:20:29 INFO zookeeper.ClientCnxn: Opening socket connection to server 10.3.248.105/10.3.248.105:2181. Will not attempt to authenticate using SASL (unknown error)
13/06/27 11:20:29 INFO zookeeper.ClientCnxn: Socket connection established to 10.3.248.105/10.3.248.105:2181, initiating session
13/06/27 11:20:29 INFO zookeeper.ClientCnxn: Session establishment complete on server 10.3.248.105/10.3.248.105:2181, sessionid = 0x13f8638485c0003, negotiated timeout = 180000
13/06/27 11:20:30 INFO client.HConnectionManager$HConnectionImplementation: getMaster attempt 0 of 1 failed; no more retrying.
java.net.UnknownHostException: unknown host: localhost.localdomain
HBase connection failed!
at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.<init>(HBaseClient.java:276)
at org.apache.hadoop.hbase.ipc.HBaseClient.createConnection(HBaseClient.java:255)
at org.apache.hadoop.hbase.ipc.HBaseClient.getConnection(HBaseClient.java:1111)
at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:974)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:86)
at com.sun.proxy.$Proxy5.getProtocolVersion(Unknown Source)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine.getProxy(WritableRpcEngine.java:138)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getMaster(HConnectionManager.java:712)
at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:126)
at org.apache.hadoop.hbase.client.HBaseAdmin.checkHBaseAvailable(HBaseAdmin.java:1781)
at hbaseimagestore.HBaseImageStore.main(HBaseImageStore.java:44)
13/06/27 11:20:30 INFO client.HConnectionManager$HConnectionImplementation: Closed zookeeper sessionid=0x13f8638485c0003
13/06/27 11:20:30 INFO zookeeper.ZooKeeper: Session: 0x13f8638485c0003 closed
org.apache.hadoop.hbase.MasterNotRunningException: Retried 1 times
at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:138)
at org.apache.hadoop.hbase.client.HBaseAdmin.checkHBaseAvailable(HBaseAdmin.java:1781)
at hbaseimagestore.HBaseImageStore.main(HBaseImageStore.java:44)
13/06/27 11:20:30 INFO zookeeper.ClientCnxn: EventThread shut down

Edit: also, the /etc/hosts file on the master/zookeeper server: 编辑:还有,master / zookeeper服务器上的/ etc / hosts文件:

10.3.248.105   master
10.3.248.106   slave
127.0.0.1   localhost

I don't know if it is the best way to do this, but it should do the trick. 我不知道这是否是最好的方法,但它应该做到这一点。 Change the master's hosts file to : 将master的hosts文件更改为:

10.3.248.105   master     localhost
10.3.248.106   slave
#127.0.0.1   localhost

Restart hbase after this change. 此更改后重新启动hbase。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM