Sharding Sphere 读写分离的配置
生活随笔
收集整理的這篇文章主要介紹了
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的相关代理