【发布时间】:2019-08-04 10:25:48
【问题描述】:
我们有 2 台机器在域模式下运行 Keycloak 4.8.3.Final (WildFly Core 6.0.2.Final)。首先,host1 将运行域控制器并将成为我们的主控。 Host2 是我们的从站,它自己注册到主站。据我们了解,域模式通过提供一个存储和发布配置的中心位置来解决这个问题。
第一个是通过执行命令启动的:
/opt/keycloak/bin/domain.sh --host-config host-master.xml -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0 -Djava.security。 egd=file:/dev/urandom -Dkeycloak.profile.feature.token_exchange=enabled -Djboss.node.name=host1
第二个通过执行命令:
/opt/keycloak/bin/domain.sh --host-config host-slave.xml -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0 -Djboss.domain。 master.username=slave -Djboss.domain.master.address={host1_ip} -Dkeycloak.profile.feature.token_exchange=enabled -Djava.security.egd=file:/dev/urandom -Djboss.node.name=host2
它们都成功启动,并且从设备设法连接到主设备。我们正在使用服务器指向的 MySQL 机器来实现数据持久性。
首先,我们使用了 keycloak 分发附带的默认 domain.xml,我们最初的期望是通过在 host1 上创建一些内容,更改将传播到 host2。不幸的是,这并没有发生。当我们创建用户时,该用户会在一段时间后出现在 host2 上。当我们在 host1 的领域中创建领域或客户端时,在我们重新启动两个服务器并强制同步信息之后,才能从 host2 看到更改。
下一步是更改infinispan 指令中的 domain.xml 配置,并使缓存在所有机器上复制。
<subsystem xmlns="urn:jboss:domain:infinispan:7.0">
<cache-container name="keycloak">
<transport lock-timeout="60000" />
<replicated-cache name="authenticationSessions" />
<replicated-cache name="clientSessions" />
<replicated-cache name="offlineClientSessions" />
<replicated-cache name="authorization" />
<replicated-cache name="work" />
<replicated-cache name="keys" />
<replicated-cache name="actionTokens"></replicated-cache>
<replicated-cache name="realms" />
<replicated-cache name="users" />
<replicated-cache name="sessions" />
<replicated-cache name="offlineSessions" />
<replicated-cache name="loginFailures" />
<replicated-cache name="work" />
<replicated-cache name="realmVersions" />
</cache-container>
<cache-container name="server" aliases="singleton cluster" default-cache="default" module="org.wildfly.clustering.server">
<transport lock-timeout="60000" />
<replicated-cache name="default">
<transaction mode="BATCH" />
</replicated-cache>
</cache-container>
<cache-container name="web" default-cache="dist" module="org.wildfly.clustering.web.infinispan">
<transport lock-timeout="60000" />
<distributed-cache name="dist">
<locking isolation="REPEATABLE_READ" />
<transaction mode="BATCH" />
<file-store />
</distributed-cache>
</cache-container>
<cache-container name="ejb" aliases="sfsb" default-cache="dist" module="org.wildfly.clustering.ejb.infinispan">
<transport lock-timeout="60000" />
<distributed-cache name="dist">
<locking isolation="REPEATABLE_READ" />
<transaction mode="BATCH" />
<file-store />
</distributed-cache>
</cache-container>
<cache-container name="hibernate" module="org.infinispan.hibernate-cache">
<transport lock-timeout="60000" />
<local-cache name="local-query">
<object-memory size="10000" />
<expiration max-idle="100000" />
</local-cache>
<invalidation-cache name="entity">
<transaction mode="NON_XA" />
<object-memory size="10000" />
<expiration max-idle="100000" />
</invalidation-cache>
<replicated-cache name="timestamps" />
</cache-container>
</subsystem>
但是,我们也有同样的问题,尤其是如果您为客户端重新生成密钥,该密钥不会传播到从属主机,反之亦然。
还有其他人遇到过这个问题吗?您做了什么来解决这个问题?任何帮助将不胜感激!
【问题讨论】:
-
两个节点之间是否形成集群? INFO 级别消息指示集群视图是什么。您应该在视图中有两个节点。
标签: realm keycloak high-availability infinispan