【问题标题】:Connecting to a Postgres Heroku DB from AWS Glue, SSL issue从 AWS Glue 连接到 Postgres Heroku DB,SSL 问题
【发布时间】:2018-05-03 03:09:04
【问题描述】:

我正在尝试连接到我的 Heroku 数据库,但遇到以下与 SSL 相关的一系列错误:

SSL connection to data store using host matching failed. Retrying without host matching.
SSL connection to data store failed. Retrying without SSL.
Check that your connection definition references your JDBC database with correct URL syntax, username, and password. org.postgresql.util.PSQLException: Connection attempt timed out.

我设法使用 DBeaver 连接到数据库并遇到了类似的 SSL 问题,直到我将 SSL 工厂设置为 org.postgresql.ssl.NonValidatingFactory,但 Glue 不提供任何 SSL 选项。

数据库实际上托管在 AWS 上,连接 URL 是:

jdbc:postgresql://ec2-52-19-160-2.eu-west-1.compute.amazonaws.com:5432/something

(ps.AWS Glue 论坛毫无用处!他们似乎没有回答任何人的问题)

【问题讨论】:

  • 你解决过这个问题吗?我也在尝试从 aws 胶水连接到我的 heroku postgres 数据库,并且遇到了同样的问题。
  • 不,事实证明您需要使用 SSL 连接到 heroku 的 posgres 数据库,但在我发布它时 Glue 没有提供此功能。 AWS 支持表示它在待办事项列表上。我放弃了 Glue,现在将 Step Functions 用于我的所有 AWS 编排。容易得多。

标签: postgresql amazon-web-services ssl aws-glue


【解决方案1】:

我遇到了同样的问题,似乎问题在于 Heroku 需要的 JDBC 驱动程序比 Amazon 需要的驱动程序更新。看到这个帖子:

AWS Data Pipelines with a Heroku Database

此外,您似乎可以直接从您的 python 脚本中使用 jbdc。见这里:

https://dzone.com/articles/extract-data-into-aws-glue-using-jdbc-drivers-and

所以您似乎需要下载一个新驱动程序,将其上传到 s3,然后在您的脚本中手动使用它,如此处所述:

https://gist.github.com/saiteja09/2af441049f253d90e7677fb1f2db50cc

祝你好运!

更新:我能够在胶水作业中使用以下代码 sn-p 连接到数据。我必须将 Postgres 驱动程序上传到 S3,然后将其添加到我的 Glue Job 的路径中。此外,请确保 Jars 是公开的,或者您已配置 IAM 用户的策略,以便他们可以访问存储桶。

%pyspark
import sys
from pyspark.context import SparkContext
from awsglue.context import GlueContext
from awsglue.dynamicframe import DynamicFrame
from awsglue.transforms import *

glueContext = GlueContext(SparkContext.getOrCreate())

source_df = spark.read.format("jdbc").option("url","jdbc:postgresql://<hostname>:<port>/<datbase>“).option("dbtable", “<table>”).option("driver", "org.postgresql.Driver").option("sslfactory", "org.postgresql.ssl.NonValidatingFactory").option("ssl", "true").option("user", “<username>”).option("password", “<password>”).load()

dynamic_dframe = DynamicFrame.fromDF(source_df, glueContext, "dynamic_df")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-21
    • 2016-08-14
    • 1970-01-01
    • 2020-10-11
    • 2019-08-15
    • 2021-11-26
    相关资源
    最近更新 更多