开发者社区> 问答> 正文

spark 访问不了oss

用github上的aliyun-emapreduce-demo, Spark本地应用访问oss遇到的问题:
在源文件的src/main/scala/com/aliyun/emr/example/RunLocally.scala 中
conf.set("spark.hadoop.fs.oss.impl", "com.aliyun.fs.oss.nat.NativeOssFileSystem")
conf.set("spark.hadoop.mapreduce.job.run-local", "true")
编译后执行 spark-submit --class com.aliyun.emr.example.OSSSample target/shaded/examples-1.1-shaded.jar oss://...后
如果不在uri里面给出ak的话,只在代码里用conf.set 设置ak,结果有exeption, 原因是Caused by: java.lang.IllegalArgumentException: AccessKeyId/AccessKeySecret/SecurityToken is not available, you can set them in configuration.

如果用oss://key:secret@buket.endpoint 作为命令输入参数的话,会有报错
WARN NativeOssFileSystem: Disallow set ak information in OSS URI.
Exception in thread "main" java.io.IOException: java.lang.IllegalArgumentException: Disallow set ak information in OSS URI

ak怎么用啊?各位怎么解决呢给点建议吧

展开
收起
云海漫步 2017-11-27 06:43:53 6529 0
2 条回答
写回答
取消 提交回答
  • 我也碰到这个问题了,有解决方案吗?

    2019-07-17 21:45:15
    赞同 展开评论 打赏
  • 我用的代码是github上的emr demo里的osssample

    2019-07-17 21:45:15
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Hybrid Cloud and Apache Spark 立即下载
Scalable Deep Learning on Spark 立即下载
Comparison of Spark SQL with Hive 立即下载