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
   
![image](https://user-images.githubusercontent.com/27982943/117280616-5d15c500-ae95-11eb-98d0-d5fac56f0936.png)
   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:
us...@infra.apache.org


Reply via email to