MGR 读写分离 从库只读不生效
使用 GreateSQL MGR docker-compose 创建了 一主二从。镜像版本:greatsql/greatsql:8.0.25-16SELECT * 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
请问 问题出在哪儿?帮看看
primary写入数据时,secondary能正常apply relay log而不报错吗?
印象中,是不能设置 innodb_read_only 的,否则会导致MGR工作异常。 yejr 发表于 2023-3-24 13:35
primary写入数据时,secondary能正常apply relay log而不报错吗?
印象中,是不能设置 innodb_read_only 的 ...
这MGR是GreateSQL docker-compose创建的,工作正常,可以apply relay log.
innodb_read_only 变量值 确实改动不,设置值 提示不允许更改。 Jazz 发表于 2023-3-24 14:13
这MGR是GreateSQL docker-compose创建的,工作正常,可以apply relay log.
innodb_read_only 变量值 确实 ...
GreatSQL发布的docker镜像应该是没有设置 `innodb_read_only = 1` 的。
页:
[1]