hbase mapreduce作业加载配置(hbase site.xml),但实际上没有

wpcxdonn  于 2021-06-03  发布在  Hadoop
关注(0)|答案(1)|浏览(334)

我正在写一个mapreduce作业,它读取hbase表。几乎所有的东西都能正常工作除了 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,但它似乎已经关闭引用本地配置问题(我认为不是)和一个问题,所以这里可能是类似于我的查询,但没有答案。我使用cdh5.0.2和hbase 0.96.1.1。任何见解都将不胜感激。

xnifntxz

xnifntxz1#

今天我遇到了类似的事情。
实际上:当我从ide运行它时,我的作业将“localhost”作为hbase.zookeeper.quorum。
原因是'yarn'和'hadoop'脚本在启动java运行时之前将config dir(即hbase-site.xml所在的位置)添加到类路径。当我从ide运行时,这根本就没有完成。
现在,当您创建hbase config时,将加载两个文件:
hbase-default.xml:这是其中一个hbase jar的一部分,因此始终可以找到它。
hbase-site.xml:这是在config dir中,这个config dir应该在类路径上,并且可以推翻默认设置中的一些设置。
我通过在我的应用程序中使用这样的代码段(从这里复制)打印类路径来验证这一点

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

通过打印

config.get("hbase.zookeeper.quorum") :

我怀疑你也有类似的问题。
我考虑的一件事是获取“hadoop\u conf\u dir”环境变量,并确保它是类路径的一部分,如果不是,则给出警告。

相关问题