HBase Java 客户端无法访问远程 HBase 区域服务器
Posted
技术标签:
【中文标题】HBase Java 客户端无法访问远程 HBase 区域服务器【英文标题】:HBase Java client can't reach to remote HBase region server 【发布时间】:2014-02-21 02:50:43 【问题描述】:我已经在服务器中启动了一个独立的 HBase(192.168.36.42
)
客户端
package com.test;
import java.util.ArrayList;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
public class HBaseClient
public static void main(String[] args) throws Exception
Configuration config = HBaseConfiguration.create();
System.out.println("IP Address : " + config.get("hbase.zookeeper.quorum"));
HTable table = new HTable(config, "test_table");
ArrayList<Put> data = new ArrayList<Put>();
Put p = new Put("row3".getBytes());
p.add("field1".getBytes(), "qualifier".getBytes(), "value".getBytes());
table.put(data);
table.flushCommits();
data.clear();
table.close();
System.out.println("close table");
这是客户端的控制台输出:
14/02/26 16:21:31 INFO ipc.HBaseRPC: Server at BJ-NQ-V-CR002/192.168.36.42:44525 could not be reached after 1 tries, giving up.
14/02/26 16:21:33 INFO ipc.HBaseRPC: Server at BJ-NQ-V-CR002/192.168.36.42:44525 could not be reached after 1 tries, giving up.
14/02/26 16:21:35 INFO ipc.HBaseRPC: Server at BJ-NQ-V-CR002/192.168.36.42:44525 could not be reached after 1 tries, giving up.
14/02/26 16:21:37 INFO ipc.HBaseRPC: Server at BJ-NQ-V-CR002/192.168.36.42:44525 could not be reached after 1 tries, giving up.
客户端/etc/host
:
192.168.36.42 BJ-NQ-V-CR002
hbase-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hbase.zookeeper.quorum</name>
<value>BJ-NQ-V-CR002</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
</configuration>
服务器端
hbase(main):003:0> describe 'test_table'
DESCRIPTION ENABLED
'test_table', NAME => 'field1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', true
VERSIONS => '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false',
BLOCKSIZE => '65536', IN_MEMORY => 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true', NAME => 'field2', D
ATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION => 'N
ONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY =>
'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'
1 row(s) in 0.1680 seconds
/etc/hosts
127.0.0.1 BJ-NQ-V-CR002
127.0.0.1 localhost localhost.localdomain
192.168.36.42 BJ-NQ-V-CR002
hbase-site.xml
<configuration>
<property>
<name>hbase.zookeeper.quorum</name>
<value>BJ-NQ-V-CR002</value>
</property>
<property>
<name>hbase.rootdir</name>
<value>file:///root/hbase-0.94.16/data/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/root/hbase-0.94.16/data/zookeeper</value>
</property>
</configuration>
区域服务器
BJ-NQ-V-CR002
【问题讨论】:
【参考方案1】:您的日志没有显示任何超时异常,只是一些 zookeeper 输出。不过,我以前见过这个。
检查您是否可以从 hbase shell 中put
。您可能只有一个为该表提供服务的区域服务器,并且它存在问题。有问题的区域服务器已关闭或表文件在 hdfs 上不可用。
重启区域服务器并查看其日志
【讨论】:
我可以直接从 hbase shellput
数据到 test_table
。我是 HBase 新手,我以独立模式启动 HBase(这意味着主服务器和区域服务器在同一台机器上)
以上是关于HBase Java 客户端无法访问远程 HBase 区域服务器的主要内容,如果未能解决你的问题,请参考以下文章