scala - Spark:报告集群的总量和可用内存
问题描述
我在 Amazon EMR 上运行 Spark 作业;我想继续从程序本身报告集群的总内存和可用内存。Spark API 中是否有任何方法可以提供有关集群内存的信息?
解决方案
您可以使用 spark.metrics.conf
如何使用:在你的 spark conf 文件中初始化 spark.metrics.conf
spark.metrics.conf = /path/to/metrics.properties
在上面的路径中创建metrics.properties文件。在该文件中提到您想要从 spark 应用程序中获取的参数,甚至您可以指定格式和间隔。
例如,在这里我每 1 分钟获取一次 CSV 格式的数据:
driver.sink.csv.class=org.apache.spark.metrics.sink.CsvSink
# Polling period for the CsvSink
#*.sink.csv.period=1
# Unit of the polling period for the CsvSink
#*.sink.csv.unit=minutes
# Polling directory for CsvSink
driver.sink.csv.directory=/Path/at/which/data/will/be/dumped
# Polling period for the CsvSink specific for the worker instance
driver.sink.csv.period=1
# Unit of the polling period for the CsvSink specific for the worker instance
driver.sink.csv.unit=minutes
您可以在以下位置找到完整文档:https ://spark.apache.org/docs/latest/monitoring.html#metrics
推荐阅读
- sql - 如何使用 Power Query M 将 Excel 表列值拉入 SQL WHERE 子句?
- java - 使用功能将 jts 转换为 GeoJSON 的类型错误
- django - 如何在 Django 和 Redux 中使用 JWT
- python - 熊猫找不到列,ValueError
- flutter - 颤振将3d点转换为2d点
- haskell - 如何重构 Haskell 数据类型中的重复字段名称?
- function - lua 调用与循环相同的函数
- reactjs - 将来源页面定义为 Gatsby 的首页的正确方法
- arrays - jQuery从数组中的选项中获取所有内容
- sql - 如何从完整的给定表中生成单个 MD5 散列