简体   繁体   中英

How to run Spark-Streaming job as a daemon

在使用日志轮换记录日志文件中发生的任何异常的同时,守护 Spark-Streaming 作业的最佳方法是什么?

This is the way to run 2 daemon threads, based on your requirement it can increase..

nohup ./mysparkstreamingjob.sh one> ../../logs/nohup.out 2> ../../logs/nohup.err < /dev/null &

nohup ./mysparkstreamingjob.sh two> ../../logs/nohup.out 2> ../../logs/nohup.err < /dev/null &

mysparkstreamingjob.sh will look like

#!/bin/sh
echo $CLASSPATH
spark-submit --verbose --jars $(echo /dirofjars/*.jar | tr ' ' ','),$SPARK_STREAMING_JAR --class com.xx.xx.StreamingJob \
    --master yarn-client \
    --num-executors 12 \
    --executor-cores 4 \
    --driver-memory 4G \
    --executor-memory 4G \
    --driver-class-path ../../config/properties/* \
    --conf "spark.driver.extraJavaOptions=-XX:PermSize=256M -XX:MaxPermSize=512M" \
    --conf "spark.shuffle.memoryFraction=0.5" \
    --conf "spark.storage.memoryFraction=0.75" \
    --conf "spark.storage.unrollFraction=0.2" \
    --conf "spark.memory.fraction=0.75" \
    --conf "spark.worker.cleanup.enabled=true" \
    --conf "spark.worker.cleanup.interval=14400" \
    --conf "spark.shuffle.io.numConnectionsPerPeer=5" \
    --conf "spark.eventlog.enabled=true" \
    --conf "spark.driver.extraLibrayPath=$HADOOP_HOME/*:$HBASE_HOME/*:$HADOOP_HOME/lib/*:$HBASE_HOME/lib/htrace-core-3.1.0-incubating.jar:$HDFS_PATH/*:$SOLR_HOME/*:$SOLR_HOME/lib/*" \
    --conf "spark.executor.extraLibraryPath=$HADOOP_HOME/*:$HBASE_HOME/*:$HADOOP_HOME/lib/*:$HBASE_HOME/lib/htrace-core-3.1.0-incubating.jar:$HDFS_PATH/*:$SOLR_HOME/*:$SOLR_HOME/lib/*" \
    --conf "spark.executor.extraClassPath=$(echo /dirofjars/*.jar | tr ' ' ',')" \
    --conf "spark.yarn.executor.memoryOverhead=2048" \
    --conf "spark.yarn.driver.memoryOverhead=1024" \
    --conf "spark.eventLog.overwrite=true" \
    --conf "spark.shuffle.consolidateFiles=true" \
    --conf "spark.akka.frameSize=1024" \
    --files xxxx.properties, xxxx.properties \
    -DprocMySpark$1

Custom log4j rotation of file you need to configure and pass that setting to your spark submit. based on appender you use it will do in natural way as java + log4j working.

For Example :

--conf "spark.executor.extraJavaOptions=-Dlog4j.configuration=/tmp/log4j.properties"

Moreover, spark webui url(which is by default) has all logs high level and low level

You should be using oozie for scheduling your spark streaming job. https://oozie.apache.org/docs/4.2.0/DG_SparkActionExtension.html

This will give you a good overview about scheduling, managing and monitoring your spark jobs. http://blog.cloudera.com/blog/2014/02/new-hue-demos-spark-ui-job-browser-oozie-scheduling-and-yarn-support/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM