2015-05-29 63 views
1

我是Hbase和Hadoop中的新手。在ubuntu上運行eclipse中的Hbase示例

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

我也使用habse shell成功創建或插入數據到hbase表。

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) 

我試圖尋找類似:

但是,當我嘗試寫一個簡單的程序在Eclipse中

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

使用Java API將數據插入到表,我下面得到這個錯誤錯誤,但目前尚未找到解決方案。

有沒有人有這個問題的經驗?請幫幫我。

另外,我的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> 

這樣

> 127.0.0.1 localhost 
> 127.0.0.1 testuser-VirtualBox 

感謝我的/ etc/hosts文件

回答

0

請看here你的錯誤的更多的參考資料以防你錯過了它。快樂編碼:)

+0

感謝您的幫助。我已經看過你的鏈接,但仍未找到解決方案。我可以在Hbase shell中運行良好,但不能在Eclipse的Java中運行程序,它總是顯示異常。 – ndk076

+0

還有一件事,我在本教程中配置了Hbase基礎http://cloudfront.blogspot.in/2012/06/how-to-configure-habse-in-pseudo.html#.VWzsBM9VhBe – ndk076