通过java程序从另一台windows计算机访问windows hbase

igetnqfo  于 2021-06-09  发布在  Hbase
关注(0)|答案(0)|浏览(296)

我在windows机器上有hbase。
我试图通过java程序从另一台windows机器上访问相同的内容。
连接拒绝错误的结果。
注:
我在linux上也试过同样的方法,效果很好。我在linux机器上安装了hbase,并通过java从windows机器上访问它。只有在尝试从linux或windows访问windows hbase时才会出现问题
hbase-env.sh地址:
以下两行未注解;

set HBASE_MANAGES_ZK=true

set JAVA_HOME=C:\jdk

hbase-site.xml:

<configuration>
    <property>
        <name>hbase.rootdir</name>
        <value>D:\hbaseInstalledPath</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.dataDir</name>
        <value>D:\zookeeperDataDirPath</value>
    </property>
    <property>
        <name>hbase.zookeeper.recoverable.waittime</name>
        <value>30000</value>
    </property>
    <property>
        <name>zookeeper.session.timeout</name>
        <value>180000</value>
    </property>
    <property>
        <name>hbase.master</name>
        <value>'HBase running IP'</value>
    </property>
    <property>
        <name>hbase.cluster.distributed</name>
        <value>false</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.clientPort</name>
        <value>2181</value>
    </property>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>'HBase running IP' , 'JavaClient IP'</value>
    </property>
</configuration>

java代码:

HConnection connection=null;
Configuration config=HBaseConfiguration.create();
config.clear();
config.set("hbase.zookeeper.quorum","172.16.101.82");
config.set("hbase.zookeeper.property.clientPort","2181");
try {
connection=HConnectionManager.createConnection(config);
}
catch(Exception e)
{ }
try {
HTableInterface table=connection.getTable(TableName.valueOf("sample"));
}
catch(Exception e)
{ }

例外情况:

Exception in connection creationorg.apache.hadoop.hbase.MasterNotRunningException: 
com.google.protobuf.ServiceException: org.apache.hadoop.net.ConnectTimeoutException:
20000 millis timeout while waiting for channel to be ready for connect. ch : 
java.nio.channels.SocketChannel[connection-pending 
remote=synclapn4948/172.16.101.82:54422]

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题