AWS Glue - 无法连接到 mysql

Fai*_*ool 3 mysql jdbc amazon-web-services aws-glue

您好,在此实例中,数据库安全组对所有入站流量(所有端口 - 所有源)开放。

我还可以在 mysql 工作台或 Datagrip 中很好地连接到数据库,这肯定会使用 jdbc 连接字符串。

2019-05-21 14:12:03 INFO CatalogClient:651 - Got connection 'tem-sas-main' info from Catalog with url: jdbc:mysql://my-database-example:3306/sas_tem_central
2019-05-21 14:12:03 INFO CatalogClient:684 - JDBC configuration for connection tem-sas-main: JDBCConfiguration(url=jdbc:mysql://my-database-example:3306/sas_tem_central, hostname=my-database-example, port=3306, databaseVendor=mysql, databaseVersion=null, connectionName=tem-sas-main, path=sas_tem_central, subnetId=subnet-0717c4db096e84393, availabilityZone=eu-west-1a, securityGroups=[sg-074b074ebc51c2315], enforceSSL=false)
2019-05-21 14:12:03 INFO JdbcConnection:42 - Starting connecter. driver com.mysql.jdbc.Driver@7e5d9a50
2019-05-21 14:12:03 INFO JdbcConnection:60 - Attempting to connect with SSL host matching: jdbc:mysql://my-database-example:3306/sas_tem_central
2019-05-21 14:14:15 INFO JdbcConnection:69 - SSL connection to data store using host matching failed. Retrying without host matching.
2019-05-21 14:14:15 INFO JdbcConnection:83 - Attempting to connect with SSL: jdbc:mysql://my-database-example:3306/sas_tem_central
2019-05-21 14:16:26 INFO JdbcConnection:88 - SSL connection to data store failed. Retrying without SSL.
2019-05-21 14:16:26 INFO JdbcConnection:102 - Attempting to connect without SSL: jdbc:mysql://my-database-example:3306/sas_tem_central
Check that your connection definition references your JDBC database with correct URL syntax, username, and password. Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Run Code Online (Sandbox Code Playgroud)

还要注意我的 JDBC 连接字符串是

jdbc:mysql://my-database-example:3306/sas_tem_central

并且 Require SSL connection 设置为 false

小智 7

在与 AWS 架构师交谈后,我可以确认 Glue 目前不适用于 MySql 版本 8。这在我能找到的任何地方都没有记录。


lko*_*lko 6

Glue 支持的数据库(未在 Glue 文档/常见问题解答中突出显示)

下表列出了 AWS Glue 支持的 JDBC 驱动程序版本。

Microsoft SQL Server    6.x
MySQL   5.1
Oracle Database 11.2
PostgreSQL  42.x
Amazon Redshift 4.1
Run Code Online (Sandbox Code Playgroud)

现在,您可以自定义自己的配置以从 AWS Glue 作业连接到 MySQL 8 和其他更新的数据库。

  1. 下载 MySQL 8 的 JDBC 驱动程序
  2. 上传到 S3
  3. 通过 Glue - Tables - Connections 创建到您的数据库的 JDBC 连接(请注意,这将无法使用“测试连接”,因为支持的最新版本是(当前)5.7
  4. 编辑 Glue Job - Dependent jars 路径 - 例如 s3://yourS3bucket/path/mysql-connector-java-8.0.21.jar
  5. 修改胶水作业,例如 Python 脚本
datasink4 = glueContext.write_dynamic_frame.from_jdbc_conf
(frame = dropnullfields3, catalog_connection = “GLUE-CONNECTION-NAME”, 
connection_options = { 
"customJdbcDriverS3Path": "s3://yourS3Bucket/path/mysql-connector-java-8.0.21.jar", 
"customJdbcDriverClassName": "com.mysql.cj.jdbc.Driver", 
"user": “#DBuserName#”, "password": “DbUsersPassword”, 
"url":"jdbc:mysql://dbname.url.region.rds.amazonaws.com/schemaName, 
"connectionType": "mysql", "dbtable": “tablenameInDb”, 
"database": “schemaName”}, transformation_ctx = "datasink4")
Run Code Online (Sandbox Code Playgroud)

(该脚本中没有新行)