Spark疯狂踩坑系列

如果WEB UI界面或者程序日志里面看不到错误,使用以下方式查看日志

yarn logs -applicationId application_1585536649766_xxxx

错误1

Error: Could not find or load main class org.apache.spark.deploy.yarn.ApplicationMaster

解决办法:

检查spark-defaults.conf中的配置

spark.yarn.jars=hdfs://hadoop:9000/spark-yarn/jars/*.jar
spark.yarn.archive  hdfs://hadoop000:8020/tmp/spark-archive/spark2.4.5.zip

以上两种配置方式不可以错乱

错误2

java.lang.NoClassDefFoundError: org/lionsoul/ip2region/DbConfig

解决办法

--jars /home/hadoop/lib/ip2region-1.7.2.jar

错误3

java.lang.NullPointerException
at com.tunan.spark.utils.IpParseUtil.IpParse(IpParseUtil.java:19)

解决办法

--files /home/hadoop/lib/ip2region.db

代码中拿出文件有两种方式

String dbPath = GetIPRegion.class.getResource("/ip2region.db").getPath();
String dbPath = SparkFiles.get("/ip2region.db");
Author: Tunan
Link: http://yerias.github.io/2020/03/30/error/5/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.