0
  • 我在 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]
4

0 回答 0