You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/05/06 10:04:25 UTC
[GitHub] [shardingsphere] w350727743 opened a new issue #10256: 读写无法分开
w350727743 opened a new issue #10256:
URL: https://github.com/apache/shardingsphere/issues/10256
在学习sharding-jdbc读写分离时候,遇到读写无法分开的问题,希望大佬能帮忙看一下。非常感谢!
`
# 配置真实数据源
spring.shardingsphere.datasource.names=demo,demo1,demo2
spring.shardingsphere.datasource.common.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.common.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.common.username=root
spring.shardingsphere.datasource.common.password= 123456
# 配置第 1 个数据源
spring.shardingsphere.datasource.demo.jdbc-url=jdbc:mysql://localhost:3306/demo?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
# 配置第 2 个数据源
spring.shardingsphere.datasource.demo1.jdbc-url=jdbc:mysql://localhost:3306/demo1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.demo2.jdbc-url=jdbc:mysql://localhost:3306/demo2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
# 写数据源名称
spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.write-data-source-name=demo
# 读数据源名称,多个从数据源用逗号分隔
spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.read-data-source-names=demo1,demo2
# 负载均衡算法名称
spring.shardingsphere.rules.readwrite-splitting.data-sources.pr_ds.load-balancer-name=round_robin
# 负载均衡算法配置
spring.shardingsphere.rules.readwrite-splitting.load-balancers.round_robin.type=ROUND_ROBIN
#打印sql
spring.shardingsphere.props.sql-show=true
mybatis.mapper-locations=classpath:mapper/*.xml
mybatis.type-aliases-package=com.lzc.shardingsphererwtest.entity
`
springboot版本:2.1.5.RELEASE
shardingsphere-jdbc-core-spring-boot-starter版本:5.0.0-alpha

demo属于测试中的主库,希望结果在做查询操作时候,读写分离应该读从库demo1,demo2
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu commented on issue #10256: 读写无法分开
Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #10256:
URL: https://github.com/apache/shardingsphere/issues/10256#issuecomment-833640080
**For English only**, other languages will not accept.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu closed issue #10256: 读写无法分开
Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #10256:
URL: https://github.com/apache/shardingsphere/issues/10256
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org