版本是 5.1.1 ,主从数据库,分表不分库,表 sharding 没啥问题,主从的读写分离就一直不行,请求各位大佬支援。
spring:
shardingsphere:
datasource:
names: ds0,ds1
# 主库 1,master 数据库
ds0:
xxxxxx
# 从库 1,slave 数据库
ds1:
xxxxx
props:
sql-show: true
sql-simple: false
# 是否在启动时检查分表元数据一致性
check-table-metadata-enabled: true
check-duplicate-table-enabled: false
sql-comment-parse-enabled: false
sql-federation-enabled: false
rules:
# 分片
sharding:
tables:
xxxxxx:
actual-data-nodes: ds$->{0..1}.xxxxx$->{0..7}
table-strategy:
standard:
sharding-column: uid
sharding-algorithm-name: xxxxAl
default-sharding-column: uid
binding-tables:
- xxxxxx
broadcast-tables:
default-database-strategy:
none:
default-table-strategy:
none:
sharding-algorithms:
xxxxAl:
type: INLINE
props:
algorithm-expression: xxxxxx_xxxx
### 读写分离
readwrite-splitting:
data-sources:
readwrite_ds:
type: Static
load-balancer-name: round_robin
props:
write-data-source-name: ds0
read-data-source-names: ds1
load-balancers:
round_robin:
type: ROUND_ROBIN