在ubuntu上的eclipse中运行hbase示例

oknrviil  于 2021-06-02  发布在  Hadoop
关注(0)|答案(1)|浏览(433)

我是hbase和hadoop的新手。
我正在ubuntu中以伪模式安装hadoop(1.2.1)和hbase(0.94.27)。
我还使用habse shell成功地创建或向hbase表插入数据。
但当我试图在eclipse中使用javaapi编写一个简单的程序来向表中插入数据时

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/主持人喜欢这样

> 127.0.0.1 localhost
> 127.0.0.1 testuser-VirtualBox

谢谢

mcdcgff0

mcdcgff01#

请在这里查找更多关于您的错误的参考资料,以防您遗漏。快乐编码:)

相关问题