使用 GreateSQL MGR docker-compose 创建了 一主二从。镜像版本:greatsql/greatsql:8.0.25-16 SELECT * from replication_group_members; SECONDARY: show variables like '%read_only'; 使用 Apache ShardingSphere Proxy 5.3.1,配置读写分离,配置如下: databaseName: proxy_account dataSources: write_account: url: jdbc:mysql://192.168.1.168:3302/account?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true username: root password: root connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 1 read_account_1: url: jdbc:mysql://192.168.1.168:3303/account?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true username: root password: root connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 1 read_account_2: url: jdbc:mysql://192.168.1.168:3304/account?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true username: root password: root connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 1 rules: - !READWRITE_SPLITTING dataSources: readwrite_ds: staticStrategy: writeDataSourceName: write_account readDataSourceNames: - read_account_1 - read_account_2 loadBalancerName: random loadBalancers: random: type: RANDOM 配置负载均衡策略为随机,但是程序访问日志显示,读并没有走MGR从库。 多次查询访问,全部走的 write_account,没有走 read_account_1和read_account_2 程序为 Java Spring Boot Data JPA spring.application.name=account-service server.port=8083 spring.datasource.url=jdbc:mysql://192.168.1.168:3333/proxy_account?useSSL=false&serverTimezone=UTC spring.datasource.username=root spring.datasource.password=Aa123456 spring.jpa.show-sql=true spring.jpa.open-in-view=false 请问 问题出在哪儿?帮看看 |
yejr
2023-3-24 13:35:17
| ||
Jazz
2023-3-24 14:13:46
| ||
yejr
2023-3-24 18:52:24
| ||
合作电话:010-64087828
社区邮箱:greatsql@greatdb.com