Configure one Postgresql DB in a domain setup !?

I am trying to have a single Postgresql DB for a Master -> Slave setup.
I start the master without problems and the postgresql runs without any problems (on master@
From the second VM (the slave) I can psql -h -U keycloak -W without any problems (the connection is there)
My datasource configuration:

 <datasource jndi-name="java:jboss/datasources/PostgresDS" pool-name="PostgresDS" enabled="true" use-java-context="true" use-ccm="true" statistics-enabled="true">
                    <connection-property name="url">jdbc:postgresql://</connection-property>
                            <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
                    <driver name="postgresql" module="org.postgresql">
                    <driver name="h2" module="com.h2database.h2">

I know you will say that the config has too much information, but I started from the config in the documentation that didn’t work for me (all on KeycloakDS without connection-property, driver-class, datasourc-class, validation) to all combinations from stackoverflow and other blogs.

The error:
[Server:server-two] Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "keycloak" [Server:server-two] at org.postgresql@42.2.14//org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication( [Server:server-two] at org.postgresql@42.2.14//org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect( [Server:server-two] at org.postgresql@42.2.14//org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl( [Server:server-two] at org.postgresql@42.2.14//org.postgresql.core.ConnectionFactory.openConnection( [Server:server-two] at org.postgresql@42.2.14//org.postgresql.jdbc.PgConnection.<init>( [Server:server-two] at org.postgresql@42.2.14//org.postgresql.Driver.makeConnection( [Server:server-two] at org.postgresql@42.2.14//org.postgresql.Driver.connect( [Server:server-two] at org.jboss.ironjacamar.jdbcadapters@1.4.20.Final//org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createLocalManagedConnection( [Server:server-two] ... 57 more [Server:server-two] [Server:server-two] 22:00:50,207 FATAL [] (ServerService Thread Pool -- 63) java.lang.RuntimeException: Failed to connect to database

Remember the psql direct connection from slave-vm works (with password and user). Only from datasource I get that the password auth failed.
I’ve tried to encode base64 also the password, but didn’t help me in any way.
Is there something that I’m missing?

I’ve changed the pg_hba.conf settings on slave-vm to:

#"local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all               ident (previously password)
# IPv6 local connections:
host    all             all             ::1/128                 ident (previously password)
host   all            keycloak   password

and now I get this error:
Caused by: org.postgresql.util.PSQLException: FATAL: Ident authentication failed for user "keycloak"
which makes me think that the driver is trying to login to the postgres db on the slave and not the one from the master.
The question is why? because in the settings I have the ip of the master VM:
<connection-url>jdbc:postgresql://</connection-url> <connection-property name="url">jdbc:postgresql://</connection-property>.
What do I miss?


Ok, I found the problem.
In the domain.xml on the master the connection-url settings were done for localhost and the slave actually uses the domain.xml from master not from slave VM.

That’s that and I hope this lesson will help others too.

1 Like

Hey edwint, I’m trying to do a similar configuration, could you please show how did your

<connection-url> tag ended up like?

It was exactly like in the example:


instead of jdbc:postgresql://localhost/keycloak

1 Like