当前位置:网站首页>Configuration and practice of shardingsphere JDBC sub database separation of read and write
Configuration and practice of shardingsphere JDBC sub database separation of read and write
2022-06-13 03:25:00 【Python's path to becoming a God】
shardingsphere-jdbc Configuration and practice of sub database - Read / write separation
Main library :ds0, Slave Library :s0, Main library :ds1, Slave Library :s1
To configure
spring:
shardingsphere:
# Data source configuration
datasource:
names: ds0,s0,ds1,s1
# Slice library configuration
ds0:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ds0?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: 123456
initial-size: 5
maxActive: 5
maxWait: 60000
poolPreparedStatements: true
s0:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/s0?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: 123456
initial-size: 5
maxActive: 5
maxWait: 60000
poolPreparedStatements: true
ds1:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ds1?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: 123456
initial-size: 5
maxActive: 5
maxWait: 60000
poolPreparedStatements: true
s1:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/s1?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: 123456
initial-size: 5
maxActive: 5
maxWait: 60000
poolPreparedStatements: true
sharding:
default-database-strategy:
standard:
sharding-column: id
precise-algorithm-class-name: com.clsu.algorithm.MyPreciseAlgorithm
range-algorithm-class-name: com.clsu.algorithm.MyRangeAlgorithm
tables:
test:
actual-data-nodes: ds$->{0..1}.test$->{0..1}
table-strategy:
standard:
sharding-column: id
range-algorithm-class-name: com.clsu.algorithm.MyRangeAlgorithm
#split database impl
precise-algorithm-class-name: com.clsu.algorithm.MyPreciseAlgorithm
key-generator:
column: id
type: SNOWFLAKE
# Read write separation configuration
master-slave-rules:
ds0:
master-data-source-name: ds0
slave-data-source-names: s0
ds1:
master-data-source-name: ds1
slave-data-source-names: s1
props:
sql:
show: true
边栏推荐
- MySQL create user authorization remote access
- On the career crisis of programmers at the age of 35
- Detailed explanation of curl command
- Differences of several query methods in PDO
- DTCC | 2021 China map database technology conference link sharing
- Patrick Pichette, partner of inovia, former chief financial officer of Google and current chairman of twitter, joined the board of directors of neo4j
- 简述:分布式CAP理论和BASE理论
- [azure data platform] ETL tool (9) -- ADF performance optimization case sharing (1)
- 技术博客,经验分享宝典
- Sparksql of spark
猜你喜欢
On the career crisis of programmers at the age of 35
Sparksql of spark
MySQL transaction isolation level experiment
Video playback has repeatedly broken 1000w+, how to use the second dimension to create a popular model in Kwai
Use of jstack
[JVM series 4] common JVM commands
Azure SQL db/dw series (14) -- using query store (3) -- common scenarios
brew工具-“fatal: Could not resolve HEAD to a revision”错误解决
Azure SQL db/dw series (9) -- re understanding the query store (2) -- working principle
Azure SQL db/dw series (10) -- re understanding the query store (3) -- configuring the query store
随机推荐
QML connecting to MySQL database
Brief introduction: distributed cap theory and base theory
[azure data platform] ETL tool (3) - azure data factory copy from local data source to azure
Graph data modeling tool
Polymorphism in golang
Introduction to redis (using redis, common commands, persistence methods, and cluster operations)
Few-shot Unsupervised Domain Adaptation with Image-to-Class Sparse Similarity Encoding
Summary of virtualization technology development
MASA Auth - 从用户的角度看整体设计
The use of curl in PHP
Microservice practice based on rustlang
C language function strcmp() (compare two strings)
MySQL transactions and locks (V)
[JVM Series 2] runtime data area
Mongodb index -index
C simple understanding - overloaded operator
(九)详解广播机制
Figure data * reconstruction subgraph
Review notes of RS data communication foundation STP
Time processing class in PHP