如何在类路径中包含 hbase-site.xml [英] How to include hbase-site.xml in the classpath

查看:25
本文介绍了如何在类路径中包含 hbase-site.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试让我的 HBase 代码使用在我的 hbase-site.xml 中指定的设置.它似乎使用默认设置而不是 hbase-site.xml 配置文件中指定的设置.更新文件后,我重新启动了 HBase 集群,但它仍然没有使用我更新的配置文件.

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.

我使用的集群是 2 个节点,其中一个是主节点.两个节点上的配置文件都将主节点的 IP 指定为 zookeeper 仲裁.我相信问题是我在 hbase-site.xml 中指定的设置没有被使用,因为如果我通过代码将 zookeeper quorum 设置为与我的 hbase-site.xml 中相同的值,代码运行良好,但第二个节点不能如果没有通过代码指定法定人数,请联系 master.

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.

config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", masterNodeIP);

我非常感谢有关如何将 hbase-site.xml 包含到我的代码的类路径中的说明或链接.我在 Windows 机器上使用 Eclipse 进行开发,并在 Linux 集群上安装了 HBase 环境.由于依赖关系,我通常使用 Eclipse 来编译代码.

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.

理想情况下,我希望集群中的每个节点都使用自己的配置文件.

Ideally, I want each node in the cluster to use its own config file.

提前致谢!

推荐答案

如果它使用默认值而不管你在 hbase-site.xml 中放了什么,这可能意味着它被覆盖了类路径中的另一个文件.这是很有可能的,因为hbase jar 中已经有一个conf-site.xml.

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 的目录,以确保没有任何内容覆盖它.类似的东西:

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:

java -cp $CLASSPATH:/usr/lib/hbase/conf path.to.your.Mainclass

如果它变得太模糊,我建议从命令行而不是在 Eclipse 中运行它,这样您就可以完全确定您的类路径中的内容.

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.

希望有所帮助.

这篇关于如何在类路径中包含 hbase-site.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆