下载
https://dlcdn.apache.org/shardingsphere/5.5.1/apache-shardingsphere-5.5.1-shardingsphere-proxy-bin.tar.gz
apache-shardingsphere-5.5.1-shardingsphere-proxy-bin
将idea Maven下的 mysql-connector-java 包 复制到lib
配置
databaseName: SALESMANAGER
dataSources:
ds_0:
url: jdbc:mysql://192.168.1.103:3036/SALESMANAGER?useSSL=false
username: root
password: wusu1314
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
ds_1:
url: jdbc:mysql://192.168.1.103:3037/SALESMANAGER?useSSL=false
username: root
password: wusu1314
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
minPoolSize: 1
rules:
- !READWRITE_SPLITTING
#读写分离
dataSourceGroups:
readwrite_ds:
writeDataSourceName: ds_0
readDataSourceNames:
- ds_1
# - read_ds_1
loadBalancerName: random
loadBalancers:
random:
type: RANDOM
- !SHARDING
#分库分表
tables:
orders:
actualDataNodes: ds_0.orders_${0..1} #数据节点
tableStrategy:
standard:
shardingColumn: ORDER_ID
shardingAlgorithmName: t_order_inline #算法分片
keyGenerateStrategy: #密钥生成策略
column: ORDER_ID
keyGeneratorName: snowflake #雪花算法
auditStrategy:
auditorNames:
- sharding_key_required_auditor
allowHintDisable: true
# product:
# actualDataNodes: ds_0.product_${0..1}
# tableStrategy:
# standard:
# shardingColumn: PRODUCT_ID
# shardingAlgorithmName: t_product_inline
# keyGenerateStrategy:
# column: PRODUCT_ID
# keyGeneratorName: snowflake
bindingTables:
- orders
defaultTableStrategy:
none:
defaultAuditStrategy:
auditorNames:
- sharding_key_required_auditor
allowHintDisable: true
shardingAlgorithms:
t_order_inline:
type: INLINE
props:
algorithm-expression: orders_${ORDER_ID % 2}
# t_product_inline:
# type: INLINE
# props:
# algorithm-expression: product_${PRODUCT_ID % 2}
keyGenerators:
snowflake:
type: SNOWFLAKE
auditors:
sharding_key_required_auditor:
type: DML_SHARDING_CONDITIONS
- !SINGLE
tables:
- "*.*"
以上为读写分离 +单库分表
分库分表 中间件 ShardingProxy
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- 面试官心理分析 其实这块肯定是扯到高并发了,因为分库分表一定是为了支撑高并发、数据量大两个问题的。而且现在说实话,...
- 原文出处:https://github.com/doocs/advanced-java/blob/master/d...
- 一、概述 顺势而为,大数据高并发要有系统不断的升级,分库分表便是其一。 二、为什么要分库分表 场景:随着互联网技术...
- 面试题 为什么要分库分表(设计高并发系统的时候,数据库层面该如何设计)?用过哪些分库分表中间件?不同的分库分表中间...
- 微信搜索“java进阶架构师”,选择“置顶公众号”更多精彩文章 20大进阶架构专题每日送达 一、背景 随着时间和业...