当前位置:
首页 >
Sharding Sphere 读写分离的配置
发布时间:2025/4/16
40
豆豆
生活随笔
收集整理的这篇文章主要介绍了
Sharding Sphere 读写分离的配置
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
#配置主从数据源,要基于MySQL主从架构。
spring.shardingsphere.datasource.names=m0,s0spring.shardingsphere.datasource.m0.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.m0.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.m0.url=jdbc:mysql://192.168.1.4:3306/masterdemo?serverTimezone=GMT%2B8
spring.shardingsphere.datasource.m0.username=root
spring.shardingsphere.datasource.m0.password=rootspring.shardingsphere.datasource.s0.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.s0.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.s0.url=jdbc:mysql://192.168.1.4:3306/masterdemo?serverTimezone=GMT%2B8
spring.shardingsphere.datasource.s0.username=root
spring.shardingsphere.datasource.s0.password=root
#读写分离规则, m0 主库,s0 从库
spring.shardingsphere.sharding.master-slave-rules.ds0.master-data-source-name=m0
spring.shardingsphere.sharding.master-slave-rules.ds0.slave-data-source-names[0]=s0
#基于读写分离的表分片
spring.shardingsphere.sharding.tables.t_dict.actual-data-nodes=ds0.t_dictspring.shardingsphere.sharding.tables.t_dict.key-generator.column=dict_id
spring.shardingsphere.sharding.tables.t_dict.key-generator.type=SNOWFLAKE
spring.shardingsphere.sharding.tables.t_dict.key-generator.props.worker.id=1spring.shardingsphere.props.sql.show = true
spring.main.allow-bean-definition-overriding=true
总结
以上是生活随笔为你收集整理的Sharding Sphere 读写分离的配置的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: Sharding Sphere如何配置,
- 下一篇: AOP的相关代理