【发布时间】:2021-12-28 02:07:02
【问题描述】:
我目前正在使用来自 bitnami (Here) 的掌舵图表,并尝试在 GCP 中使用 Cloud SQL 实例。无论我建立什么连接字符串,连接到数据库时都会出现各种连接错误。这会导致初始 pod 启动失败,并且永远不会完全初始化。
spring-cloud-dataflow 似乎没有与spring-cloud-gcp 捆绑,因此无法通过实例名称进行配置,因此我假设我们需要使用私有 IP 地址,但每次都失败。
对于以下测试,创建了 Cloud SQL MySQL 实例,并创建了 Cloud SQL Postgresql 实例。
MySQL 实例的图表配置 1:(为简洁起见,省略了用户名和密码)
mariadb.enabled=false
externalDatabase.dataflow.url=jdbc:mysql://<privateip>/dataflow?useSSL=false
externalDatabase.dataflow.username=root
externalDatabase.driver=org.mariadb.jdbc.Driver
结果(使用端口 0 或端口 3306):
java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=<private IP>)(port=0)(type=master) : Could not connect to <private IP>:0 : unexpected end of stream, read 0 bytes from 4 (socket was closed by server)
Caused by: java.io.EOFException: unexpected end of stream, read 0 bytes from 4 (socket was closed by server)
图表配置2(postgresql实例):
mariadb.enabled=false
externalDatabase.dataflow.url=jdbc:postgresql://<Private IP>:5432/
externalDatabase.dataflow.username=postgres
externalDatabase.driver=org.postgresql.Driver
结果:
org.postgresql.util.PSQLException: The connection attempt failed.
Caused by: java.net.SocketException: Connection reset
我已经验证我可以通过 Squirrel SQL(用于 postgresql)和 MySQL 工作台通过 jdbc 访问数据库。
除非spring-cloud-dataflow 附带spring-cloud-gcp,否则这永远不会起作用吗?
【问题讨论】:
标签: google-cloud-sql bitnami spring-cloud-dataflow spring-cloud-gcp