HBase Java客户端 - 未知主机:localhost.localdomain

时间:2013-08-25 11:57:21

标签: hbase

版本:Hadoop:2.0.0-cdh4.3.1

HBase:0.94.6-cdh4.3.1

我正在运行cloudera快速启动vm(一切都在172.16.144.150上运行),这是我的小HBase Java客户端(HbaseClient.java),HBase客户端在远程机器上运行,它所做的就是:

public static void main(String[] args) throws IOException {
    Configuration config = HBaseConfiguration.create();
    HTable table = new HTable(config, "s1");
    System.out.println(table.getTableName());
}

HBase的-site.xml中:

<property>
    <name>hbase.rootdir</name>
    <value>hdfs://172.16.144.150:8020/hbase</value>
  </property>
  <property>
    <name>zookeeper.znode.parent</name>
    <value>/hbase</value>
  </property>
  .......
  <property>
    <name>zookeeper.znode.rootserver</name>
    <value>root-region-server</value>
  </property>
  <property>
    <name>hbase.zookeeper.quorum</name>
    <value>172.16.144.150</value>
  </property>

当我运行我的Java客户端时,我收到错误unknown host: localhost.localdomain

Initiating client connection, connectString=172.16.144.150:2181 sessionTimeout=60000 watcher=hconnection
zookeeper.disableAutoWatchReset is false
The identifier of this process is 41939@smin-MacBook-Pro.local
Opening socket connection to server cloudera/172.16.144.150:2181. Will not attempt to authenticate using SASL (unknown error)
Socket connection established to cloudera/172.16.144.150:2181, initiating session
Session establishment request sent on cloudera/172.16.144.150:2181
Session establishment complete on server cloudera/172.16.144.150:2181, sessionid = 0x14076b058850045, negotiated timeout = 60000
hconnection Received ZooKeeper Event, type=None, state=SyncConnected, path=null
hconnection-0x14076b058850045 connected

locateRegionInMeta parentTable=-ROOT-, metaLocation={region=-ROOT-,,0.70236052, hostname=localhost.localdomain, port=60020}, 
attempt=0 of 10 failed; retrying after sleep of 1000 because: 
unknown host: localhost.localdomain

Reading reply sessionid:0x14076b058850045, packet:: clientPath:null serverPath:null finished:false header:: 17,3  replyHeader:: 17,460,0  request:: '/hbase,F  response:: s{20,20,1376375496826,1376375496826,0,32,0,0,0,12,430} 
Reading reply sessionid:0x14076b058850045, packet:: clientPath:null serverPath:null finished:false header:: 18,4  replyHeader:: 18,460,0  request:: '/hbase/root-region-server,T  response:: #ffffffff0001b3635323630406c6f63616c686f73742e6c6f63616c646f6d61696e6c6f63616c686f73742e6c6f63616c646f6d61696e2c36303032302c31333737333538373930303037,s{430,430,1377358805621,1377358805621,0,0,0,0,73,0,430} 
hconnection-0x14076b058850045 Retrieved 41 byte(s) of data from znode /hbase/root-region-server and set watcher; localhost.localdomain,60020,1...
Looked up root region location, connection=org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@68a7a3a7; serverName=localhost.localdomain,60020,1377358790007

locateRegionInMeta parentTable=.META., metaLocation=null, attempt=2 of 10 failed; 
retrying after sleep of 1008 because: Unable to find region for s1,,99999999999999 
after 10 tries.

2 个答案:

答案 0 :(得分:2)

在您的客户端中添加以下两行:

config.set("hbase.zookeeper.quorum", "172.16.144.150");
config.set("hbase.zookeeper.property.clientPort","2181");

还要将计算机的主机名和IP添加到客户端的/ etc / hosts文件中。

答案 1 :(得分:1)

最后重新解决了问题,我认为发生的事情是:

  1. 我的Hbase客户端(远程机器)正在寻找zookeeper。它读取本地hbase-site.xml,并在cloudera vm上找到zookeeper,然后找到Hbase master没问题。

  2. 它到达Hbase master,下一步它试图找到我要求的特定HBase表的区域,在我的例子中,它是's1'。它首先找到-ROOT-:

  3.   

    locateRegionInMeta parentTable = -ROOT-,metaLocation = {region = -ROOT - ,, 0.70236052,   hostname = localhost.localdomain,port = 60020} table

    所以我猜的问题是,在hbase中,元数据指向localhost.localdomain,根据我的cloudera vm上的hbase-site.xml,这是正确的。但是我的HBase客户端是远程的,因为它不知道什么是localhost.localdomain。

    通过在我的客户端/ etc / hosts中添加ip和localhost.localdomain映射,它开始工作。