0

当我在 IDE Eclipse 中编写 java 代码访问 hbase 时,总是显示消息“java.net.UnknownHostException”。但是 hbase shell 运行良好。我以伪分发模式将 hadoop 和 hbase 安装在单个 linux 节点上。我的主机名是 yzd。以下是 /etc/hosts 和 hbase-site.xml:

/etc/hosts:
127.0.0.1 localhost yzd

hbase-site.xml:
      <property>
              <name>hbase.rootdir</name>
              <value>hdfs://localhost:9000/hbase</value>
      </property>
      <property>
              <name>hbase.cluster.distributed</name>
              <value>true</value>
      </property>
      <property>
              <name>dfs.replication</name>
              <value>1</value>
      </property>

Error message:
INFO [main] (HBaseRPC.java:117) - Using org.apache.hadoop.hbase.ipc.WritableRpcEngine for org.apache.hadoop.hbase.ipc.HMasterInterface
INFO [main] (HConnectionManager.java:596) - getMaster attempt 0 of 10 failed; retrying after sleep of 1000

java.net.UnknownHostException: unknown host: �  13846@yzdlocalhost
at org.apache.hadoop.hbase.ipc.HBaseClient$Connection.<init>(HBaseClient.java:224)
at org.apache.hadoop.hbase.ipc.HBaseClient.getConnection(HBaseClient.java:954)
at org.apache.hadoop.hbase.ipc.HBaseClient.call(HBaseClient.java:816)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:141)
at com.sun.proxy.$Proxy4.getProtocolVersion(Unknown Source)
at org.apache.hadoop.hbase.ipc.WritableRpcEngine.getProxy(WritableRpcEngine.java:174)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:295)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:272)
at org.apache.hadoop.hbase.ipc.HBaseRPC.getProxy(HBaseRPC.java:324)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getMaster(HConnectionManager.java:579)
at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:94)
at com.hbasebook.hush.schema.SchemaManager.process(SchemaManager.java:126)
at com.hbasebook.hush.HushMain.main(HushMain.java:57)
4

2 回答 2

0

First of all yzd is not host name, its domain name (You should prefer FQDN). Now this line

java.net.UnknownHostException: unknown host: �  13846@yzdlocalhost

clearly says that 13846@yzdlocalhost host is not there. Now you can do followings:

  1. Use IP address instead of hostname in both hbase-site.xml and core-site.xml and check
  2. Then use FQDN in etc/hosts file and tab-separate the values, now you can replace the IP with FQDN
于 2014-07-14T07:56:06.620 回答
0

检查本地 hbase 的版本是否与您在 pom.xml 中用作依赖项的版本匹配。这应该可以解决您的问题。我遇到了同样的问题,我在独立模式下使用 hbase。我希望这可以帮助你。

于 2014-07-14T04:25:27.577 回答