Mac 上出现 Error initializing SparkContext
java.net.UnknownHostException: xiangjiadeMacBook-Pro.local: xiangjiadeMacBook-Pro.local: nodename nor servname provided, or not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1475)
at org.apache.spark.util.Utils$.findLocalInetAddress(Utils.scala:788)
at org.apache.spark.util.Utils$.org$apache$spark$util$Utils$$localIpAddress$lzycompute(Utils.scala:781)
at org.apache.spark.util.Utils$.org$apache$spark$util$Utils$$localIpAddress(Utils.scala:781)
at org.apache.spark.util.Utils$$anonfun$localHostName$1.apply(Utils.scala:838)
at org.apache.spark.util.Utils$$anonfun$localHostName$1.apply(Utils.scala:838)
at scala.Option.getOrElse(Option.scala:120)
at org.apache.spark.util.Utils$.localHostName(Utils.scala:838)
at org.apache.spark.SparkContext.<init>(SparkContext.scala:420)
at com.llc.HelloSpark$.main(HelloSpark.scala:13)
at com.llc.HelloSpark.main(HelloSpark.scala)
Caused by: java.net.UnknownHostException: xiangjiadeMacBook-Pro.local: nodename nor servname provided, or not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1295)
at java.net.InetAddress.getLocalHost(InetAddress.java:1471)
... 10 more
17/09/26 20:50:50 INFO SparkContext: Successfully stopped SparkContext
Exception in thread "main" java.net.UnknownHostException: xiangjiadeMacBook-Pro.local: xiangjiadeMacBook-Pro.local: nodename nor servname provided, or not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1475)
at org.apache.spark.util.Utils$.findLocalInetAddress(Utils.scala:788)
at org.apache.spark.util.Utils$.org$apache$spark$util$Utils$$localIpAddress$lzycompute(Utils.scala:781)
at org.apache.spark.util.Utils$.org$apache$spark$util$Utils$$localIpAddress(Utils.scala:781)
at org.apache.spark.util.Utils$$anonfun$localHostName$1.apply(Utils.scala:838)
at org.apache.spark.util.Utils$$anonfun$localHostName$1.apply(Utils.scala:838)
at scala.Option.getOrElse(Option.scala:120)
at org.apache.spark.util.Utils$.localHostName(Utils.scala:838)
at org.apache.spark.SparkContext.<init>(SparkContext.scala:420)
at com.llc.HelloSpark$.main(HelloSpark.scala:13)
at com.llc.HelloSpark.main(HelloSpark.scala)
Caused by: java.net.UnknownHostException: xiangjiadeMacBook-Pro.local: nodename nor servname provided, or not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1295)
at java.net.InetAddress.getLocalHost(InetAddress.java:1471)
... 10 more
命令行解决
$ sudo hostname -s 127.0.0.1