spring.shardingsphere.datasource.names=swallow-bird0,swallow-bird1
spring.shardingsphere.datasource.swallow-bird0.type=com.zaxxer.hikari.hikaridatasource
spring.shardingsphere.datasource.swallow-bird0.driver-class-name=com.mysql.jdbc.driver
spring.shardingsphere.datasource.swallow-bird0.jdbc-url=jdbc:mysql://*******:3306/swallow_bird0?useunicode=true&characterencoding=utf-8
spring.shardingsphere.datasource.swallow-bird0.username=root
spring.shardingsphere.datasource.swallow-bird0.password=ab...?967426
spring.shardingsphere.datasource.swallow-bird0.maxactive=10
spring.shardingsphere.datasource.swallow-bird0.minimum-idle=5
spring.shardingsphere.datasource.swallow-bird0.maximum-pool-size=15
spring.shardingsphere.datasource.swallow-bird0.auto-commit=true
spring.shardingsphere.datasource.swallow-bird0.idle-timeout=30000
spring.shardingsphere.datasource.swallow-bird0.pool-name=hikaricp
spring.shardingsphere.datasource.swallow-bird0.max-lifetime=1800000
spring.shardingsphere.datasource.swallow-bird0.connection-timeout=30000
spring.shardingsphere.datasource.swallow-bird0.connection-test-query=select 1
spring.shardingsphere.datasource.swallow-bird1.type=com.zaxxer.hikari.hikaridatasource
spring.shardingsphere.datasource.swallow-bird1.driver-class-name=com.mysql.jdbc.driver
spring.shardingsphere.datasource.swallow-bird1.jdbc-url=jdbc:mysql://*******:3306/swallow_bird1?useunicode=true&characterencoding=utf-8
spring.shardingsphere.datasource.swallow-bird1.username=root
spring.shardingsphere.datasource.swallow-bird1.password=ab...?967426
spring.shardingsphere.datasource.swallow-bird1.maxactive=20
spring.shardingsphere.datasource.swallow-bird1.minimum-idle=5
spring.shardingsphere.datasource.swallow-bird1.maximum-pool-size=15
spring.shardingsphere.datasource.swallow-bird1.auto-commit=true
spring.shardingsphere.datasource.swallow-bird1.idle-timeout=30000
spring.shardingsphere.datasource.swallow-bird1.pool-name=hikaricp
spring.shardingsphere.datasource.swallow-bird1.max-lifetime=1800000
spring.shardingsphere.datasource.swallow-bird1.connection-timeout=30000
spring.shardingsphere.datasource.swallow-bird01.connection-test-query=select 1
#客戶表分表
spring.shardingsphere.sharding.tables.customer.actual-data-nodes=swallow-bird$->.customer_$->
spring.shardingsphere.sharding.tables.customer.database-strategy.standard.sharding-column=customer_id
spring.shardingsphere.sharding.tables.customer.database-strategy.standard.precise-algorithm-class-name=com.swallowbirds.sass.businesssystem.config.sharding.customsublibrary
spring.shardingsphere.sharding.tables.customer.table-strategy.standard.sharding-column=customer_id
spring.shardingsphere.sharding.tables.customer.table-strategy.standard.precise-algorithm-class-name=com.swallowbirds.sass.businesssystem.config.sharding.customsublibrartb
#好友分表
spring.shardingsphere.sharding.tables.friend.actual-data-nodes=swallow-bird$->.friend_$->
spring.shardingsphere.sharding.tables.friend.database-strategy.standard.sharding-column=customer_id
spring.shardingsphere.sharding.tables.friend.database-strategy.standard.precise-algorithm-class-name=com.swallowbirds.sass.businesssystem.config.sharding.customsublibrary
spring.shardingsphere.sharding.tables.friend.table-strategy.standard.sharding-column=customer_id
spring.shardingsphere.sharding.tables.friend.table-strategy.standard.precise-algorithm-class-name=com.swallowbirds.sass.businesssystem.config.sharding.customsublibrartb
這裡的配置是自定義分庫分表策略的方式
在策略方式中建議大家使用列舉,並且定義每個分表分庫的版本。這樣的設計,是當你的表資料達到一定量的時候,可以選擇提公升版本,來把資料優化儲存。具體的**博主實現是
public enum dbandtableenum
public string gettablename()
public string getshardingkey()
public string getbiztype()
public string getidversion()
public string getcharsprefix()
public int getnumberstartindex()
public int getdbindexbegin()
public int gettbindexbegin()
public int getdbcount()
public int gettbcount()
public string getdesc()
}
引入依賴`
io.shardingsphere
sharding-transaction-spring-boot-starter
4.0.0-rc1
現在版本更新到4.0.0-rc2了,不過使用方式差不不大。建議大家使用的,多參照官網
該元件使用,麻煩一點點就是,自己去設計分庫分別策略,與配置分庫分別的資料來源。希望給大家能帶來幫助
分布式訊息中介軟體
一 分布式訊息中介軟體入門 訊息中介軟體主要實現分布式系統中解耦 非同步訊息 流量銷鋒 日誌處理等場景。現在生產中用得最多的訊息佇列有 activemq,rabbitmq,kafka,rocketmq 等。jms 規範 類似於 jdbc 的一套介面規範,但不同的是他是面向的訊息服務,提供一套標準 a...
分布式訊息中介軟體 kafka
在我們大量使用分布式資料庫 分布式計算集群的時候,是否會遇到這樣的一些問題 這個時候,我們就可以用到分布式訊息系統了。雖然上面的描述更偏向於乙個日誌系統,但確實kafka在實際應用中被大量的用於日誌系統。首先我們要明白什麼是訊息系統,在kafka官網上對kafka的定義叫 a distributed...
Redis分布式中介軟體TwemProxy
twemproxy,也叫nutcraker。是乙個twtter開源的乙個redis和memcache 伺服器。redis作為乙個高效的快取伺服器,非常具有應用價值。但是當使用比較多的時候,就希望可以通過某種方式 統一進行管理。避免每個應用每個客戶端管理連線的鬆散性。同時在一定程度上變得可以控制。搜尋...