JDBC_PING无法发现实例(aws上的keycloak HA模式)

时间:2018-01-14 16:02:33

标签: amazon-web-services jdbc wildfly keycloak jgroups

我正在尝试使用连接到RDS DB(MySQL 5.7)的JDBC_PING在HA模式下在2个AWS EC2实例上设置Keycloak。在启动时,当实例尝试使用" org.jgroups.protocols.pbcast.GMS"发现彼此时出现错误,但是我收到超时错误,之后它变为独立模式。似乎实例无法相互联系,但tcpdump没有显示有关实例之间直接连接的任何进/出活动,但是它们主动与数据库通信,并且JGROUPS表定期使用ping数据更新。无法理解那是什么问题。您可以在下面看到日志。

实例1

 2018-01-12 17:53:01,264 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
    - 51) address=ip-192-168-33-243, cluster=ee, physical address=0.0.0.0:7600
    2018-01-12 17:53:01,264 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
    - 51) address=ip-192-168-33-243, cluster=ee, physical address=0.0.0.0:7600
    2018-01-12 17:53:31,305 TRACE [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
    - 51) ip-192-168-33-243: no members discovered after 30033 ms: creating cluster as first memb
    er
    2018-01-12 17:53:31,305 TRACE [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-33-243: no members discovered after 30033 ms: creating cluster as first member
    2018-01-12 17:53:31,307 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-33-243: installing view [ip-192-168-33-243|0] (1) [ip-192-168-33-243]
    2018-01-12 17:53:31,307 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-33-243: installing view [ip-192-168-33-243|0] (1) [ip-192-168-33-243]
    2018-01-12 17:53:31,370 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-33-243: created cluster (first member). My view is [ip-192-168-33-243|0], impl is org.jgroups.protocols.pbcast.CoordGmsImpl
2018-01-12 17:53:01,264 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
    - 51) address=ip-192-168-33-243, cluster=ee, physical address=0.0.0.0:7600
    2018-01-12 17:53:01,264 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
    - 51) address=ip-192-168-33-243, cluster=ee, physical address=0.0.0.0:7600
    2018-01-12 17:53:31,305 TRACE [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
    - 51) ip-192-168-33-243: no members discovered after 30033 ms: creating cluster as first memb
    er
    2018-01-12 17:53:31,305 TRACE [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-33-243: no members discovered after 30033 ms: creating cluster as first member
    2018-01-12 17:53:31,307 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-33-243: installing view [ip-192-168-33-243|0] (1) [ip-192-168-33-243]
    2018-01-12 17:53:31,307 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-33-243: installing view [ip-192-168-33-243|0] (1) [ip-192-168-33-243]
    2018-01-12 17:53:31,370 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-33-243: created cluster (first member). My view is [ip-192-168-33-243|0], impl is org.jgroups.protocols.pbcast.CoordGmsImpl
    2018-01-12 17:53:31,370 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-33-243: created cluster (first member). My view is [ip-192-168-33-243|0], impl is org.jgroups.protocols.pbcast.CoordGmsImpl

实例2

    2018-01-14 17:27:55,458 WARN  [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
- 51) ip-192-168-27-128: JOIN(ip-192-168-27-128) sent to ip-192-168-33-243 timed out (after 3
0000 ms), on try 2
2018-01-14 17:27:55,489 TRACE [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
- 51) ip-192-168-27-128: discovery took 31 ms, members: 411 rsps (2 coords) [done]
2018-01-14 17:27:55,489 TRACE [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
- 51) ip-192-168-27-128: discovery took 31 ms, members: 411 rsps (2 coords) [done]
2018-01-14 17:27:55,489 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
- 51) ip-192-168-27-128: found multiple coords: [ip-192-168-33-243, ip-192-168-27-128]
2018-01-14 17:27:55,489 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
- 51) ip-192-168-27-128: found multiple coords: [ip-192-168-33-243, ip-192-168-27-128]
2018-01-14 17:27:55,489 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
- 51) ip-192-168-27-128: sending JOIN(ip-192-168-27-128) to ip-192-168-33-243
2018-01-14 17:27:55,489 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
- 51) ip-192-168-27-128: sending JOIN(ip-192-168-27-128) to ip-192-168-33-243
2018-01-14 17:28:25,490 WARN  [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
- 51) ip-192-168-27-128: JOIN(ip-192-168-27-128) sent to ip-192-168-33-243 timed out (after 3
0000 ms), on try 3
2018-01-14 17:28:25,490 WARN  [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -
- 51) ip-192-168-27-128: JOIN(ip-192-168-27-128) sent to ip-192-168-33-243 timed out (after 3
0000 ms), on try 3
2018-01-14 17:28:25,490 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-27-128: sending JOIN(ip-192-168-27-128) to ip-192-168-27-128
2018-01-14 17:28:25,490 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-27-128: sending JOIN(ip-192-168-27-128) to ip-192-168-27-128
2018-01-14 17:28:55,490 WARN  [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-27-128: JOIN(ip-192-168-27-128) sent to ip-192-168-27-128 timed out (after 30000 ms), on try 3
2018-01-14 17:28:55,490 WARN  [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-27-128: JOIN(ip-192-168-27-128) sent to ip-192-168-27-128 timed out (after 30000 ms), on try 3
2018-01-14 17:28:55,521 TRACE [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-27-128: discovery took 30 ms, members: 411 rsps (2 coords) [done]
2018-01-14 17:28:55,521 TRACE [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-27-128: discovery took 30 ms, members: 411 rsps (2 coords) [done]
2018-01-14 17:28:55,521 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-27-128: found multiple coords: [ip-192-168-33-243, ip-192-168-27-128]
2018-01-14 17:28:55,521 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-27-128: found multiple coords: [ip-192-168-33-243, ip-192-168-27-128]
2018-01-14 17:28:55,521 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-27-128: sending JOIN(ip-192-168-27-128) to ip-192-168-27-128
2018-01-14 17:28:55,521 DEBUG [org.jgroups.protocols.pbcast.GMS] (ServerService Thread Pool -- 51) ip-192-168-27-128: sending JOIN(ip-192-168-27-128) to ip-192-168-27-128

摘自standalone-ha.xml Keycloak文件:

 <subsystem xmlns="urn:jboss:domain:jgroups:5.0">
          <channels default="ee">
              <channel name="ee" stack="tcp"/>
          </channels>
          <stacks>
              <stack name="tcp">
                  <transport type="TCP" socket-binding="jgroups-tcp"/>
                  <protocol type="JDBC_PING">
                    <property name="datasource_jndi_name">java:jboss/datasources/KeycloakCluster</property>
                    <property name="initialize_sql">
                      CREATE TABLE IF NOT EXISTS JGROUPSPING (
                      own_addr varchar(200) NOT NULL,
                      cluster_name varchar(200) NOT NULL,
                      updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                      ping_data varbinary(5000) DEFAULT NULL,
                      PRIMARY KEY (own_addr, cluster_name))
                      ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
                    </property>
                  </protocol>
                  <protocol type="MERGE3"/>
                  <protocol type="FD_SOCK"/>
                  <protocol type="FD_ALL"/>
                  <protocol type="VERIFY_SUSPECT"/>
                  <protocol type="pbcast.NAKACK2"/>
                  <protocol type="UNICAST3"/>
                  <protocol type="pbcast.STABLE"/>
                  <protocol type="pbcast.GMS">
                    <property name="join_timeout">30000</property>
                  </protocol>
                  <protocol type="MFC"/>
                  <protocol type="FRAG2"/>
              </stack>
          </stacks>
        </subsystem>

1 个答案:

答案 0 :(得分:0)

检查你的套接字绑定是否有jgroups-tcp指定私有接口。它应该像

<socket-binding name="jgroups-tcp" interface="private" port="7601"/>

然后使用telnet客户端检查是否可以从另一个实例建立连接。如果没有,则检查EC2安全组规则,ACL允许可用区域中子网之间的连接。

其次......故意在FD_SOCK上缺少套接字绑定吗?可能需要为FD_SOCK定义单独的tcp端口绑定,这也需要在EC2安全组和ACL规则中。