启动Spark报Caused by: java.net.UnknownHostException: iotsparkmaster: unknown error

[iotspark@iotsparkmaster sbin]$ ./start-all.sh
hostname: Host name lookup failure
starting org.apache.spark.deploy.master.Master, logging to /usr/iotspark/spark/spark-2.3.0-bin-hadoop2.7/logs/spark-iotspark-org.apache.spark.deploy.master.Master-1-iotsparkmaster.out
failed to launch: nice -n 0 /usr/iotspark/spark/spark-2.3.0-bin-hadoop2.7/bin/spark-class org.apache.spark.deploy.master.Master --host --port 7077 --webui-port 8080
        at org.apache.spark.deploy.master.MasterArguments.(MasterArguments.scala:30)
        at org.apache.spark.deploy.master.Master$.main(Master.scala:1049)
        at org.apache.spark.deploy.master.Master.main(Master.scala)
  Caused by: java.net.UnknownHostException: iotsparkmaster: unknown error
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
        at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:907)
        at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1302)
        at java.net.InetAddress.getLocalHost(InetAddress.java:1479)
        ... 10 more
  18/03/26 19:00:37 INFO ShutdownHookManager: Shutdown hook called
full log in /usr/iotspark/spark/spark-2.3.0-bin-hadoop2.7/logs/spark-iotspark-org.apache.spark.deploy.master.Master-1-iotsparkmaster.out
hostname: Host name lookup failure
localhost: starting org.apache.spark.deploy.worker.Worker, logging to /usr/iotspark/spark/spark-2.3.0-bin-hadoop2.7/logs/spark-iotspark-org.apache.spark.deploy.worker.Worker-1-iotsparkmaster.out
localhost: failed to launch: nice -n 0 /usr/iotspark/spark/spark-2.3.0-bin-hadoop2.7/bin/spark-class org.apache.spark.deploy.worker.Worker --webui-port 8081 spark://:7077
localhost:      at org.apache.spark.deploy.worker.WorkerArguments.(WorkerArguments.scala:31)
localhost:      at org.apache.spark.deploy.worker.Worker$.main(Worker.scala:754)
localhost:      at org.apache.spark.deploy.worker.Worker.main(Worker.scala)
localhost:   Caused by: java.net.UnknownHostException: iotsparkmaster: unknown error
localhost:      at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
localhost:      at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:907)
localhost:      at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1302)
localhost:      at java.net.InetAddress.getLocalHost(InetAddress.java:1479)
localhost:      ... 10 more
localhost:   18/03/26 19:00:39 INFO ShutdownHookManager: Shutdown hook called
localhost: full log in /usr/iotspark/spark/spark-2.3.0-bin-hadoop2.7/logs/spark-iotspark-org.apache.spark.deploy.worker.Worker-1-iotsparkmaster.out

解决方案如下:
修改/etc/hosts文件

127.0.0.1 主机名 localhost.localdomain localhost

或者再增加一条,如图所示:


image.png
image.png

可以直接使用hostname查看当前主机的用户名;
然后启动spark:


image.png

你可能感兴趣的:(启动Spark报Caused by: java.net.UnknownHostException: iotsparkmaster: unknown error)