简体   繁体   English

如何使用Java API在EC2上远程连接到HBASE

[英]How to connect remotely to HBASE on EC2 with Java API

I have set up an Amazon EC2 cluster using the AWS Console with all the default settings by following Amazon's own tutorial ( http://docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/emr-hbase-launch.html ). 我已按照Amazon自己的教程( http://docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/emr-hbase-launch.html )使用AWS控制台使用所有默认设置设置了Amazon EC2集群。 I have deployed an AMI 3.0.4 that runs Hadoop 2.2.0 and HBASE 0.94.7. 我已经部署了运行Hadoop 2.2.0和HBASE 0.94.7的AMI 3.0.4。 I want to be able to run a java program on my own computer that will connect to HBASE using the JAVA API. 我希望能够在自己的计算机上运行Java程序,该程序将使用JAVA API连接到HBASE。 Previously, I have been able to do this successfully using an Amazon EC2 instance that I set up myself but using a more recent version of HBASE (0.96.1.1-hadoop2) however I am getting the following error under this new cluster set up: 以前,我能够使用自己设置的Amazon EC2实例成功完成此操作,但使用的是HBASE的最新版本(0.96.1.1-hadoop2),但是在此新群集设置下出现以下错误:

Exception in thread "main" org.apache.hadoop.hbase.MasterNotRunningException: com.google.protobuf.ServiceException: java.io.IOException: Call to <MY_EC2_MASTER_INTERNAL_HOST_NAME>/<THE_EC2_MASTER_EXTERNAL_IP>:60000 failed on local exception: java.io.IOException: Connection reset by peer

I have checked that the server is running, I have correctly mapped the EC2 internal host name to the public IP address in my local /etc/hosts file exactly as I had done with the Amazon instance I had set up myself. 我检查了服务器是否正在运行,是否已将EC2内部主机名正确映射到本地/ etc / hosts文件中的公用IP地址,就像我对自己设置的Amazon实例所做的一样。 I also have the right ports open (2181, 60000, 60010, 60020, 60030 - probably don't even need all these) on Amazon and currently accepting traffic from all IP sources (temporarily until I have the setup done right and I resolve this issue). 我还在Amazon上打开了正确的端口(2181、60000、60010、60020、60030-甚至可能不需要所有这些端口),并且目前接受来自所有IP源的流量(暂时直到正确完成设置并解决此问题为止)问题)。

My Java API is using the following configuration (and the last line causes the error): 我的Java API使用以下配置(最后一行会导致错误):

Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", "<EC2_MASTER_PUBLIC_IP_ADDRESS>");
config.set("hbase.zookeeper.property.clientPort","2181");
this.conf = config;
this.tokenizer = ObjectFactory.createOpenNLPTokenizer();
HBaseAdmin.checkHBaseAvailable(this.conf);

Any idea what could be causing the problem? 知道是什么原因引起的吗? Could it be a mismatch between my version of the hbase client (0.96.1.1-hadoop2) and the fact that the Amazon HBase is 0.94.7? 我的hbase客户端版本(0.96.1.1-hadoop2)与Amazon HBase为0.94.7的事实之间可能不匹配吗? I cannot find the HBase client in the maven repository for this version which is why I am using the slightly newer version. 在此版本的Maven存储库中找不到HBase客户端,这就是为什么我使用的是较新的版本。

Dont use jars downloaded from maven repository . 不要使用从maven存储库下载的jar Rather, copy the hbase jar from the lib folder of the AWS EMR cluster and put it in the lib folder of your local machine. 而是从AWS EMR集群的lib文件夹中复制hbase jar并将其放入本地计算机的lib文件夹中。
Now compile your code using copied hbase jar file in classpath ie javac -cp "hbase-jar-copied-location" filename.java and then run. 现在,使用在类路径中复制的hbase jar文件(即javac -cp "hbase-jar-copied-location" filename.java编译代码,然后运行。
Amazon uses some customizations in the hbase jars to suit their needs, that's why programs compiled against hbase jars downloaded from outside maven repositories dont work. 亚马逊在hbase jar中使用了一些自定义设置以满足他们的需求,这就是为什么从外部maven存储库下载的针对hbase jar编译的程序无法正常工作的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM