使用spark / scal应用程序访问s3时找不到AWS凭据

时间:2016-03-29 10:29:27

标签: scala amazon-web-services amazon-s3 apache-spark

我正在使用Windows环境,没有安装hadoop,我有一个带bin的hadoop文件夹和winutils,就是这样。

我根据文档设置了id和secret的环境变量,但不断得到这个例外:

Exception in thread "main" java.lang.IllegalArgumentException: AWS Access Key ID and Secret Access Key must be specified as the username or password (respectively) of a s3n URL, or by setting the fs.s3n.awsAccessKeyId or fs.s3n.awsSecretAccessKey properti

我知道如何解决这个问题吗?

我已经确认变量是通过回应它们来设置的,但它们没有被拾取 - 谢谢./

1 个答案:

答案 0 :(得分:0)

您是否尝试过此配置?

val sc = new SparkContext(conf)
val hadoopConf = sc.hadoopConfiguration;
hadoopConf.set("fs.s3.impl", "org.apache.hadoop.fs.s3native.NativeS3FileSystem")
hadoopConf.set("fs.s3.awsAccessKeyId",myAccessKey)
hadoopConf.set("fs.s3.awsSecretAccessKey",mySecretKey)