Skip to content

Instantly share code, notes, and snippets.

@rkbalgi
Last active March 2, 2022 19:12
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rkbalgi/183a113e946dd9f8360e774dcf17a3db to your computer and use it in GitHub Desktop.
Save rkbalgi/183a113e946dd9f8360e774dcf17a3db to your computer and use it in GitHub Desktop.
JDBC_PING with keycloak and postgresql on AWS Fargate
In your effort of implementing standalone-ha with keycloak postgresql using JDBC_PING you will stumble upon many sites that define
the table structure for jgroupsping and the right one goes like this -
CREATE TABLE IF NOT EXISTS JGROUPSPING (
own_addr varchar(200) NOT NULL,
cluster_name varchar(200) NOT NULL,
ping_data BYTEA,
constraint PK_JGROUPSPING PRIMARY KEY (own_addr, cluster_name)
);
In some links, you will see additional columns like bind_addr and created. These can be included, but will have supplied
as java system properties (especially bind_addr)
The errors occuring because of these will look like - "null value in column "created" or "bind_addr" violates not-null constraint"
' Links
https://developer.jboss.org/wiki/JDBCPING
@rkbalgi
Copy link
Author

rkbalgi commented Dec 24, 2018

If you are planning to use this on AWS with ECS fargate (awsvpc mode), know that UDP multicast is not supported and so tcp will have to be made the default for jgroups. Unfortunately, the docker images have UDP as default and so standalone-ha.xml should be changed as below. (I built my own keycloak image based on these changes)

 <subsystem xmlns="urn:jboss:domain:jgroups:6.0">
            <channels default="ee">
                <channel name="ee" stack="tcp" cluster="ejb"/>
            </channels>

Here is a useful link that attempts to do the same but, using a cli script https://medium.com/@mickael.gregori/configure-jgroups-to-run-keycloak-in-clustered-mode-8991fd655e74

@rkbalgi
Copy link
Author

rkbalgi commented Dec 24, 2018

Some useful information here as well - keycloak/keycloak-containers@7da8430

@dqvn
Copy link

dqvn commented Mar 13, 2020

CREATE TABLE IF NOT EXISTS JGROUPSPING (own_addr varchar(200) NOT NULL, cluster_name varchar(200) NOT NULL, ping_data BYTEA, constraint PK_JGROUPSPING PRIMARY KEY (own_addr, cluster_name));

WORKED FOR ME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment