使用spring data hadoop连接到cloudera quickstart vm hbase时出现未知主机异常

ghhkc1vu  于 2021-06-09  发布在  Hbase
关注(0)|答案(1)|浏览(386)

我将quickstart vms用于cdh 5.3.x
我尝试为hbase实现这个spring hadoop示例
该示例将从主机连接到虚拟机中的hbase以创建表、添加数据、读取数据。
在我的pom里我用

  1. <properties>
  2. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  3. <spring.version>4.0.5.RELEASE</spring.version>
  4. <spring.hadoop.version>2.1.2.RELEASE-cdh5</spring.hadoop.version>
  5. <hadoop.version>2.5.0-cdh5.3.0</hadoop.version>
  6. <hbase.version>0.98.6-cdh5.3.0</hbase.version>
  7. </properties>

我的hbase.propertise文件:

  1. hbase.zk.host=172.30.119.25
  2. hbase.zk.port=2181

my application-context.xml:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:hdp="http://www.springframework.org/schema/hadoop"
  6. xmlns:p="http://www.springframework.org/schema/p"
  7. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd">
  8. <context:property-placeholder location="hbase.properties"/>
  9. <context:component-scan base-package="org.springframework.samples.hadoop.hbase"/>
  10. <hdp:configuration id="hadoopConfiguration">
  11. fs.defaultFS=hdfs://172.30.119.25:8020
  12. </hdp:configuration>
  13. <hdp:hbase-configuration id="hbaseConfiguration" configuration-ref="hadoopConfiguration" zk-quorum="${hbase.zk.host}" zk-port="${hbase.zk.port}"/>
  14. <bean id="hbaseTemplate" class="org.springframework.data.hadoop.hbase.HbaseTemplate">
  15. <property name="configuration" ref="hbaseConfiguration"/>
  16. </bean>
  17. </beans>

运行示例时,我遇到了以下异常:

  1. Exception in thread "main" org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=35, exceptions:
  2. Wed Jul 15 16:01:24 ICT 2015, org.apache.hadoop.hbase.client.RpcRetryingCaller@35988e16, java.net.UnknownHostException: unknown host: quickstart.cloudera

有人能帮我解决这个例外吗?

omqzjyyz

omqzjyyz1#

如果您在虚拟机之外运行客户端,请尝试添加 quickstart.cloudera 并将其外部虚拟机ip接入 /etc/hosts .
这些虚拟机通常不是为从外部使用而设计的,但是cloudera的虚拟机比hortonwork的虚拟机更友好一些。

相关问题