我目前正在使用来自 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
吗?