我正在尝试测试 Spark-Submit 独立模式并运行下面的示例任务
spark-submit \
--class org.apache.spark.examples.SparkPi \
--master spark://MBP-49F32N-CSP.local:7077 \
--driver-memory 3g \
--executor-memory 3g \
--num-executors 2 \
--executor-cores 2 \
--conf spark.dynamicAllocation.enabled=false \
/opt/homebrew/Cellar/apache-spark/3.5.0/libexec/examples/jars/spark-examples_2.12-3.5.0.jar \
10
我可以看到下面生成的日志
/apache-spark/3.5.0/libexec/work
我可以看到带有 application-id 的目录
应用程序-20230929175322-0003 应用程序-20231003110238-0000
app-20231003110238-0000 里面有子目录 0 1 2 3 4 5 以执行者的名字命名。 在每个目录中我可以看到 stderr stdout
有没有办法聚合application-id(ex=app-20231003110238-0000)目录下的所有执行器日志?
就像当我们在纱线模式下运行 Spark 时,我们会看到下面的所有日志
纱线日志 -applicationId
您可以使用 shell 脚本来聚合所有 stdout 和 stderr 日志,类似于下面的内容。
cd /apache-spark/3.5.0/libexec/work/<app_id>
# Concatenate executor stderr logs
cat */stderr > agg_stderr.log
# Concatenate executor stdout logs
cat */stdout > agg_stdout.log