1

I'm newbie in Hbase and Hadoop.

I'm setup Hadoop (1.2.1) and hbase (0.94.27) in pseudo mode in Ubuntu.

I'm also use habse shell to create or insert data to hbase table successfully.

But when I try to write a simple program to insert data to table by using Java API in 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();
         }
     }
}

, I got this error following:

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)

I tried to search similar error but not yet find solution so far.

Do anybody have experience with this problem? Please help me.

In addition, my hbase-site.xml like this

>   <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>

my /etc/hosts like this

> 127.0.0.1 localhost
> 127.0.0.1 testuser-VirtualBox

Thanks

ndk076
  • 165
  • 12

1 Answers1

0

Please look here for more references of your error in case you missed it. Happy coding :)

Community
  • 1
  • 1
Ramzy
  • 6,948
  • 6
  • 18
  • 30
  • Thanks for your help. I already looked at your link but still not yet find solution for my case. I can run well in Hbase shell but can not run program in Eclipse's Java, it always show that exception. – ndk076 Jun 01 '15 at 07:15
  • one more thing, I configured Hbase base on this tutorial http://cloudfront.blogspot.in/2012/06/how-to-configure-habse-in-pseudo.html#.VWzsBM9VhBe – ndk076 Jun 01 '15 at 07:32