【问题标题】:HBase: Zookeeper tells remote client to connect to localhostHBase:Zookeeper 告诉远程客户端连接到 localhost
【发布时间】:2013-06-25 05:33:17
【问题描述】:

这里是 HBase/Hadoop 的超级新手。我启动并运行了一个两节点 HBase 测试集群,现在我正尝试从远程 Java 客户端连接到该集群。这是我卡住的地方:客户端成功连接到单服务器Zookeeper quorum(与HBase master在同一台服务器上运行),但Zookeeper传回客户端的地址是localhost,并且(显然)客户端失败连接到任何东西,因为 HBase 不在本地运行。考虑到由于管理原因我无法编辑客户端主机文件(无论如何我都不倾向于这样做,因为这似乎是一个可怕的黑客攻击),有没有办法让 Zookeeper 返回正确的 IP HBase 主服务器?

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(); }

错误转储:

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

编辑:另外,master/zookeeper 服务器上的 /etc/hosts 文件:

10.3.248.105   master
10.3.248.106   slave
127.0.0.1   localhost

【问题讨论】:

    标签: java networking hadoop hbase apache-zookeeper


    【解决方案1】:

    我不知道这是否是最好的方法,但它应该可以解决问题。将master的hosts文件改为:

    10.3.248.105   master     localhost
    10.3.248.106   slave
    #127.0.0.1   localhost
    

    更改后重启 hbase。

    【讨论】:

    • 这成功地让客户端查询master 而不是localhost,但由于master 没有在客户端定义它也无法连接。有没有办法只取回本地 IP 地址而不是主机名,还是我必须设置本地 DNS 或其他东西来处理主机名解析?
    • 在 ZK 的 hosts 文件中做同样的更改,看看是否有帮助。
    • Zookeeper 和 master 在同一台服务器上运行,他们不应该使用相同的主机文件吗?
    • 是的,他们应该这样做。在您的代码中添加这一行并重试:“config.set("hbase.master", "10.3.248.105:60000");"..这根本不是一个整洁的解决方案,但我只是想看看如果它有什么不同。根据您的配置更改端口。
    • 不,仍然尝试查询主服务器但失败。 config.set("hbase.master", foo) 已弃用,我认为?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-26
    • 2020-07-04
    • 2011-07-26
    • 1970-01-01
    • 1970-01-01
    • 2017-09-30
    • 1970-01-01
    相关资源
    最近更新 更多