1. 程式人生 > >java.net.UnknownHostException: master (HBase報錯)

java.net.UnknownHostException: master (HBase報錯)

錯誤如下:

Caused by: java.lang.IllegalArgumentException: java.net.UnknownHostException: master
	at org.apache.hadoop.security.SecurityUtil.buildTokenService(SecurityUtil.java:373)
	at org.apache.hadoop.hdfs.NameNodeProxies.createNonHAProxy(NameNodeProxies.java:258)
	at org.apache.hadoop.hdfs.NameNodeProxies.createProxy(NameNodeProxies.java:153)
	at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:602)
	at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:547)
	at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:139)

造成報錯的原因:
hbase-site.xml
hdfs://master:9000/hbase 的master需要在hosts檔案下配置

<configuration>
<property>
    <name>hbase.rootdir</name>
    <value>hdfs://master:9000/hbase</value>
  </property>
  <property>
     <name>hbase.cluster.distributed</name>
     <value>true</value>
  </property>
  <property>
     <name>hbase.master.port</name>
     <value>16000</value>
  </property>
   <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/usr/local/data/zkdata</value>
  </property>
  <property>
    <name>hbase.zookeeper.quorum</name>
    <value>node1,node2,node3</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.clientPort</name>
    <value>2181</value>
  </property>
</configuration>

解決方案:
修改Linux下的/etc/hosts檔案,更改成如下

	192.168.25.121 node1 master
	192.168.25.122 node2
	192.168.25.123 node3