Keycloak Cluster

Allgemein

HAProxy

Multicast (UDP)

...
<subsystem xmlns="urn:jboss:domain:jgroups:8.0">
            <channels default="ee">
                <channel name="ee" stack="udp" cluster="ejb"/>
            </channels>
...
...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
...
        <socket-binding name="jgroups-mping" interface="private" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45700"/>
        <socket-binding name="jgroups-tcp" interface="private" port="7600"/>
        <socket-binding name="jgroups-tcp-fd" interface="private" port="57600"/>
        <socket-binding name="jgroups-udp" interface="private" port="55200" multicast-address="${jboss.default.multicast.address:230.0.0.4}" multicast-port="45688"/>
        <socket-binding name="jgroups-udp-fd" interface="private" port="54200"/>
...
        <socket-binding name="modcluster" multicast-address="${jboss.modcluster.multicast.address:224.0.1.105}" multicast-port="23364"/>
...
    </socket-binding-group>
...

TCPPING

...
<subsystem xmlns="urn:jboss:domain:jgroups:8.0">
            <channels default="ee">
                <channel name="ee" stack="tcp" cluster="ejb"/>
            </channels>
...
... 
<stack name="tcp">
   <transport type="TCP" socket-binding="jgroups-tcp"/>
   <protocol type="TCPPING">
 	<property name="initial_hosts">
	   10.100.10.11[7600],10.100.10.12[7600]
	</property>
   </protocol>
   <!--<socket-protocol type="MPING" socket-binding="jgroups-mping"/>-->
...
</stack>

JDBC_PING

Vorteil: die einzelnen Clients müssen nicht explizit in der Config benannt werden, sie tragen sich in der Datenbank ein. Dafür muss eine Tabelle in der Datenbank erzeugt werden. Nocht nicht getestet.

...
<subsystem xmlns="urn:jboss:domain:jgroups:8.0">
            <channels default="ee">
                <channel name="ee" stack="tcp" cluster="ejb"/>
            </channels>
...
<stack name="tcp">
   <transport type="TCP" socket-binding="jgroups-tcp"/>
   <protocol type="JDBC_PING">
     <property name="datasource_jndi_name">java:jboss/datasources/KeycloakDS</property>
</protocol>
...
</stack>
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));
https://gist.github.com/rkbalgi/183a113e946dd9f8360e774dcf17a3db
https://lists.jboss.org/pipermail/keycloak-user/2017-February/009729.html
https://www.keycloak.org/2019/05/keycloak-cluster-setup.html