Databricks Runtime 16.4中spark.scheduler.allocation.file配置问题
解决Databricks Runtime 16.4中spark.scheduler.allocation.file配置报错问题
问题原因
直接使用file:/Workspace/...路径访问工作区文件时,Spark调度器进程没有Workspace文件系统(WSFS)的认证令牌,导致权限验证失败,抛出Missing token错误。
两种可行解决方案
方案1:使用DBFS路径(推荐)
DBFS是Databricks集群默认有权限访问的分布式文件系统,无需额外令牌配置:
- 将
fairscheduler.xml上传到DBFS(可通过Databricks UI的"数据"页面上传,或用dbutils.fs.cp从Workspace复制:dbutils.fs.cp("file:/Workspace/init/fairscheduler.xml", "dbfs:/init/fairscheduler.xml")) - 修改Spark配置为:
config("spark.scheduler.allocation.file", "dbfs:/init/fairscheduler.xml")
方案2:通过初始化脚本同步到本地文件系统
如果必须使用Workspace中的原文件,可通过集群初始化脚本将文件复制到节点本地路径:
- 创建初始化脚本(比如
dbfs:/scripts/copy_fairscheduler.sh),内容如下:#!/bin/bash # 从Workspace复制文件到节点本地临时目录 databricks fs cp "file:/Workspace/init/fairscheduler.xml" "/tmp/fairscheduler.xml" - 在集群配置中添加初始化脚本路径("高级选项"->"初始化脚本")
- 修改Spark配置为:
config("spark.scheduler.allocation.file", "file:/tmp/fairscheduler.xml")
内容的提问来源于stack exchange,提问作者Franek
相关产品推荐
相关产品推荐

