java 如何在类路径中包含 hbase-site.xml
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14326308/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to include hbase-site.xml in the classpath
提问by Alex Vertlieb
I am currently trying to get my HBase code to use the settings specified in my hbase-site.xml. It seems to use default settings instead of what is specified in the hbase-site.xml config file. I have restarted the HBase cluster since updating the files, but it is still not using config files that I updated.
我目前正在尝试让我的 HBase 代码使用我的 hbase-site.xml 中指定的设置。它似乎使用默认设置而不是 hbase-site.xml 配置文件中指定的设置。自从更新文件后,我重新启动了 HBase 集群,但它仍然没有使用我更新的配置文件。
The cluster I am using is 2 nodes, one of which is the master. The config files on both of the nodes specify the IP of the master node as the zookeeper quorum. I believe the problem is that my settings specified in hbase-site.xml are not being used because the code runs fine if I set the zookeeper quorum to the same value as in my hbase-site.xml via code, but the second node cannot contact the master if the quorum is not specified via code.
我使用的集群是 2 个节点,其中一个是主节点。两个节点上的配置文件都将主节点的 IP 指定为 zookeeper 仲裁。我相信问题是我在 hbase-site.xml 中指定的设置没有被使用,因为如果我通过代码将 zookeeper quorum 设置为与我的 hbase-site.xml 中相同的值,代码运行良好,但第二个节点不能如果未通过代码指定法定人数,请联系主人。
config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", masterNodeIP);
I would greatly appreciate instructions or a link on how to include hbase-site.xml into my code's classpath. I develop with Eclipse on a Windows machine and have the HBase environment installed on a Linux cluster. I usually use Eclipse to compile the code, due to dependencies.
我非常感谢有关如何将 hbase-site.xml 包含到我的代码类路径中的说明或链接。我在 Windows 机器上使用 Eclipse 进行开发,并在 Linux 集群上安装了 HBase 环境。由于依赖关系,我通常使用 Eclipse 来编译代码。
Ideally, I want each node in the cluster to use its own config file.
理想情况下,我希望集群中的每个节点都使用自己的配置文件。
Thanks in advance!
提前致谢!
回答by Charles Menguy
If it's using the default regardless of what you put in your hbase-site.xml
, it probably means it is being overriden by another file in your classpath. This is very possible because there is already a conf-site.xml
in the hbase jar.
如果它使用默认值而不管你hbase-site.xml
在你的 . 这是很有可能的,因为conf-site.xml
hbase jar 中已经有一个。
To fix this, edit your classpath to add the directory containing your hbase-site.xml
at the end of the classpath to be sure nothing overrides it. Something like:
要解决此问题,请编辑您的类路径以hbase-site.xml
在类路径的末尾添加包含您的目录,以确保没有任何内容覆盖它。就像是:
java -cp $CLASSPATH:/usr/lib/hbase/conf path.to.your.Mainclass
If it gets too obscure, I would advise running this from command line and not in Eclipse so you can be exactly sure of what you have in your classpath.
如果它变得太模糊,我建议从命令行而不是在 Eclipse 中运行它,这样您就可以完全确定您在类路径中的内容。
Hope that helps.
希望有帮助。