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

解决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.nameservicesname>  
  3.     <value>nameservice1value>  
  4.   property>  
  5.   <property>  
  6.     <name>dfs.client.failover.proxy.provider.nameservice1name>  
  7.     <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvidervalue>  
  8.   property>  
  9.   <property>  
  10.     <name>dfs.ha.automatic-failover.enabled.nameservice1name>  
  11.     <value>truevalue>  
  12.   property>  
  13.   <property>  
  14.     <name>ha.zookeeper.quorumname>  
  15.     <value>bdc40.hexun.com:2181,bdc41.hexun.com:2181,bdc46.hexun.com:2181,bdc53.hexun.com:2181,bdc54.hexun.com:2181value>  
  16.   property>  
  17.   <property>  
  18.     <name>dfs.ha.namenodes.nameservice1name>  
  19.     <value>namenode50,namenode85value>  
  20.   property>  
  21.   <property>  
  22.     <name>dfs.namenode.rpc-address.nameservice1.namenode50name>  
  23.     <value>bdc20.hexun.com:8020value>  
  24.   property>  
  25.   <property>  
  26.     <name>dfs.namenode.servicerpc-address.nameservice1.namenode50name>  
  27.     <value>bdc20.hexun.com:8022value>  
  28.   property>  
  29.   <property>  
  30.     <name>dfs.namenode.http-address.nameservice1.namenode50name>  
  31.     <value>bdc20.hexun.com:50070value>  
  32.   property>  
  33.   <property>  
  34.     <name>dfs.namenode.https-address.nameservice1.namenode50name>  
  35.     <value>bdc20.hexun.com:50470value>  
  36.   property>  
  37.   <property>  
  38.     <name>dfs.namenode.rpc-address.nameservice1.namenode85name>  
  39.     <value>bdc220.hexun.com:8020value>  
  40.   property>  
  41.   <property>  
  42.     <name>dfs.namenode.servicerpc-address.nameservice1.namenode85name>  
  43.     <value>bdc220.hexun.com:8022value>  
  44.   property>  
  45.   <property>  
  46.     <name>dfs.namenode.http-address.nameservice1.namenode85name>  
  47.     <value>bdc220.hexun.com:50070value>  
  48.   property>  
  49.   <property>  
  50.     <name>dfs.namenode.https-address.nameservice1.namenode85name>  
  51.     <value>bdc220.hexun.com:50470value>  
  52.   property>  


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

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

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


你可能感兴趣的:(Spark)