gpt4 book ai didi

hadoop - 在 ubuntu 上的 eclipse 中运行 Hbase 示例

转载 作者:可可西里 更新时间:2023-11-01 16:11:13 25 4
gpt4 key购买 nike

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

谢谢

最佳答案

请看here以防您错过错误的更多引用。快乐编码:)

关于hadoop - 在 ubuntu 上的 eclipse 中运行 Hbase 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30531254/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com