下载
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
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 面试官心理分析 其实这块肯定是扯到高并发了,因为分库分表一定是为了支撑高并发、数据量大两个问题的。而且现在说实话,...
- 原文出处:https://github.com/doocs/advanced-java/blob/master/d...
- 一、概述 顺势而为,大数据高并发要有系统不断的升级,分库分表便是其一。 二、为什么要分库分表 场景:随着互联网技术...
- 面试题 为什么要分库分表(设计高并发系统的时候,数据库层面该如何设计)?用过哪些分库分表中间件?不同的分库分表中间...
- 微信搜索“java进阶架构师”,选择“置顶公众号”更多精彩文章 20大进阶架构专题每日送达 一、背景 随着时间和业...