AWS Glue-无法连接到mysql

时间:2019-05-21 14:41:35

标签: mysql amazon-web-services jdbc aws-glue

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

我还可以在mysql workbench或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.

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

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

并且“需要SSL连接”设置为“假”

4 个答案:

答案 0 :(得分:3)

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

答案 1 :(得分:1)

Glue's supported Databases(在Glue文档/常见问题中未特别指出)

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

Microsoft SQL Server    6.x
MySQL   5.1
Oracle Database 11.2
PostgreSQL  42.x
Amazon Redshift 4.1

现在,您可以customize your own configuration从AWS Glue Jobs连接到MySQL 8和其他较新的数据库。

  1. 下载MySQL 8的JDBC驱动程序
  2. 上传到S3
  3. 通过Glue-表-连接创建到数据库的JDBC连接 (请注意,由于支持的最新版本(当前为5.7),因此无法使用“测试连接”进行此操作
  4. 编辑Glue作业-依赖罐子路径-例如 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")

(该脚本中没有新行)

答案 2 :(得分:0)

将AWS RDS与MySQL Engine一起使用时,无需创建JDBC连接。创建连接时,可以使用Amazon RDS。

New Connection Screen

答案 3 :(得分:0)

您的连接字符串看起来正确。

我在同样的问题上苦苦挣扎,发现我必须解决一些问题:

  1. 确保用于RDS的安全组是自引用的。这意味着您应该将RDS上数据库实例的安全组添加到“所有TCP”的入站和出站规则中。

  2. 确保已为VPC创建端点。为此,请导航到您的VPC,单击“端点”,为RDS所在的VPC添加一个“端点”,并为S3创建一个端点。

  3. 最后,在其上创建MySQL RDS实例的版本应为版本5​​(而不是版本8)。我注意到,AWS Glue JDBC连接器仅适用于MySQL版本5(5.7)

相关问题