【问题标题】:HBase MapReduce job loads configuration (hbase-site.xml), but actually doesn'tHBase MapReduce 作业加载配置(hbase-site.xml),但实际上没有
【发布时间】:2014-06-30 23:30:07
【问题描述】:

我正在编写一个从 (a) HBase 表中读取的 MapReduce 作业。除了Configuration 类之外,几乎所有东西都可以正常工作。所以我这样做了,

Configuration config = HBaseConfiguration.create();
GenericOptionsParser parser = new GenericOptionsParser(config, args);
// This should work but is not working.
config.addResource(new Path(parser.getCommandLine().getOptionValue("conf", DEFAULT_HBASE_CONF)));

当我像这样运行作业时(正确地将路径传递给hbase-site.xml),我收到了这个错误。

14/06/30 23:02:30 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:735)
    at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1075)
14/06/30 23:02:30 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)

但是当我添加以下两行时,它就像一个魅力(即使它看起来完全荒谬)。

// So these are the workarounds.
config.set("hbase.rootdir", config.get("hbase.rootdir"));
config.set("hbase.zookeeper.quorum", config.get("hbase.zookeeper.quorum"));

基本上,从Configuration 对象中读回参数并将它们设置回同一个对象中,这很疯狂。

我读到了一个关于它的错误HBASE-11066,但它似乎已经关闭,理由是本地配置问题(我认为不是)和一个 SO 问题here 这可能与我的查询类似,但还没有答案.我将 CDH 5.0.2 与 HBase 0.96.1.1 一起使用。任何见解都将不胜感激。

【问题讨论】:

    标签: hadoop mapreduce hbase


    【解决方案1】:

    今天我遇到了类似的事情。

    实际上:当我从 IDE 运行时,我的工作将“localhost”作为 hbase.zookeeper.quorum。

    原因是“yarn”和“hadoop”脚本在启动 java 运行时之前将配置目录(即 hbase-site.xml 所在的位置)添加到类路径中。 当我从我的 IDE 运行时,这根本没有完成。

    现在,当您创建 HBase 配置时,会加载两个文件:

    • hbase-default.xml:这是其中一个 hbase jar 的一部分,因此始终可以找到。
    • hbase-site.xml:这是在配置目录中,这个配置目录应该在类路径中,并且可以覆盖一些默认设置。

    我通过使用像这样 (copied from here) 的 sn-p 从我的应用程序中打印类路径来验证这一点

    ClassLoader cl = ClassLoader.getSystemClassLoader();
    URL[] urls = ((URLClassLoader)cl).getURLs();
    for(URL url: urls){
        System.out.println(url.getFile());
    }
    

    并通过打印

    的结果
    config.get("hbase.zookeeper.quorum") :
    

    我怀疑你也有类似的问题。

    我正在考虑的一件事是获取“HADOOP_CONF_DIR”环境变量并确保它是类路径的一部分,如果它没有给出警告。

    【讨论】:

    • 但我确实将hbase-site.xml 添加为资源。
    • HBaseConfiguration.create();也这样做。但如果它不在类路径上,那么实际上什么都不会加载。
    • 据我所知,HBaseConfiguration.create(); 创建了一个 Configuration 对象,其中包含 HBase 安装的所有默认值。然后,当您将 hbase-site.xml 添加为资源时,将从文件中读取值并进行更新。这适用于非 mapreduce 项目,但对于 MapReduce 项目,它似乎不起作用。
    • 我昨天跟踪了代码,它还添加了 hbase-site.xml 作为资源。
    • 是的,但是如果 ir 不是类路径的一部分怎么办。然后它无法读取它。那是我们手动将其添加为资源的时候。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-16
    • 2014-06-09
    相关资源
    最近更新 更多