【问题标题】:how to configure for test hbase program如何配置测试hbase程序
【发布时间】:2016-03-18 15:34:35
【问题描述】:

我是 hadoop 和 hbase 的新手,并在 windows8 中安装了 hadoop。 我启动 hadoop Like image 并通过字数统计程序测试 map-reduce 并且它的工作。(在 Eclipse 中)

但是我不能使用 hbase!我为 Eclipse 使用了一个 hbase 插件。 (来自eclipse市场网站) 我有一个用于连接和创建表的类,......

  public class HBaseConnector {

private static Configuration configuration = null;
private static HTable hTable;
private static HBaseAdmin admin;
private static Logger logger = Logger.getLogger(HBaseConnector.class);

static {
    configuration = HBaseConfiguration.create();
}

public void creatTable(String tableName, String[] familys) {

    try {
        admin = new HBaseAdmin(configuration);

        if (admin.tableExists(tableName)) {

            logger.debug(tableName + "table already exists !!");

        } else {

            HTableDescriptor tableDesc = new HTableDescriptor(tableName);
            for (int i = 0; i < familys.length; i++) {
                tableDesc.addFamily(new HColumnDescriptor(familys[i]));
            }
            admin.createTable(tableDesc);
            logger.debug(tableName + " table created successfully !! ");

        }
        admin.close();

    } catch (MasterNotRunningException e) {
        logger.error(e.getMessage());
    } catch (ZooKeeperConnectionException e) {
        logger.error(e.getMessage());
    } catch (IOException e) {
        logger.error(e.getMessage());
    }

}

在主函数中我有这些代码:

  String tablename = "employee";
        String[] familys = { "personal", "professional" };

        HBaseConnector connector = new HBaseConnector();
        connector.creatTable(tablename, familys);

但无法连接:

    18:59:34 WARN zookeeper.RecoverableZooKeeper: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/master
16/03/18 18:59:34 INFO util.RetryCounter: Sleeping 4000ms before retry #2...
16/03/18 18:59:34 INFO zookeeper.ClientCnxn: Opening socket connection to server 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (Unable to locate a login configuration)
16/03/18 18:59:34 ERROR zookeeper.ClientCnxnSocketNIO: Unable to open socket to 0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181
16/03/18 18:59:34 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.SocketException: Address family not supported by protocol family: connect
    at sun.nio.ch.Net.connect(Native Method)
    at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
    at org.apache.zookeeper.ClientCnxnSocketNIO.registerAndConnect(ClientCnxnSocketNIO.java:266)
    at org.apache.zookeeper.ClientCnxnSocketNIO.connect(ClientCnxnSocketNIO.java:276)
    at org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:958)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:993)
16/03/18 18:59:34 DEBUG zookeeper.ClientCnxnSocketNIO: Ignoring exception during shutdown input
java.nio.channels.ClosedChannelException

我如何运行一个简单的 HBase 程序?

【问题讨论】:

    标签: java eclipse hadoop hbase hadoop2


    【解决方案1】:

    在我看来,您忘记安装或启动 HBase。 HBase 是一个额外的组件,据我所知,您只运行 HDFS 和 Yarn。

    您的最后一条日志消息说它无法连接到 Zookeeper。它是 Hadoop 组件的(分布式)键/值存储。您的简单 HBase 程序正在尝试连接到 Zookeeper 并获取值 /hbase/master znode。它这样做失败了,因此它无法继续并连接到 HBase 主服务器。

    安装 HBase master + 至少一个 RegionServer。如果您遵循安装文档,您还将与 Zookeeper 打交道:

    https://hbase.apache.org/book.html#standalone_dist

    我的个人建议:除非出于某种原因确实需要 1.2.0,否则请使用 1.1.3 而不是 1.2.0。我无法启动 1.2.0。

    【讨论】:

    • 我在启动 hbase 时出错:d:\hadoop-2.3.0\hbase-1.1.3\bin>start-hbase.cmd 线程“main”中的异常 java.lang.NoClassDefFoundError: org/apache/hadoop/hba...... org.apache.hadoop.hbase.util.HBaseConfTool。程序将会退出。错误:无法确定启动模式。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-14
    • 2018-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-31
    • 2017-07-21
    相关资源
    最近更新 更多