Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 从红移读取火花数据帧(火花红移模块)_Scala_Apache Spark_Jdbc_Amazon Redshift - Fatal编程技术网

Scala 从红移读取火花数据帧(火花红移模块)

Scala 从红移读取火花数据帧(火花红移模块),scala,apache-spark,jdbc,amazon-redshift,Scala,Apache Spark,Jdbc,Amazon Redshift,我跟随spark红移教程阅读从红移到spark(databricks)的内容。我有以下代码: val tempDir = "s3n://{my-s3-bucket-here}" val jdbcUsername = "usernameExample" val jdbcPassword = "samplePassword" val jdbcHostname = "redshift.companyname.xyz" val jdbcPort = 9293 val jdbcDatabase =

我跟随spark红移教程阅读从红移到spark(databricks)的内容。我有以下代码:

val tempDir = "s3n://{my-s3-bucket-here}"



val jdbcUsername = "usernameExample"
val jdbcPassword = "samplePassword"
val jdbcHostname = "redshift.companyname.xyz"
val jdbcPort = 9293
val jdbcDatabase = "database"
val jdbcUrl = "sampleURL"


sc.hadoopConfiguration.set("fs.s3n.awsAccessKeyId", "SAMPLEAWSKEY")
sc.hadoopConfiguration.set("fs.s3n.awsSecretAccessKey", "SECRETKEYHERE")

val subs_dim = sqlContext.read.format("com.databricks.spark.redshift").option("url", jdbcUrl).option("tempdir", tempDir).option("dbtable", "example.exampledb").load()
现在,当我尝试运行此操作时,我得到:

java.lang.IllegalArgumentException: requirement failed: You must specify a method for authenticating Redshift's connection to S3 (aws_iam_role, forward_spark_s3_credentials, or temporary_aws_*. For a discussion of the differences between these options, please see the README.
我有点困惑,因为我使用sc.hadoopConfiguration.set定义了awsAccesskeyID。我是公司的新员工,所以我想知道AWS密钥是否错误,或者我是否遗漏了其他内容


谢谢

我认为我看到的唯一原因是,它没有将S3凭据传递给红移连接,因为您没有设置
转发\u spark\u S3\u凭据

在通话中添加以下选项

option("forward_spark_s3_credentials", "true");
请参阅下面的代码片段

将Spark的S3凭据转发到Redshift:如果Forward_Spark_S3_credentials选项设置为true,则此库将自动发现Spark用于连接S3的凭据,并通过JDBC将这些凭据转发到Redshift


希望它能帮助你

你读过自述吗?有什么线索吗?是的,我查过了,上面说要设置AWS证书…我做了什么?