【发布时间】:2014-04-02 00:59:01
【问题描述】:
所以我尝试使用作为 MapReduce 步骤启动的自定义 jar 来查询我在 Amazon ec2 上的 hbase 集群。我是我的 jar(在 map 函数内)我这样称呼 Hbase:
public void map( Text key, BytesWritable value, Context contex ) throws IOException, InterruptedException {
Configuration conf = HBaseConfiguration.create();
HTable table = new HTable(conf, "tablename");
...
问题是,当它到达 HTable 行并尝试连接到 hbase 时,该步骤失败并且我收到以下错误:
2014-02-28 18:00:49,936 INFO [main] org.apache.zookeeper.ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=180000 watcher=hconnection
2014-02-28 18:00:49,974 INFO [main] org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper: The identifier of this process is 5119@ip-10-0-35-130.ec2.internal
2014-02-28 18:00:49,998 INFO [main-SendThread(localhost:2181)] org.apache.zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2014-02-28 18:00:50,005 WARN [main-SendThread(localhost:2181)] org.apache.zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
...
2014-02-28 18:01:05,542 WARN [main] org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
2014-02-28 18:01:05,542 ERROR [main] org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper: ZooKeeper exists failed after 3 retries
2014-02-28 18:01:05,542 WARN [main] org.apache.hadoop.hbase.zookeeper.ZKUtil: hconnection Unable to set watcher on znode (/hbase/hbaseid)
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
... and on and on
我可以很好地使用 hbase shell,并且可以从 shell 查询数据和所有内容。我不知道从哪里开始,我已经搜索了几个小时没有运气。互联网上的大多数此类问题都没有谈论亚马逊特定的修复。我认为 zookeeper 和 hbase 应该由 amazon bootstrap 自动正确连接。
我正在使用 hbase 0.94.17 jar 并且亚马逊正在运行 hbase 0.94.7 我很确定这不是问题,我猜测更多的是我没有正确设置 Java 代码。如果有人可以提供帮助,将不胜感激。谢谢
【问题讨论】:
-
所以通过在代码中设置 zookeeper 仲裁 (conf.set("hbase.zookeeper.quorum","
"); ) 我能够让它工作,但我每次都无法将我的主节点 ip 硬编码到我的 java 中。似乎如果我不这样做,仲裁是从某个配置中提取的,作为“本地主机”而不是主节点仲裁,这是我的 hadoop 配置(hdfs-site、mapred-site 等)中设置的主节点仲裁从哪里提取本地主机?
标签: hadoop amazon-web-services hbase apache-zookeeper elastic-map-reduce