Hadoop 从远程计算机连接到hbase

Hadoop 从远程计算机连接到hbase,hadoop,hbase,Hadoop,Hbase,我有安装habse的VM。 IP:192.168.20.10 我想尝试从桌面连接到hbase: 以下是我正在尝试的> public static void main(String[] args) throws IOException { AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/hbase-beans.xml", HBaseConnection.cla

我有安装habse的VM。 IP:192.168.20.10 我想尝试从桌面连接到hbase: 以下是我正在尝试的>

public static void main(String[] args) throws IOException {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/hbase-beans.xml", HBaseConnection.class);
    context.registerShutdownHook();
            UserRepository userRepository = context.getBean(UserRepository.class);
    List<User> users = userRepository.findAll();

    System.out.println("Number of users = " + users.size());
    System.out.println(users);
}






public List<User> findAll() {
        return hbaseTemplate.find(tableName, "cfInfo", new RowMapper<User>() {

            public User mapRow(Result result, int rowNum) throws Exception {
                return new User(Bytes.toString(result.getValue(CF_INFO, qUser)), 
                                Bytes.toString(result.getValue(CF_INFO, qEmail)),
                                Bytes.toString(result.getValue(CF_INFO, qPassword))

                                );
            }
        });

    }
publicstaticvoidmain(字符串[]args)引发IOException{
AbstractApplicationContext context=new ClassPathXmlApplicationContext(“/META-INF/spring/hbase bean.xml”,HBaseConnection.class);
registerShutdownHook();
UserRepository UserRepository=context.getBean(UserRepository.class);
List users=userRepository.findAll();
System.out.println(“用户数=“+users.size());
System.out.println(用户);
}
公共列表findAll(){
返回hbaseTemplate.find(tableName,“cfInfo”,new RowMapper(){
公共用户mapRow(Result-Result,int-rowNum)引发异常{
返回新用户(Bytes.toString(result.getValue(CF_INFO,qUser)),
Bytes.toString(result.getValue(CF_INFO,qEmail)),
Bytes.toString(result.getValue(CF_INFO,qPassword))
);
}
});
}
这是我的bean.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:hadoop="http://www.springframework.org/schema/hadoop" xmlns:lang="http://www.springframework.org/schema/lang"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">

    <context:component-scan base-package="com.hbase.dao"/>
    <context:component-scan base-package="com.hbase.object"/>

     <hadoop:configuration id="hadoopConfiguration">fs.default.name=hdfs://192.168.20.10:9000</hadoop:configuration>


    <hadoop:hbase-configuration configuration-ref="hadoopConfiguration" zk-port="2181" zk-quorum="192.168.20.10"></hadoop:hbase-configuration>

    <bean id="hbaseTemplate" class="org.springframework.data.hadoop.hbase.HbaseTemplate">
        <property name="configuration" ref="hbaseConfiguration" />
    </bean>

</beans>

fs.default.name=hdfs://192.168.20.10:9000
当我直接在远程计算机上运行时,此代码工作正常。当我通过提供hbase的ip从windows计算机上运行相同的代码时,它不会返回任何值

配置windows计算机
C:\windows\System32\drivers\etc\hosts
文件来解析您的HBase群集节点详细信息。建议确保 DNS配置正确!。i、 e.所有国家的地址 从windows解析HBase群集的节点(RegionServer) 机器


您能够从主机ping您的VM ip地址吗?您还可以从主机远程登录ZooKeeper和Hadoop端口。这可能只是网络连接问题,而不是hbase问题