运行 dataproc 上的 Spark-Job 时请求的身份验证范围不足

Request insufficient authentication scopes when running Spark-Job on dataproc

我正在尝试 运行 google dataproc 集群上的 spark 作业作为

 gcloud dataproc jobs submit hadoop --cluster <cluster-name> \
--jar file:///usr/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar \
--class org.apache.hadoop.examples.WordCount \
--arg1 \
--arg2 \

但是作业抛出错误

 (gcloud.dataproc.jobs.submit.spark) PERMISSION_DENIED: Request had insufficient authentication scopes.

如何将身份验证范围添加到 运行 作业?

通常,如果您 运行 遇到此错误,那是因为 运行 gcloud 来自使用 VM-metadata controlled scopes 的 GCE VM 内部,否则安装在本地计算机上的 gcloud 通常会已经在使用广泛的范围来包括所有 GCP 操作。

对于 Dataproc 访问,在创建您从中 运行 gcloud 的虚拟机时,您需要从 CLI 指定 --scopes cloud-platform,或者如果从云控制台创建虚拟机 UI, 你应该 select "Allow full access to all Cloud APIs":

正如上面提到的另一位评论者,现在您也可以 update scopes on existing GCE instances 添加 CLOUD_PLATFORM 范围。

您需要在创建 DataProc 集群时选中允许 API 访问的选项。然后只有您可以使用 gcloud dataproc jobs submit 将作业提交到集群 命令