【问题标题】:Run Hbase example in eclipse on ubuntu在 ubuntu 上的 Eclipse 中运行 Hbase 示例
【发布时间】:2015-05-30 13:51:27
【问题描述】:

我是 Hbase 和 Hadoop 的新手。

我在 Ubuntu 中以伪模式设置 Hadoop (1.2.1) 和 hbase (0.94.27)。

我也在使用 habse shell 成功创建或插入数据到 hbase 表。

但是当我尝试编写一个简单的程序以在 Eclipse 中使用 Java API 将数据插入表时

public class HbaseTest {
     public static void main(String[] args) throws Exception {
         Configuration conf = HBaseConfiguration.create();
         HBaseAdmin admin = new HBaseAdmin(conf);
         try {
             HTable table = new HTable(conf, "test-table");
             Put put = new Put(Bytes.toBytes("test-key"));
             put.add(Bytes.toBytes("cf"), Bytes.toBytes("q"), Bytes.toBytes("value"));
             table.put(put);
         } finally {
             admin.close();
         }
     }
}

,我收到以下错误:

15/05/30 01:24:20 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=180000 watcher=hconnection0x0
15/05/30 01:24:20 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
15/05/30 01:24:20 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)
15/05/30 01:24:21 WARN zookeeper.RecoverableZooKeeper: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
15/05/30 01:24:21 INFO util.RetryCounter: Sleeping 2000ms before retry #1...
15/05/30 01:24:22 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
15/05/30 01:24:22 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)

我试图搜索类似的错误,但到目前为止还没有找到解决方案。

有人遇到过这个问题吗?请帮帮我。

另外,我的hbase-site.xml是这样的

>   <configuration> <property>
>         <name>hbase.rootdir</name>
>             <value>hdfs://localhost:54310/hbase</value>
>     </property>
>     <property>
>       <name>hbase.zookeeper.property.dataDir</name>
>       <value>/home/hduser/zookeeper</value>
>       <description>Property from ZooKeeper's config zoo.cfg.
>       The directory where the snapshot is stored.
>       </description>
>     </property> </configuration>

我的 /etc/hosts 像这样

> 127.0.0.1 localhost
> 127.0.0.1 testuser-VirtualBox

谢谢

【问题讨论】:

    标签: hadoop hbase


    【解决方案1】:

    如果您错过了错误,请查看here 以获取更多错误参考。快乐编码:)

    【讨论】:

    • 感谢您的帮助。我已经查看了您的链接,但仍未找到适合我的案例的解决方案。我在 Hbase shell 中可以很好地运行,但在 Eclipse 的 Java 中无法运行程序,它总是显示异常。
    • 还有一件事,我根据本教程配置了Hbase cloudfront.blogspot.in/2012/06/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 2015-11-06
    • 1970-01-01
    • 2019-06-14
    • 1970-01-01
    • 1970-01-01
    • 2012-04-24
    相关资源
    最近更新 更多