This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 08b6486 Issue10981 (#11477)
08b6486 is described below
commit 08b6486557ce1ee66a4d6345c5e646d3307c5c77
Author: fwhdzh <[email protected]>
AuthorDate: Sat Jul 24 17:39:55 2021 +0800
Issue10981 (#11477)
* Migrate YAML Configuration change history from
4.1.2.Configuration Manual->YAML Configuration->Change History to
7.2.API Change History->7.2.1.ShardingSphere-JDBC->YAML Configuration;
* Add content of change history
---
.../shardingsphere-jdbc/yaml-configuration.cn.md | 586 +++++++++++++++++++++
.../configuration/yaml/change-history.cn.md | 173 ------
2 files changed, 586 insertions(+), 173 deletions(-)
diff --git
a/docs/document/content/others/api-change-history/shardingsphere-jdbc/yaml-configuration.cn.md
b/docs/document/content/others/api-change-history/shardingsphere-jdbc/yaml-configuration.cn.md
new file mode 100644
index 0000000..cf8c113
--- /dev/null
+++
b/docs/document/content/others/api-change-history/shardingsphere-jdbc/yaml-configuration.cn.md
@@ -0,0 +1,586 @@
++++
+title = "YAML 配置"
+weight = 2
++++
+
+## 5.0.0-alpha
+
+### 数据分片
+
+#### 配置项说明
+
+```yaml
+dataSources: # 省略数据源配置,请参考使用手册
+
+rules:
+- !SHARDING
+ tables: # 数据分片规则配置
+ <logic-table-name> (+): # 逻辑表名称
+ actualDataNodes (?): # 由数据源名 + 表名组成(参考Inline语法规则)
+ databaseStrategy (?): # 分库策略,缺省表示使用默认分库策略,以下的分片策略只能选其一
+ standard: # 用于单分片键的标准分片场景
+ shardingColumn: # 分片列名称
+ shardingAlgorithmName: # 分片算法名称
+ complex: # 用于多分片键的复合分片场景
+ shardingColumns: #分片列名称,多个列以逗号分隔
+ shardingAlgorithmName: # 分片算法名称
+ hint: # Hint 分片策略
+ shardingAlgorithmName: # 分片算法名称
+ none: # 不分片
+ tableStrategy: # 分表策略,同分库策略
+ keyGenerateStrategy: # 分布式序列策略
+ column: # 自增列名称,缺省表示不使用自增主键生成器
+ keyGeneratorName: # 分布式序列算法名称
+ autoTables: # 自动分片表规则配置
+ t_order_auto: # 逻辑表名称
+ actualDataSources (?): # 数据源名称
+ shardingStrategy: # 切分策略
+ standard: # 用于单分片键的标准分片场景
+ shardingColumn: # 分片列名称
+ shardingAlgorithmName: # 自动分片算法名称
+ bindingTables (+): # 绑定表规则列表
+ - <logic_table_name_1, logic_table_name_2, ...>
+ - <logic_table_name_1, logic_table_name_2, ...>
+ broadcastTables (+): # 广播表规则列表
+ - <table-name>
+ - <table-name>
+ defaultDatabaseStrategy: # 默认数据库分片策略
+ defaultTableStrategy: # 默认表分片策略
+ defaultKeyGenerateStrategy: # 默认的分布式序列策略
+
+ # 分片算法配置
+ shardingAlgorithms:
+ <sharding-algorithm-name> (+): # 分片算法名称
+ type: # 分片算法类型
+ props: # 分片算法属性配置
+ # ...
+
+ # 分布式序列算法配置
+ keyGenerators:
+ <key-generate-algorithm-name> (+): # 分布式序列算法名称
+ type: # 分布式序列算法类型
+ props: # 分布式序列算法属性配置
+ # ...
+
+props:
+ # ...
+```
+
+### 读写分离
+
+#### 配置项说明
+
+```yaml
+dataSources: # 省略数据源配置,请参考使用手册
+
+rules:
+- !REPLICA_QUERY
+ dataSources:
+ <data-source-name> (+): # 读写分离逻辑数据源名称
+ primaryDataSourceName: # 主库数据源名称
+ replicaDataSourceNames:
+ - <replica-data_source-name> (+) # 从库数据源名称
+ loadBalancerName: # 负载均衡算法名称
+
+ # 负载均衡算法配置
+ loadBalancers:
+ <load-balancer-name> (+): # 负载均衡算法名称
+ type: # 负载均衡算法类型
+ props: # 负载均衡算法属性配置
+ # ...
+
+props:
+ # ...
+```
+
+算法类型的详情,请参见[内置负载均衡算法列表](/cn/user-manual/shardingsphere-jdbc/configuration/built-in-algorithm/load-balance)。
+
+### 数据加密
+
+#### 配置项说明
+
+```yaml
+dataSource: # 省略数据源配置,请参考使用手册
+
+rules:
+- !ENCRYPT
+ tables:
+ <table-name> (+): # 加密表名称
+ columns:
+ <column-name> (+): # 加密列名称
+ cipherColumn: # 密文列名称
+ assistedQueryColumn (?): # 查询辅助列名称
+ plainColumn (?): # 原文列名称
+ encryptorName: # 加密算法名称
+
+ # 加密算法配置
+ encryptors:
+ <encrypt-algorithm-name> (+): # 加解密算法名称
+ type: # 加解密算法类型
+ props: # 加解密算法属性配置
+ # ...
+
+ queryWithCipherColumn: # 是否使用加密列进行查询。在有原文列的情况下,可以使用原文列进行查询
+```
+
+算法类型的详情,请参见[内置加密算法列表](/cn/user-manual/shardingsphere-jdbc/configuration/built-in-algorithm/encrypt)。
+
+### 影子库
+
+#### 配置项说明
+
+```yaml
+dataSources: # 省略数据源配置,请参考使用手册
+
+rules:
+- !SHADOW
+ column: # 影子字段名
+ sourceDataSourceNames: # 影子前数据库名
+ # ...
+ shadowDataSourceNames: # 对应的影子库名
+ # ...
+
+props:
+ # ...
+```
+
+### 分布式治理
+
+#### 配置项说明
+
+```yaml
+governance:
+ name: # 治理名称
+ registryCenter: # 配置中心
+ type: # 治理持久化类型。如:Zookeeper, etcd
+ serverLists: # 治理服务列表。包括 IP 地址和端口号。多个地址用逗号分隔。如: host1:2181,host2:2181
+ overwrite: # 本地配置是否覆盖配置中心配置。如果可覆盖,每次启动都以本地配置为准
+```
+
+## ShardingSphere-4.x
+
+### 数据分片
+
+#### 配置项说明
+
+```yaml
+dataSources:
+ ds0: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds0
+ username: root
+ password:
+ ds1: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds1
+ username: root
+ password:
+
+shardingRule:
+ tables:
+ t_order:
+ actualDataNodes: ds${0..1}.t_order${0..1}
+ databaseStrategy:
+ inline:
+ shardingColumn: user_id
+ algorithmExpression: ds${user_id % 2}
+ tableStrategy:
+ inline:
+ shardingColumn: order_id
+ algorithmExpression: t_order${order_id % 2}
+ keyGenerator:
+ type: SNOWFLAKE
+ column: order_id
+ t_order_item:
+ actualDataNodes: ds${0..1}.t_order_item${0..1}
+ databaseStrategy:
+ inline:
+ shardingColumn: user_id
+ algorithmExpression: ds${user_id % 2}
+ tableStrategy:
+ inline:
+ shardingColumn: order_id
+ algorithmExpression: t_order_item${order_id % 2}
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_config
+
+ defaultDataSourceName: ds0
+ defaultTableStrategy:
+ none:
+ defaultKeyGenerator:
+ type: SNOWFLAKE
+ column: order_id
+
+props:
+ sql.show: true
+```
+
+### 读写分离
+
+#### 配置项说明
+
+```yaml
+dataSources:
+ ds_master: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds_master
+ username: root
+ password:
+ ds_slave0: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds_slave0
+ username: root
+ password:
+ ds_slave1: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds_slave1
+ username: root
+ password:
+
+masterSlaveRule:
+ name: ds_ms
+ masterDataSourceName: ds_master
+ slaveDataSourceNames: [ds_slave0, ds_slave1]
+
+props:
+ sql.show: true
+```
+
+通过 `YamlMasterSlaveDataSourceFactory` 工厂类创建 `DataSource`:
+
+```java
+DataSource dataSource =
YamlMasterSlaveDataSourceFactory.createDataSource(yamlFile);
+```
+
+### 数据脱敏
+
+#### 配置项说明
+
+```yaml
+dataSource: !!org.apache.commons.dbcp2.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://127.0.0.1:3306/encrypt?serverTimezone=UTC&useSSL=false
+ username: root
+ password:
+
+encryptRule:
+ encryptors:
+ encryptor_aes:
+ type: aes
+ props:
+ aes.key.value: 123456abc
+ encryptor_md5:
+ type: md5
+ tables:
+ t_encrypt:
+ columns:
+ user_id:
+ plainColumn: user_plain
+ cipherColumn: user_cipher
+ encryptor: encryptor_aes
+ order_id:
+ cipherColumn: order_cipher
+ encryptor: encryptor_md5
+props:
+ query.with.cipher.column: true #是否使用密文列查询
+```
+
+### 治理
+
+#### 配置项说明
+
+```yaml
+#省略数据分片、读写分离和数据脱敏配置
+
+orchestration:
+ name: orchestration_ds
+ overwrite: true
+ registry:
+ type: zookeeper
+ namespace: orchestration
+ serverLists: localhost:2181
+```
+
+## ShardingSphere-3.x
+
+### 数据分片
+
+#### 配置项说明
+
+```yaml
+dataSources:
+ ds0: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds0
+ username: root
+ password:
+ ds1: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds1
+ username: root
+ password:
+
+shardingRule:
+ tables:
+ t_order:
+ actualDataNodes: ds${0..1}.t_order${0..1}
+ databaseStrategy:
+ inline:
+ shardingColumn: user_id
+ algorithmExpression: ds${user_id % 2}
+ tableStrategy:
+ inline:
+ shardingColumn: order_id
+ algorithmExpression: t_order${order_id % 2}
+ keyGeneratorColumnName: order_id
+ t_order_item:
+ actualDataNodes: ds${0..1}.t_order_item${0..1}
+ databaseStrategy:
+ inline:
+ shardingColumn: user_id
+ algorithmExpression: ds${user_id % 2}
+ tableStrategy:
+ inline:
+ shardingColumn: order_id
+ algorithmExpression: t_order_item${order_id % 2}
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_config
+
+ defaultDataSourceName: ds0
+ defaultTableStrategy:
+ none:
+ defaultKeyGeneratorClassName:
io.shardingsphere.core.keygen.DefaultKeyGenerator
+
+props:
+ sql.show: true
+```
+
+### 读写分离
+
+#### 配置项说明
+
+```yaml
+dataSources:
+ ds_master: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds_master
+ username: root
+ password:
+ ds_slave0: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds_slave0
+ username: root
+ password:
+ ds_slave1: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/ds_slave1
+ username: root
+ password:
+
+masterSlaveRule:
+ name: ds_ms
+ masterDataSourceName: ds_master
+ slaveDataSourceNames: [ds_slave0, ds_slave1]
+ props:
+ sql.show: true
+ configMap:
+ key1: value1
+```
+
+通过 `MasterSlaveDataSourceFactory` 工厂类创建 `DataSource`:
+
+```java
+DataSource dataSource =
MasterSlaveDataSourceFactory.createDataSource(yamlFile);
+```
+
+### 治理
+
+#### 配置项说明
+
+```yaml
+#省略数据分片和读写分离配置
+
+orchestration:
+ name: orchestration_ds
+ overwrite: true
+ registry:
+ namespace: orchestration
+ serverLists: localhost:2181
+```
+
+## ShardingSphere-2.x
+
+### 数据分片
+
+#### 配置项说明
+
+```yaml
+dataSources:
+ db0: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: org.h2.Driver
+ url: jdbc:h2:mem:db0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
+ username: sa
+ password:
+ maxActive: 100
+ db1: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: org.h2.Driver
+ url: jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
+ username: sa
+ password:
+ maxActive: 100
+
+shardingRule:
+ tables:
+ config:
+ actualDataNodes: db${0..1}.t_config
+ t_order:
+ actualDataNodes: db${0..1}.t_order_${0..1}
+ databaseStrategy:
+ standard:
+ shardingColumn: user_id
+ preciseAlgorithmClassName:
io.shardingjdbc.core.yaml.fixture.SingleAlgorithm
+ tableStrategy:
+ inline:
+ shardingColumn: order_id
+ algorithmInlineExpression: t_order_${order_id % 2}
+ keyGeneratorColumnName: order_id
+ keyGeneratorClass:
io.shardingjdbc.core.yaml.fixture.IncrementKeyGenerator
+ t_order_item:
+ actualDataNodes: db${0..1}.t_order_item_${0..1}
+ #绑定表中其余的表的策略与第一张表的策略相同
+ databaseStrategy:
+ standard:
+ shardingColumn: user_id
+ preciseAlgorithmClassName:
io.shardingjdbc.core.yaml.fixture.SingleAlgorithm
+ tableStrategy:
+ inline:
+ shardingColumn: order_id
+ algorithmInlineExpression: t_order_item_${order_id % 2}
+ bindingTables:
+ - t_order,t_order_item
+ #默认数据库分片策略
+ defaultDatabaseStrategy:
+ none:
+ defaultTableStrategy:
+ complex:
+ shardingColumns: id, order_id
+ algorithmClassName: io.shardingjdbc.core.yaml.fixture.MultiAlgorithm
+ props:
+ sql.show: true
+```
+
+### 读写分离
+
+#### 概念
+
+为了缓解数据库压力,将写入和读取操作分离为不同数据源,写库称为主库,读库称为从库,一主库可配置多从库。
+
+#### 支持项
+
+1. 提供了一主多从的读写分离配置,可独立使用,也可配合分库分表使用。
+2. 独立使用读写分离支持SQL透传。
+3. 同一线程且同一数据库连接内,如有写入操作,以后的读操作均从主库读取,用于保证数据一致性。
+4. Spring命名空间。
+5. 基于Hint的强制主库路由。
+
+#### 不支持范围
+
+1. 主库和从库的数据同步。
+2. 主库和从库的数据同步延迟导致的数据不一致。
+3. 主库双写或多写。
+
+#### 配置规则
+
+```yaml
+dataSources:
+ db_master: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: org.h2.Driver
+ url:
jdbc:h2:mem:db_master;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
+ username: sa
+ password:
+ maxActive: 100
+ db_slave_0: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: org.h2.Driver
+ url:
jdbc:h2:mem:db_slave_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
+ username: sa
+ password:
+ maxActive: 100
+ db_slave_1: !!org.apache.commons.dbcp.BasicDataSource
+ driverClassName: org.h2.Driver
+ url:
jdbc:h2:mem:db_slave_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
+ username: sa
+ password:
+ maxActive: 100
+
+masterSlaveRule:
+ name: db_ms
+ masterDataSourceName: db_master
+ slaveDataSourceNames: [db_slave_0, db_slave_1]
+ configMap:
+ key1: value1
+```
+
+通过 `MasterSlaveDataSourceFactory` 工厂类创建 `DataSource`:
+
+```java
+DataSource dataSource =
MasterSlaveDataSourceFactory.createDataSource(yamlFile);
+```
+
+
+### 治理
+
+#### 配置项说明
+
+Zookeeper分库分表编排配置项说明
+
+```yaml
+dataSources: 数据源配置
+
+shardingRule: 分片规则配置
+
+orchestration: Zookeeper编排配置
+ name: 编排服务节点名称
+ overwrite: 本地配置是否可覆盖注册中心配置。如果可覆盖,每次启动都以本地配置为准
+ zookeeper: Zookeeper注册中心配置
+ namespace: Zookeeper的命名空间
+ serverLists: 连接Zookeeper服务器的列表。包括IP地址和端口号。多个地址用逗号分隔。如:
host1:2181,host2:2181
+ baseSleepTimeMilliseconds: 等待重试的间隔时间的初始值。单位:毫秒
+ maxSleepTimeMilliseconds: 等待重试的间隔时间的最大值。单位:毫秒
+ maxRetries: 最大重试次数
+ sessionTimeoutMilliseconds: 会话超时时间。单位:毫秒
+ connectionTimeoutMilliseconds: 连接超时时间。单位:毫秒
+ digest: 连接Zookeeper的权限令牌。缺省为不需要权限验证
+```
+
+Etcd分库分表编排配置项说明
+
+```yaml
+dataSources: 数据源配置
+
+shardingRule: 分片规则配置
+
+orchestration: Etcd编排配置
+ name: 编排服务节点名称
+ overwrite: 本地配置是否可覆盖注册中心配置。如果可覆盖,每次启动都以本地配置为准
+ etcd: Etcd注册中心配置
+ serverLists: 连接Etcd服务器的列表。包括IP地址和端口号。多个地址用逗号分隔。如:
http://host1:2379,http://host2:2379
+ timeToLiveSeconds: 临时节点存活时间。单位:秒
+ timeoutMilliseconds: 每次请求的超时时间。单位:毫秒
+ maxRetries: 每次请求的最大重试次数
+ retryIntervalMilliseconds: 重试间隔时间。单位:毫秒
+```
+
+分库分表编排数据源构建方式
+
+```java
+DataSource dataSource =
OrchestrationShardingDataSourceFactory.createDataSource(yamlFile);
+```
+
+读写分离数据源构建方式
+```java
+DataSource dataSource =
OrchestrationMasterSlaveDataSourceFactory.createDataSource(yamlFile);
+```
\ No newline at end of file
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/change-history.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/change-history.cn.md
deleted file mode 100644
index 3a2981d..0000000
---
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/change-history.cn.md
+++ /dev/null
@@ -1,173 +0,0 @@
-+++
-title = "变更历史"
-weight = 7
-+++
-
-## 5.0.0-alpha
-
-### 读写分离
-
-#### 配置项说明
-
-```yaml
-dataSources: # 省略数据源配置,请参考使用手册
-
-rules:
-- !REPLICA_QUERY
- dataSources:
- <data-source-name> (+): # 读写分离逻辑数据源名称
- primaryDataSourceName: # 主库数据源名称
- replicaDataSourceNames:
- - <replica-data_source-name> (+) # 从库数据源名称
- loadBalancerName: # 负载均衡算法名称
-
- # 负载均衡算法配置
- loadBalancers:
- <load-balancer-name> (+): # 负载均衡算法名称
- type: # 负载均衡算法类型
- props: # 负载均衡算法属性配置
- # ...
-
-props:
- # ...
-```
-
-算法类型的详情,请参见[内置负载均衡算法列表](/cn/user-manual/shardingsphere-jdbc/configuration/built-in-algorithm/load-balance)。
-
-## ShardingSphere-4.x
-
-### 读写分离
-
-#### 配置项说明
-
-```yaml
-dataSources:
- ds_master: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_master
- username: root
- password:
- ds_slave0: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_slave0
- username: root
- password:
- ds_slave1: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_slave1
- username: root
- password:
-
-masterSlaveRule:
- name: ds_ms
- masterDataSourceName: ds_master
- slaveDataSourceNames: [ds_slave0, ds_slave1]
-
-props:
- sql.show: true
-```
-
-通过 `YamlMasterSlaveDataSourceFactory` 工厂类创建 `DataSource`:
-
-```java
-DataSource dataSource =
YamlMasterSlaveDataSourceFactory.createDataSource(yamlFile);
-```
-
-## ShardingSphere-3.x
-
-### 读写分离
-
-#### 配置项说明
-
-```yaml
-dataSources:
- ds_master: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_master
- username: root
- password:
- ds_slave0: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_slave0
- username: root
- password:
- ds_slave1: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: com.mysql.jdbc.Driver
- url: jdbc:mysql://localhost:3306/ds_slave1
- username: root
- password:
-
-masterSlaveRule:
- name: ds_ms
- masterDataSourceName: ds_master
- slaveDataSourceNames: [ds_slave0, ds_slave1]
- props:
- sql.show: true
- configMap:
- key1: value1
-```
-
-通过 `MasterSlaveDataSourceFactory` 工厂类创建 `DataSource`:
-
-```java
-DataSource dataSource =
MasterSlaveDataSourceFactory.createDataSource(yamlFile);
-```
-
-## ShardingSphere-2.x
-
-### 读写分离
-
-#### 概念
-
-为了缓解数据库压力,将写入和读取操作分离为不同数据源,写库称为主库,读库称为从库,一主库可配置多从库。
-
-#### 支持项
-
-1. 提供了一主多从的读写分离配置,可独立使用,也可配合分库分表使用。
-2. 独立使用读写分离支持SQL透传。
-3. 同一线程且同一数据库连接内,如有写入操作,以后的读操作均从主库读取,用于保证数据一致性。
-4. Spring命名空间。
-5. 基于Hint的强制主库路由。
-
-#### 不支持范围
-
-1. 主库和从库的数据同步。
-2. 主库和从库的数据同步延迟导致的数据不一致。
-3. 主库双写或多写。
-
-#### 配置规则
-
-```yaml
-dataSources:
- db_master: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: org.h2.Driver
- url:
jdbc:h2:mem:db_master;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
- username: sa
- password:
- maxActive: 100
- db_slave_0: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: org.h2.Driver
- url:
jdbc:h2:mem:db_slave_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
- username: sa
- password:
- maxActive: 100
- db_slave_1: !!org.apache.commons.dbcp.BasicDataSource
- driverClassName: org.h2.Driver
- url:
jdbc:h2:mem:db_slave_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
- username: sa
- password:
- maxActive: 100
-
-masterSlaveRule:
- name: db_ms
- masterDataSourceName: db_master
- slaveDataSourceNames: [db_slave_0, db_slave_1]
- configMap:
- key1: value1
-```
-
-通过 `MasterSlaveDataSourceFactory` 工厂类创建 `DataSource`:
-
-```java
-DataSource dataSource =
MasterSlaveDataSourceFactory.createDataSource(yamlFile);
-```