下載
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 包 復(fù)制到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} #數(shù)據(jù)節(jié)點
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
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 面試官心理分析 其實這塊肯定是扯到高并發(fā)了,因為分庫分表一定是為了支撐高并發(fā)、數(shù)據(jù)量大兩個問題的。而且現(xiàn)在說實話,...
- 原文出處:https://github.com/doocs/advanced-java/blob/master/d...
- 一、概述 順勢而為,大數(shù)據(jù)高并發(fā)要有系統(tǒng)不斷的升級,分庫分表便是其一。 二、為什么要分庫分表 場景:隨著互聯(lián)網(wǎng)技術(shù)...
- 面試題 為什么要分庫分表(設(shè)計高并發(fā)系統(tǒng)的時候,數(shù)據(jù)庫層面該如何設(shè)計)?用過哪些分庫分表中間件?不同的分庫分表中間...
- 微信搜索“java進階架構(gòu)師”,選擇“置頂公眾號”更多精彩文章 20大進階架構(gòu)專題每日送達 一、背景 隨著時間和業(yè)...