因此,我试图使用自定义jar查询我的Amazon EC2上的hbase集群,我作为MapReduce步骤启动。 IM我的罐子(map函数里面)我叫HBase的像这样:从亚马逊EMR上的java使用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 [email protected]
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应该自动通过亚马逊bootstrap正确连接。
即时通讯使用hbase 0.94.17 jar和amazon正在运行hbase 0.94.7 im很确定这不是问题,我猜测它更多的是我没有正确设置Java代码。如果有人可以帮助这个itd将不胜感激。谢谢
所以通过在代码中设置zookeeper仲裁(conf.set(“hbase.zookeeper.quorum”,“”);) 我能够得到它的工作,但我不能硬编码我的主节点ip每次进入我的java。看来,如果我不这样做,法定人数从一些配置作为'本地主机'而不是主节点仲裁,这是在我的hadoop配置(hdfs网站,mapred站点等)设置 本地主机被拉从? –