简体   繁体   English

Heroku Postgres升级后,Flyway无法连接到数据库

[英]Flyway cannot connect to db after Heroku Postgres upgrade

I am upgrading my heroku database from a hobby dev to Standard 0 (using the official instructions https://devcenter.heroku.com/articles/upgrading-heroku-postgres-databases#upgrade-with-pg-copy-default ). 我正在将我的heroku数据库从业余开发者升级到标准0(使用官方说明https://devcenter.heroku.com/articles/upgrading-heroku-postgres-databases#upgrade-with-pg-copy-default )。

All went well, until I promoted the new database and restarted the app. 一切顺利,直到我升级了新数据库并重新启动了该应用程序。 I then get the following error: 然后,我得到以下错误:

o.s.boot.SpringApplication               : Application startup failed
...
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Unable to obtain Jdbc connection from DataSource
...
Caused by: org.flywaydb.core.api.FlywayException: Unable to obtain Jdbc connection from DataSource
...
Caused by: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "54.xxx.xx.xxx", user "u94bf9vxxxxxx", database "d2mqk0b6xxxxxx", SSL off
...

If I swap back to the old database again, everything works again. 如果我再次交换回旧数据库,一切将再次正常。 The only thing that I am changing is the promoted database. 我唯一要更改的是升级后的数据库。

Is there a difference between connecting to hobby and standard databases that I need to be aware of? 我需要了解的兴趣爱好数据库和标准数据库之间有区别吗?

The relevant part of my application.yml looks as follows: 我的application.yml的相关部分如下所示:

spring:
    datasource:
        driverClassName: org.postgresql.Driver
        url: ${JDBC_DATABASE_URL} 
        username: ${JDBC_DATABASE_USERNAME}
        password: ${JDBC_DATABASE_PASSWORD}
flyway:
    enabled: true
    locations: classpath:db/migrations

Any suggestions on how I can debug this would be very welcome too. 任何有关如何调试此方法的建议也将非常受欢迎。

Looks like you aren't connecting with SSL where it is required by Heroku PostgreSQL installs. 看起来您没有在Heroku PostgreSQL安装所需的地方连接SSL。

See Herokus documentation on SSL for PostgreSQL . 请参阅有关PostgreSQL的SSL的 Herokus 文档

See also Herokus documentation for enabling SSL on JDBC connections. 另请参见Herokus 文档,以在JDBC连接上启用S​​SL

You will need to add something like &ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory to your JDBC URL. 您将需要在JDBC URL中添加&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM