shardingSphere-jdbc 5.3.2 连接 Mysql MGR 集群后,在MGR其中一个节点挂掉后,不能自动切换主从关系

方便更快捷的说明问题,可以按需填写(可删除)

使用环境:

sharingSphere-jdbc 5.3.2
springboot 2.7.5
mysql MGR 1主2从集群

场景、问题:

场景:想要通过shardingjdbc实现读写分离(高性能)和自动故障切换(高可用)
问题: 1.MGR集群的其中1个节点挂掉后,sharding jdbc无法自动感知并切换主从关系,还是往挂掉的节点写数据,导致报错
2.sharingSphere-jdbc 还是sharingSphere-proxy才能支持配置高可用DB_DISCOVERY哦?还是说两者都可以,我不想用sharingSphere-proxy只想用sharingSphere-jdbc

已进行操作:

这是 sharding.yaml 配置文件
props:
sql-show: true
sql-simple: true
databaseName: database_discovery_db
dataSources:
ds_0:
driverClassName: com.mysql.cj.jdbc.Driver
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://192.168.2.241:3331/inventory?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: jskjmy666999
connectionTimeoutMilliseconds: 3000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
ds_1:
driverClassName: com.mysql.cj.jdbc.Driver
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://192.168.2.241:3332/inventory?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: jskjmy666999
connectionTimeoutMilliseconds: 3000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
ds_2:
driverClassName: com.mysql.cj.jdbc.Driver
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://192.168.2.241:3333/inventory?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: jskjmy666999
connectionTimeoutMilliseconds: 3000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
rules:

  • !READWRITE_SPLITTING
    dataSources:
    replica_ds:
    dynamicStrategy:
    autoAwareDataSourceName: readwrite_ds
    loadBalancerName: my_load_Balancer
    loadBalancers:
    my_load_Balancer:
    type: ROUND_ROBIN
  • !DB_DISCOVERY
    dataSources:
    readwrite_ds:
    dataSourceNames:
    - ds_0
    - ds_1
    - ds_2
    discoveryHeartbeatName: mgr_heartbeat
    discoveryTypeName: mgr
    discoveryHeartbeats:
    mgr_heartbeat:
    props:
    keep-alive-cron: ‘0/5 * * * * ?’
    discoveryTypes:
    mgr:
    type: MySQL.MGR
    props:
    group-name: 62536350-cfd8-11ee-8613-0242ac1a0004

现状:

MGR集群的其中1个节点挂掉后,sharding jdbc无法自动感知并切换主从关系

京ICP备2021015875号