文章目录
- Spark
- 问题:spark集群无法停止
- Spark-shell
- 问题:Spark-shell启动时报错WARN NativeCodeLoader:60 - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
- Spark-submit
- 问题:提交任务到yarn时报WARN yarn.Client: Neither spark.yarn.jars nor spark.yarn.archive is set, falling back to uploading libraries under SPARK_HOME.
- 问题:spark 与 Hadoop 融合后提交作业 slf4j提示Class path contains multiple SLF4J bindings
- Spark-sql
- 问题:spark-sql on yarn运行报错TransportClient:331 - Failed to send RPC *** java.nio.channels.ClosedChannelException
- 问题:spark中的beeline连接thriftserver后插入数据异常Spark currently does NOT populate bucketed output which is compatible with Hive
Spark
问题:spark集群无法停止
原因:
Spark的停止,是通过一些.pid文件来操作的。
查看spark-daemon.sh文件,其中一行:$SPARK_PID_DIR The pid files are strored . /tmp by default .
$SPARK_PID_DIR存放的pid文件中,就是要停止的进程的pid,其中$SPARK_PID_DIR默认是在系统的/tmp目录。
系统每隔一段时间就会清除/tmp目录下的内容。到/tmp下查看,如果没有Spark相关.pid文件,这就是导致Spark集群无法停止的原因。
解决方案:
在集群所有节点spark的conf/spark-env.sh文件中增加如下配置:
export SPARK_PID_DIR=/data/spark/pids
重启spark集群即可。
Spark-shell
问题:Spark-shell启动时报错WARN NativeCodeLoader:60 - Unable to load native-hadoop library for your platform… using builtin-java classes where applicable
解决方案:
在/etc/profile设置一下:export LD_LIBRARY_PATH=$HADOOP_HOME/lib/native
在spark的conf/spark-env.sh文件加入:export LD_LIBRARY_PATH=$HADOOP_HOME/lib/native
Spark-submit
问题:提交任务到yarn时报WARN yarn.Client: Neither spark.yarn.jars nor spark.yarn.archive is set, falling back to uploading libraries under SPARK_HOME.
解决方案:
在hdfs上创建目录
hdfs dfs -mkdir /spark_jars
上传spark的所有jar包到hdfs的/spark_jars目录
hdfs dfs -put /usr/local/spark/jars/* /spark_jars/
在${SPARK_HOME}/conf/spark-defaults.conf文件中新增如下配置:
spark.yarn.jars hdfs://hadoopSvr1:8020/spark-jars/*
问题:spark 与 Hadoop 融合后提交作业 slf4j提示Class path contains multiple SLF4J bindings
具体WARN信息如下:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/spark/jars/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop-3.1.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
解决方案:
主要原因是spark与hadoop融合后,依赖冲突了,删掉其中一个jar包(或改名)即可(下面以改名spark下的jar包为例)
cd /usr/local/spark/jars/
mv slf4j-log4j12-1.7.16.jar slf4j-log4j12-1.7.16.jar.backup
Spark-sql
问题:spark-sql on yarn运行报错TransportClient:331 - Failed to send RPC *** java.nio.channels.ClosedChannelException
具体错误信息如下:
ERROR TransportClient:331 - Failed to send RPC RPC 5232077649582323523 to /10.62.124.41:41929: java.nio.channels.ClosedChannelException
解决方案:
查看NodeManager的日志,发现:
WARN org.apache.hadoop.yarn.server.nodemanager.containermanager.monitor.ContainersMonitorImpl: Container [pid=8101,containerID=container_e03_1552020687119_0005_02_000001] is running 624192000B beyond the 'VIRTUAL' memory limit. Current usage: 376.1 MB of 1 GB physical memory used; 2.7 GB of 2.1 GB virtual memory used. Killing container.
由此可以看出container使用的虚拟内存超过了设置的2.1G,被kill掉了。
container使用的虚拟内存是由以下公式计算的:
虚拟内存=yarn.scheduler.minimum-allocation-mb * yarn.nodemanager.vmem-pmem-ratio
如果容器使用的虚拟内存总量超过这个公式计算的值,就会Killing container.
此外,我的yarn.scheduler.minimum-allocation-mb值并没有设置,因此默认为1G,yarn.nodemanager.vmem-pmem-ratio也没设置,默认为2.1,所以就出现了日志中的用了1G里的376.1M物理内存,用了2.1G里的2.7G虚拟内存。
我的解决方法是增大虚拟内存与物理内存的比例配置,具体实现:在yarn-site.xml文件中修改配置如下:
<property>
<name>yarn.nodemanager.vmem-pmem-ratio</name>
<value>3</value>
</property>
重启yarn集群即可!
问题:spark中的beeline连接thriftserver后插入数据异常Spark currently does NOT populate bucketed output which is compatible with Hive
解决方案:
在集群所有节点spark的conf/hive-site.xml文件中增加如下配置:
<property>
<name>hive.enforce.bucketing</name>
<value>false</value>
</property>
<property>
<name>hive.enforce.sorting</name>
<value>false</value>
</property>
重启spark集群和thriftserver即可!