小编Sha*_*esh的帖子

WildFly Postgres DataSource远程连接 - 网址被忽略

我在以独立群集模式设置Keycloak服务器时遇到了一些配置问题.尽管配置数据源以使用postgres数据库{REMOTE_IP},但它无法启动服务器抱怨它无法连接localhost:5432.

我一直在搜索,但是我很困惑为什么当connection-url设置为远程主机时,DataSource会尝试连接到localhost.

我的配置有什么错误吗?我怎样才能弄清楚为什么PG试图连接到localhost而不是{REMOTE_IP}


我的设置是1个Postgres数据库服务器和2个Keycloak服务器

我按照安装说明使用了关系数据库,并为Postgres添加了JDBC驱动程序v9.4.1212.

我的DataSource配置如下:

<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
    <connection-url>jdbc:postgresql://{REMOTE_IP}:5432/keycloak</connection-url>
    <driver>postgresql</driver>
    <pool>
        <max-pool-size>20</max-pool-size>
    </pool>
    <security>
        <user-name>keycloak</user-name>
        <password>{PASSWORD}</password>
    </security>
</datasource>
Run Code Online (Sandbox Code Playgroud)

日志中的错误消息显示为:

...
Caused by: org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:262)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:52)
    at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:216)
    at org.postgresql.Driver.makeConnection(Driver.java:404)
    at org.postgresql.Driver.connect(Driver.java:272)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:86)
    at org.postgresql.ds.PGPoolingDataSource.getConnection(PGPoolingDataSource.java:309)
    at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection(LocalManagedConnectionFactory.java:312)
    ... 43 more
Caused by: java.net.ConnectException: Connection refused (Connection …
Run Code Online (Sandbox Code Playgroud)

postgresql wildfly keycloak

2
推荐指数
1
解决办法
2556
查看次数

标签 统计

keycloak ×1

postgresql ×1

wildfly ×1