blob: 950b00020e293502583afac5ce2b702a9fb04930 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>内置算法 on ShardingSphere</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/</link>
<description>Recent content in 内置算法 on ShardingSphere</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language>
<atom:link href="https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>元数据持久化仓库</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/metadata-repository/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/metadata-repository/</guid>
<description>背景信息 Apache ShardingSphere 为不同的运行模式提供了不同的元数据持久化方式,用户在配置运行模式的同时可以选择合适的方式来存储元数据。
参数解释 数据库持久化 类型:JDBC
适用模式:Standalone
可配置属性:
名称 数据类型 说明 默认值 provider String 元数据存储类型,可选值为 H2,MySQL H2 jdbc_url String JDBC URL jdbc:h2:mem:config;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL username String 账号 sa password String 密码 ZooKeeper 持久化 类型:ZooKeeper
适用模式:Cluster
可配置属性:
名称 数据类型 说明 默认值 retryIntervalMilliseconds int 重试间隔毫秒数 500 maxRetries int 客户端连接最大重试次数 3 timeToLiveSeconds int 临时数据失效的秒数 60 operationTimeoutMilliseconds int 客户端操作超时的毫秒数 500 digest String 登录认证密码 Etcd 持久化 类型:Etcd</description>
</item>
<item>
<title>分片算法</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/sharding/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/sharding/</guid>
<description>背景信息 ShardingSphere 内置提供了多种分片算法,按照类型可以划分为自动分片算法、标准分片算法、复合分片算法和 Hint 分片算法,能够满足用户绝大多数业务场景的需要。此外,考虑到业务场景的复杂性,内置算法也提供了自定义分片算法的方式,用户可以通过编写 Java 代码来完成复杂的分片逻辑。
参数解释 自动分片算法 取模分片算法 类型:MOD
可配置属性:
属性名称 数据类型 说明 sharding-count int 分片数量 哈希取模分片算法 类型:HASH_MOD
可配置属性:
属性名称 数据类型 说明 sharding-count int 分片数量 基于分片容量的范围分片算法 类型:VOLUME_RANGE
可配置属性:
属性名称 数据类型 说明 range-lower long 范围下界,超过边界的数据会报错 range-upper long 范围上界,超过边界的数据会报错 sharding-volume long 分片容量 基于分片边界的范围分片算法 类型:BOUNDARY_RANGE</description>
</item>
<item>
<title>分布式序列算法</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/keygen/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/keygen/</guid>
<description>背景信息 传统数据库软件开发中,主键自动生成技术是基本需求。而各个数据库对于该需求也提供了相应的支持,比如 MySQL 的自增键,Oracle 的自增序列等。 数据分片后,不同数据节点生成全局唯一主键是非常棘手的问题。同一个逻辑表内的不同实际表之间的自增键由于无法互相感知而产生重复主键。 虽然可通过约束自增主键初始值和步长的方式避免碰撞,但需引入额外的运维规则,使解决方案缺乏完整性和可扩展性。
目前有许多第三方解决方案可以完美解决这个问题,如 UUID 等依靠特定算法自生成不重复键,或者通过引入主键生成服务等。为了方便用户使用、满足不同用户不同使用场景的需求, Apache ShardingSphere 不仅提供了内置的分布式主键生成器,例如 UUID、SNOWFLAKE,还抽离出分布式主键生成器的接口,方便用户自行实现自定义的自增主键生成器。
参数解释 雪花算法 类型:SNOWFLAKE
可配置属性:
属性名称 数据类型 说明 默认值 worker-id (?) long 工作机器唯一标识 0 max-vibration-offset (?) int 最大抖动上限值,范围[0, 4096)。注:若使用此算法生成值作分片值,建议配置此属性。此算法在不同毫秒内所生成的 key 取模 2^n (2^n一般为分库或分表数) 之后结果总为 0 或 1。为防止上述分片问题,建议将此属性值配置为 (2^n)-1 1 max-tolerate-time-difference-milliseconds (?) long 最大容忍时钟回退时间,单位:毫秒 10 毫秒 注意:worker-id 为选配项
在单机模式下支持用户自定义配置,如果用户不配置使用默认值为0。 在集群模式下会由系统自动生成,相同的命名空间下不会生成重复的值。 NanoID 类型:NANOID</description>
</item>
<item>
<title>负载均衡算法</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/load-balance/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/load-balance/</guid>
<description>背景信息 ShardingSphere 内置提供了多种负载均衡算法,具体包括了轮询算法、随机访问算法和权重访问算法,能够满足用户绝大多数业务场景的需要。此外,考虑到业务场景的复杂性,内置算法也提供了扩展方式,用户可以基于 SPI 接口实现符合自己业务需要的负载均衡算法。
参数解释 轮询负载均衡算法 类型:ROUND_ROBIN
随机负载均衡算法 类型:RANDOM
权重负载均衡算法 类型:WEIGHT
可配置属性:
属性名称 数据类型 说明 ${replica-name} double 属性名使用读库名称,参数填写读库对应的权重值。权重参数范围最小值 &amp;gt; 0,合计 &amp;lt;= Double.MAX_VALUE。 操作步骤 使用读写分离时,在 loadBalancers 属性下配置对应的负载均衡算法即可; 配置示例 rules: - !READWRITE_SPLITTING dataSources: readwrite_ds: writeDataSourceName: write_ds readDataSourceNames: - read_ds_0 - read_ds_1 loadBalancerName: random transactionalReadQueryStrategy: PRIMARY loadBalancers: random: type: RANDOM props: 相关参考 核心特性:读写分离 开发者指南:读写分离 </description>
</item>
<item>
<title>加密算法</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/encrypt/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/encrypt/</guid>
<description>背景信息 加密算法是 Apache ShardingSphere 的加密功能使用的算法,ShardingSphere 内置了多种算法,可以让用户方便使用。
参数解释 标准加密算法 AES 加密算法 类型:AES
可配置属性:
名称 数据类型 说明 aes-key-value String AES 使用的 KEY digest-algorithm-name String AES KEY 的摘要算法 (可选,默认值:SHA-1) RC4 加密算法 类型:RC4
可配置属性:
名称 数据类型 说明 rc4-key-value String RC4 使用的 KEY SM3 加密算法 类型:SM3
可配置属性:
名称 数据类型 说明 sm3-salt String SM3 使用的 SALT(空或 8 Bytes) SM4 加密算法 类型:SM4</description>
</item>
<item>
<title>影子算法</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/shadow/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/shadow/</guid>
<description>背景信息 影子库功能对执行的 SQL 语句进行影子判定。影子判定支持两种类型算法,用户可根据实际业务需求选择一种或者组合使用。
参数解释 列影子算法 列值匹配算法 类型:VALUE_MATCH
属性名称 数据类型 说明 column String 影子列 operation String SQL 操作类型(INSERT, UPDATE, DELETE, SELECT) value String 影子列匹配的值 列正则表达式匹配算法 类型:REGEX_MATCH
属性名称 数据类型 说明 column String 匹配列 operation String SQL 操作类型(INSERT, UPDATE, DELETE, SELECT) regex String 影子列匹配正则表达式 Hint 影子算法 SQL HINT 影子算法 类型:SQL_HINT</description>
</item>
<item>
<title>SQL 翻译</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/sql-translator/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/sql-translator/</guid>
<description>原生 SQL 翻译器 类型:NATIVE
可配置属性:
默认使用的 SQL 翻译器,但目前暂未实现
使用 JooQ 的 SQL 翻译器 类型:JOOQ
可配置属性:
由于需要第三方的 JooQ 依赖,因此 ShardingSphere 默认并未包含相关模块,需要使用下面的 Maven 坐标引用该模块
&amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.apache.shardingsphere&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;shardingsphere-sql-translator-jooq-provider&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${project.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; </description>
</item>
<item>
<title>分片审计算法</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/audit/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/audit/</guid>
<description>背景信息 分片审计功能是针对数据库分片场景下对执行的 SQL 语句进行审计操作。分片审计既可以进行拦截操作,拦截系统配置的非法 SQL 语句,也可以是对 SQL 语句进行统计操作。
参数解释 DML_SHARDING_CONDITIONS 算法 类型:DML_SHARDING_CONDITIONS
操作步骤 配置数据分片规则时设置分配审计生成策略 配置示例 DML_SHARDING_CONDITIONS auditors: sharding_key_required_auditor: type: DML_SHARDING_CONDITIONS </description>
</item>
<item>
<title>脱敏算法</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/mask/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/mask/</guid>
<description>背景信息 脱敏算法是 Apache ShardingSphere 的脱敏功能使用的算法,ShardingSphere 内置了多种算法,可以让用户方便使用。
参数解释 哈希脱敏算法 MD5 脱敏算法 类型:MD5
可配置属性:
名称 数据类型 说明 salt String 盐值(可选) 遮盖脱敏算法 保留前 N 后 M 脱敏算法 类型:KEEP_FIRST_N_LAST_M
可配置属性:
名称 数据类型 说明 first-n int 前 n 位 last-m int 后 n 位 replace-char String 替换字符 保留自 X 至 Y 脱敏算法 类型:KEEP_FROM_X_TO_Y</description>
</item>
</channel>
</rss>