[解决]Spark运行中java.net.UnknownHostException: nameservice1的异常

[Author]: kwu

解决Spark运行中java.net.UnknownHostException: nameservice1的异常,nameservice1是配置hdfs中用到的HA,在执行spark程序时出现 java.net.UnknownHostException: nameservice1异常,找到正确的路径。


分析在CDH5.4中配置文件/etc/hadoop/conf/hdfs-site.xml,此文件记录了hdfs的路径与主节点的配置


hdfs-site.xml 主要配置如下:

[html]  view plain copy
  1. <property>  
  2.     <name>dfs.nameservices</name>  
  3.     <value>nameservice1</value>  
  4.   </property>  
  5.   <property>  
  6.     <name>dfs.client.failover.proxy.provider.nameservice1</name>  
  7.     <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>  
  8.   </property>  
  9.   <property>  
  10.     <name>dfs.ha.automatic-failover.enabled.nameservice1</name>  
  11.     <value>true</value>  
  12.   </property>  
  13.   <property>  
  14.     <name>ha.zookeeper.quorum</name>  
  15.     <value>bdc40.hexun.com:2181,bdc41.hexun.com:2181,bdc46.hexun.com:2181,bdc53.hexun.com:2181,bdc54.hexun.com:2181</value>  
  16.   </property>  
  17.   <property>  
  18.     <name>dfs.ha.namenodes.nameservice1</name>  
  19.     <value>namenode50,namenode85</value>  
  20.   </property>  
  21.   <property>  
  22.     <name>dfs.namenode.rpc-address.nameservice1.namenode50</name>  
  23.     <value>bdc20.hexun.com:8020</value>  
  24.   </property>  
  25.   <property>  
  26.     <name>dfs.namenode.servicerpc-address.nameservice1.namenode50</name>  
  27.     <value>bdc20.hexun.com:8022</value>  
  28.   </property>  
  29.   <property>  
  30.     <name>dfs.namenode.http-address.nameservice1.namenode50</name>  
  31.     <value>bdc20.hexun.com:50070</value>  
  32.   </property>  
  33.   <property>  
  34.     <name>dfs.namenode.https-address.nameservice1.namenode50</name>  
  35.     <value>bdc20.hexun.com:50470</value>  
  36.   </property>  
  37.   <property>  
  38.     <name>dfs.namenode.rpc-address.nameservice1.namenode85</name>  
  39.     <value>bdc220.hexun.com:8020</value>  
  40.   </property>  
  41.   <property>  
  42.     <name>dfs.namenode.servicerpc-address.nameservice1.namenode85</name>  
  43.     <value>bdc220.hexun.com:8022</value>  
  44.   </property>  
  45.   <property>  
  46.     <name>dfs.namenode.http-address.nameservice1.namenode85</name>  
  47.     <value>bdc220.hexun.com:50070</value>  
  48.   </property>  
  49.   <property>  
  50.     <name>dfs.namenode.https-address.nameservice1.namenode85</name>  
  51.     <value>bdc220.hexun.com:50470</value>  
  52.   </property>  


配置了 nameservice1的别名,对应两台namenode50,namenode85的节点上。

通过zookeeper来选举出当前的namenode的active.

hdfs-site.xml文件复制,到$SPARK_HOME/conf 目录下,即可解决spark job 访问hdfs路径的问题。


你可能感兴趣的:(spark)