blob: ef73e6e7f7ae636cd61b4fee9d16290622acfcf2 [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>ShardingSphere</title>
<link>https://shardingsphere.apache.org/document/current/cn/</link>
<description>Recent content on ShardingSphere</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language>
<atom:link href="https://shardingsphere.apache.org/document/current/cn/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>ALTER READWRITE_SPLITTING RULE ENABLE/DISABLE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/circuit-breaker/alter-readwrite-splitting-rule-enable-disable/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/circuit-breaker/alter-readwrite-splitting-rule-enable-disable/</guid>
<description>描述 ALTER READWRITE_SPLITTING RULE ENABLE/DISABLE 语法用于启用/禁用指定逻辑库中指定读写分离规则中的指定读数据存储单元。
语法定义 语法 铁路图 AlterReadwriteSplittingRule ::= &amp;#39;ALTER&amp;#39; &amp;#39;READWRITE_SPLITTING&amp;#39; &amp;#39;RULE&amp;#39; groupName (&amp;#39;ENABLE&amp;#39; | &amp;#39;DISABLE&amp;#39;) storageUnitName &amp;#39;FROM&amp;#39; databaseName groupName ::= identifier storageUnitName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 示例 禁用指定逻辑库中指定读写分离规则中的指定读数据存储单元 ALTER READWRITE_SPLITTING RULE ms_group_0 DISABLE read_ds_0 FROM sharding_db; 启用指定逻辑库中指定读写分离规则中的指定读数据存储单元 ALTER READWRITE_SPLITTING RULE ms_group_0 ENABLE read_ds_0 FROM sharding_db; 禁用当前逻辑库中指定读写分离规则中的指定读数据存储单元 ALTER READWRITE_SPLITTING RULE ms_group_0 DISABLE read_ds_0; 启用当前逻辑库中指定读写分离规则中的指定读数据存储单元 ALTER READWRITE_SPLITTING RULE ms_group_1 ENABLE read_ds_0; 保留字 ALTER、READWRITE_SPLITTING、RULE、ENABLE、DISABLE</description>
</item>
<item>
<title>CREATE ENCRYPT RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt/create-encrypt-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt/create-encrypt-rule/</guid>
<description>描述 CREATE ENCRYPT RULE 语法用于创建数据加密规则。
语法定义 语法 铁路图 CreateEncryptRule ::= &amp;#39;CREATE&amp;#39; &amp;#39;ENCRYPT&amp;#39; &amp;#39;RULE&amp;#39; ifNotExists? encryptDefinition (&amp;#39;,&amp;#39; encryptDefinition)* ifNotExists ::= &amp;#39;IF&amp;#39; &amp;#39;NOT&amp;#39; &amp;#39;EXISTS&amp;#39; encryptDefinition ::= ruleName &amp;#39;(&amp;#39; &amp;#39;COLUMNS&amp;#39; &amp;#39;(&amp;#39; columnDefinition (&amp;#39;,&amp;#39; columnDefinition)* &amp;#39;)&amp;#39; &amp;#39;)&amp;#39; columnDefinition ::= &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; columnName &amp;#39;,&amp;#39; &amp;#39;CIPHER&amp;#39; &amp;#39;=&amp;#39; cipherColumnName (&amp;#39;,&amp;#39; &amp;#39;ASSISTED_QUERY&amp;#39; &amp;#39;=&amp;#39; assistedQueryColumnName)? (&amp;#39;,&amp;#39; &amp;#39;LIKE_QUERY&amp;#39; &amp;#39;=&amp;#39; likeQueryColumnName)? &amp;#39;,&amp;#39; encryptAlgorithmDefinition (&amp;#39;,&amp;#39; assistedQueryAlgorithmDefinition)? (&amp;#39;,&amp;#39; likeQueryAlgorithmDefinition)? &amp;#39;)&amp;#39; encryptAlgorithmDefinition ::= &amp;#39;ENCRYPT_ALGORITHM&amp;#39; &amp;#39;(&amp;#39; &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; encryptAlgorithmType (&amp;#39;,&amp;#39; propertiesDefinition)? &amp;#39;)&amp;#39; assistedQueryAlgorithmDefinition ::= &amp;#39;ASSISTED_QUERY_ALGORITHM&amp;#39; &amp;#39;(&amp;#39; &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; encryptAlgorithmType (&amp;#39;,&amp;#39; propertiesDefinition)?</description>
</item>
<item>
<title>CREATE MASK RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/mask/create-mask-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/mask/create-mask-rule/</guid>
<description>描述 CREATE MASK RULE 语法用于创建数据脱敏规则。
语法定义 语法 铁路图 CreateEncryptRule ::= &amp;#39;CREATE&amp;#39; &amp;#39;MASK&amp;#39; &amp;#39;RULE&amp;#39; ifNotExists? maskRuleDefinition (&amp;#39;,&amp;#39; maskRuleDefinition)* ifNotExists ::= &amp;#39;IF&amp;#39; &amp;#39;NOT&amp;#39; &amp;#39;EXISTS&amp;#39; maskRuleDefinition ::= ruleName &amp;#39;(&amp;#39; &amp;#39;COLUMNS&amp;#39; &amp;#39;(&amp;#39; columnDefinition (&amp;#39;,&amp;#39; columnDefinition)* &amp;#39;)&amp;#39; &amp;#39;)&amp;#39; columnDefinition ::= &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; columnName &amp;#39;,&amp;#39; maskAlgorithmDefinition &amp;#39;)&amp;#39; maskAlgorithmDefinition ::= &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; maskAlgorithmType (&amp;#39;,&amp;#39; propertiesDefinition)? &amp;#39;)&amp;#39; propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; ruleName ::= identifier columnName ::= identifier maskAlgorithmType ::= literal key ::= string value ::= literal 补充说明 maskAlgorithmType 指定数据脱敏算法类型,请参考 数据脱敏算法; 重复的 ruleName 将无法被创建; ifNotExists 子句用于避免出现 Duplicate mask rule 错误。 示例 创建数据脱敏规则 CREATE MASK RULE t_mask ( COLUMNS( (NAME=phone_number,TYPE(NAME=&amp;#39;MASK_FROM_X_TO_Y&amp;#39;, PROPERTIES(&amp;#34;from-x&amp;#34;=1, &amp;#34;to-y&amp;#34;=2, &amp;#34;replace-char&amp;#34;=&amp;#34;*&amp;#34;))), (NAME=address,TYPE(NAME=&amp;#39;MD5&amp;#39;)) )); 使用 ifNotExists 子句创建数据脱敏规则 CREATE MASK RULE IF NOT EXISTS t_mask ( COLUMNS( (NAME=phone_number,TYPE(NAME=&amp;#39;MASK_FROM_X_TO_Y&amp;#39;, PROPERTIES(&amp;#34;from-x&amp;#34;=1, &amp;#34;to-y&amp;#34;=2, &amp;#34;replace-char&amp;#34;=&amp;#34;*&amp;#34;))), (NAME=address,TYPE(NAME=&amp;#39;MD5&amp;#39;)) )); 保留字 CREATE、MASK、RULE、COLUMNS、NAME、TYPE</description>
</item>
<item>
<title>CREATE READWRITE_SPLITTING RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting/create-readwrite-splitting-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting/create-readwrite-splitting-rule/</guid>
<description>描述 。 CREATE READWRITE_SPLITTING RULE 语法用于创建读写分离规则。
语法定义 语法 铁路图 CreateReadwriteSplittingRule ::= &amp;#39;CREATE&amp;#39; &amp;#39;READWRITE_SPLITTING&amp;#39; &amp;#39;RULE&amp;#39; ifNotExists? readwriteSplittingDefinition (&amp;#39;,&amp;#39; readwriteSplittingDefinition)* ifNotExists ::= &amp;#39;IF&amp;#39; &amp;#39;NOT&amp;#39; &amp;#39;EXISTS&amp;#39; readwriteSplittingDefinition ::= ruleName &amp;#39;(&amp;#39; dataSourceDefinition (&amp;#39;,&amp;#39; transactionalReadQueryStrategyDefinition)? (&amp;#39;,&amp;#39; loadBalancerDefinition)? &amp;#39;)&amp;#39; dataSourceDefinition ::= &amp;#39;WRITE_STORAGE_UNIT&amp;#39; &amp;#39;=&amp;#39; writeStorageUnitName &amp;#39;,&amp;#39; &amp;#39;READ_STORAGE_UNITS&amp;#39; &amp;#39;(&amp;#39; storageUnitName (&amp;#39;,&amp;#39; storageUnitName)* &amp;#39;)&amp;#39; transactionalReadQueryStrategyDefinition ::= &amp;#39;TRANSACTIONAL_READ_QUERY_STRATEGY&amp;#39; &amp;#39;=&amp;#39; transactionalReadQueryStrategyType loadBalancerDefinition ::= &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; loadBalancerType (&amp;#39;,&amp;#39; propertiesDefinition)? &amp;#39;)&amp;#39; ruleName ::= identifier writeStorageUnitName ::= identifier storageUnitName ::= identifier transactionalReadQueryStrategyType ::= string loadBalancerType ::= string propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; key ::= string value ::= literal 补充说明 transactionalReadQueryStrategyType 指定事务内读请求路由策略,请参考YAML 配置; loadBalancerType 指定负载均衡算法类型,请参考负载均衡算法; 重复的 ruleName 将无法被创建; ifNotExists 子句用于避免出现 Duplicate readwrite_splitting rule 错误。 示例 创建读写分离规则 CREATE READWRITE_SPLITTING RULE ms_group_0 ( WRITE_STORAGE_UNIT=write_ds, READ_STORAGE_UNITS(read_ds_0,read_ds_1), TYPE(NAME=&amp;#34;random&amp;#34;) ); 使用 ifNotExists 子句创建读写分离规则 读写分离规则 CREATE READWRITE_SPLITTING RULE IF NOT EXISTS ms_group_0 ( WRITE_STORAGE_UNIT=write_ds, READ_STORAGE_UNITS(read_ds_0,read_ds_1), TYPE(NAME=&amp;#34;random&amp;#34;) ); 保留字 CREATE、READWRITE_SPLITTING、RULE、WRITE_STORAGE_UNIT、READ_STORAGE_UNITS 、TYPE、NAME、PROPERTIES、TRUE、FALSE</description>
</item>
<item>
<title>CREATE SHADOW RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/create-shadow-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/create-shadow-rule/</guid>
<description>描述 CREATE SHADOW RULE 语法用于创建影子库压测规则。
语法定义 语法 铁路图 CreateShadowRule ::= &amp;#39;CREATE&amp;#39; &amp;#39;SHADOW&amp;#39; &amp;#39;RULE&amp;#39; ifNotExists? shadowRuleDefinition (&amp;#39;,&amp;#39; shadowRuleDefinition)* ifNotExists ::= &amp;#39;IF&amp;#39; &amp;#39;NOT&amp;#39; &amp;#39;EXISTS&amp;#39; shadowRuleDefinition ::= ruleName &amp;#39;(&amp;#39; storageUnitMapping shadowTableRule (&amp;#39;,&amp;#39; shadowTableRule)* &amp;#39;)&amp;#39; storageUnitMapping ::= &amp;#39;SOURCE&amp;#39; &amp;#39;=&amp;#39; storageUnitName &amp;#39;,&amp;#39; &amp;#39;SHADOW&amp;#39; &amp;#39;=&amp;#39; storageUnitName shadowTableRule ::= tableName &amp;#39;(&amp;#39; shadowAlgorithm &amp;#39;)&amp;#39; shadowAlgorithm ::= &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; shadowAlgorithmType &amp;#39;,&amp;#39; propertiesDefinition &amp;#39;)&amp;#39; ruleName ::= identifier storageUnitName ::= identifier tableName ::= identifier algorithmName ::= identifier shadowAlgorithmType ::= string propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; key ::= string value ::= literal 补充说明 重复的 ruleName 无法被创建; storageUnitMapping 指定源数据库和影子库的映射关系,需使用 RDL 管理的 STORAGE UNIT ,请参考 存储单元; shadowAlgorithm 可同时作用于多个 shadowTableRule; algorithmName 会根据 ruleName、tableName 和 shadowAlgorithmType 自动生成; shadowAlgorithmType 目前支持 VALUE_MATCH、REGEX_MATCH 和 SQL_HINT; ifNotExists 子句用于避免出现 Duplicate shadow rule 错误。 示例 创建影子库压测规则 CREATE SHADOW RULE shadow_rule( SOURCE=demo_ds, SHADOW=demo_ds_shadow, t_order(TYPE(NAME=&amp;#34;SQL_HINT&amp;#34;)), t_order_item(TYPE(NAME=&amp;#34;VALUE_MATCH&amp;#34;, PROPERTIES(&amp;#34;operation&amp;#34;=&amp;#34;insert&amp;#34;,&amp;#34;column&amp;#34;=&amp;#34;user_id&amp;#34;, &amp;#34;value&amp;#34;=&amp;#39;1&amp;#39;))) ); 使用 ifNotExists 子句创建影子库压测规则 CREATE SHADOW RULE IF NOT EXISTS shadow_rule( SOURCE=demo_ds, SHADOW=demo_ds_shadow, t_order(TYPE(NAME=&amp;#34;SQL_HINT&amp;#34;)), t_order_item(TYPE(NAME=&amp;#34;VALUE_MATCH&amp;#34;, PROPERTIES(&amp;#34;operation&amp;#34;=&amp;#34;insert&amp;#34;,&amp;#34;column&amp;#34;=&amp;#34;user_id&amp;#34;, &amp;#34;value&amp;#34;=&amp;#39;1&amp;#39;))) ); 保留字 CREATE、SHADOW、RULE、SOURCE、SHADOW、TYPE、NAME、PROPERTIES</description>
</item>
<item>
<title>CREATE SHARDING TABLE RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-rule/</guid>
<description>描述 CREATE SHARDING TABLE RULE 语法用于为当前所选逻辑库添加分片规则。
语法定义 语法 铁路图 CreateShardingTableRule ::= &amp;#39;CREATE&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;RULE&amp;#39; ifNotExists? (tableDefinition | autoTableDefinition) (&amp;#39;,&amp;#39; (tableDefinition | autoTableDefinition))* ifNotExists ::= &amp;#39;IF&amp;#39; &amp;#39;NOT&amp;#39; &amp;#39;EXISTS&amp;#39; tableDefinition ::= tableName &amp;#39;(&amp;#39; &amp;#39;DATANODES&amp;#39; &amp;#39;(&amp;#39; dataNode (&amp;#39;,&amp;#39; dataNode)* &amp;#39;)&amp;#39; (&amp;#39;,&amp;#39; &amp;#39;DATABASE_STRATEGY&amp;#39; &amp;#39;(&amp;#39; strategyDefinition &amp;#39;)&amp;#39;)? (&amp;#39;,&amp;#39; &amp;#39;TABLE_STRATEGY&amp;#39; &amp;#39;(&amp;#39; strategyDefinition &amp;#39;)&amp;#39;)? (&amp;#39;,&amp;#39; &amp;#39;KEY_GENERATE_STRATEGY&amp;#39; &amp;#39;(&amp;#39; keyGenerateStrategyDefinition &amp;#39;)&amp;#39;)? (&amp;#39;,&amp;#39; &amp;#39;AUDIT_STRATEGY&amp;#39; &amp;#39;(&amp;#39; auditStrategyDefinition &amp;#39;)&amp;#39;)? &amp;#39;)&amp;#39; autoTableDefinition ::= tableName &amp;#39;(&amp;#39; &amp;#39;STORAGE_UNITS&amp;#39; &amp;#39;(&amp;#39; storageUnitName (&amp;#39;,&amp;#39; storageUnitName)* &amp;#39;)&amp;#39; &amp;#39;,&amp;#39; &amp;#39;SHARDING_COLUMN&amp;#39; &amp;#39;=&amp;#39; columnName &amp;#39;,&amp;#39; algorithmDefinition (&amp;#39;,&amp;#39; &amp;#39;KEY_GENERATE_STRATEGY&amp;#39; &amp;#39;(&amp;#39; keyGenerateStrategyDefinition &amp;#39;)&amp;#39;)?</description>
</item>
<item>
<title>PARSE SQL</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rul/parse-sql/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rul/parse-sql/</guid>
<description>描述 PARSE SQL 语法用于解析 SQL 并输出抽象语法树。
语法 语法 铁路图 ParseSql ::= &amp;#39;PARSE&amp;#39; sqlStatement 返回值说明 列 说明 parsed_statement 解析SQL语句类型 parsed_statement_detail 解析SQL语句细节 示例 解析 SQL 并输出抽象语法树 PARSE SELECT * FROM t_order; mysql&amp;gt; PARSE SELECT * FROM t_order; +----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | parsed_statement | parsed_statement_detail | +----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | MySQLSelectStatement | {&amp;#34;projections&amp;#34;:{&amp;#34;startIndex&amp;#34;:7,&amp;#34;stopIndex&amp;#34;:7,&amp;#34;projections&amp;#34;:[{&amp;#34;startIndex&amp;#34;:7,&amp;#34;stopIndex&amp;#34;:7}],&amp;#34;distinctRow&amp;#34;:false},&amp;#34;from&amp;#34;:{&amp;#34;tableName&amp;#34;:{&amp;#34;startIndex&amp;#34;:14,&amp;#34;stopIndex&amp;#34;:20,&amp;#34;identifier&amp;#34;:{&amp;#34;value&amp;#34;:&amp;#34;t_order&amp;#34;,&amp;#34;quoteCharacter&amp;#34;:&amp;#34;NONE&amp;#34;}}},&amp;#34;parameterCount&amp;#34;:0,&amp;#34;parameterMarkerSegments&amp;#34;:[],&amp;#34;commentSegments&amp;#34;:[]} | +----------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.</description>
</item>
<item>
<title>REGISTER STORAGE UNIT</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/storage-unit-definition/register-storage-unit/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/storage-unit-definition/register-storage-unit/</guid>
<description>描述 REGISTER STORAGE UNIT 语法用于为当前所选逻辑库(DATABASE)注册存储单元。
语法 语法 铁路图 RegisterStorageUnit ::= &amp;#39;REGISTER&amp;#39; &amp;#39;STORAGE&amp;#39; &amp;#39;UNIT&amp;#39; ifNotExists? storageUnitDefinition (&amp;#39;,&amp;#39; storageUnitDefinition)* storageUnitDefinition ::= storageUnitName &amp;#39;(&amp;#39; (&amp;#39;HOST&amp;#39; &amp;#39;=&amp;#39; hostName &amp;#39;,&amp;#39; &amp;#39;PORT&amp;#39; &amp;#39;=&amp;#39; port &amp;#39;,&amp;#39; &amp;#39;DB&amp;#39; &amp;#39;=&amp;#39; dbName | &amp;#39;URL&amp;#39; &amp;#39;=&amp;#39; url) &amp;#39;,&amp;#39; &amp;#39;USER&amp;#39; &amp;#39;=&amp;#39; user (&amp;#39;,&amp;#39; &amp;#39;PASSWORD&amp;#39; &amp;#39;=&amp;#39; password)? (&amp;#39;,&amp;#39; propertiesDefinition)?&amp;#39;)&amp;#39; ifNotExists ::= &amp;#39;IF&amp;#39; &amp;#39;NOT&amp;#39; &amp;#39;EXISTS&amp;#39; storageUnitName ::= identifier hostname ::= string port ::= int dbName ::= string url ::= string user ::= string password ::= string propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; key ::= string value ::= literal 特别说明 注册存储单元前请确认已经在 Proxy 中创建逻辑数据库,并执行 use 命令成功选择一个逻辑数据库; 确认注册的存储单元是可以正常连接的, 否则将不能注册成功; storageUnitName 区分大小写; storageUnitName 在当前逻辑库中需要唯一; storageUnitName 命名只允许使用字母、数字以及 _ ,且必须以字母开头; poolProperty 用于自定义连接池参数,key 必须和连接池参数名一致; ifNotExists 子句用于避免出现 Duplicate storage unit 的错误。 示例 使用标准模式注册存储单元 REGISTER STORAGE UNIT ds_0 ( HOST=&amp;#34;127.</description>
</item>
<item>
<title>SET DEFAULT SINGLE TABLE STORAGE UNIT</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/single-table/set-default-single-table-storage-unit/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/single-table/set-default-single-table-storage-unit/</guid>
<description>描述 SET DEFAULT SINGLE TABLE STORAGE UNIT 语法用于设置默认的单表存储单元。
语法定义 语法 铁路图 SetDefaultSingleTableStorageUnit ::= &amp;#39;SET&amp;#39; &amp;#39;DEFAULT&amp;#39; &amp;#39;SINGLE&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;STORAGE&amp;#39; &amp;#39;UNIT&amp;#39; singleTableDefinition singleTableDefinition ::= &amp;#39;=&amp;#39; (storageUnitName | &amp;#39;RANDOM&amp;#39;) storageUnitName ::= identifier 补充说明 STORAGE UNIT 需使用 RDL 管理的存储单元。 RANDOM 代表随机储存 示例 设置默认的单表存储单元 SET DEFAULT SINGLE TABLE STORAGE UNIT = ds_0; 设置默认的单表存储单元为随机储存 SET DEFAULT SINGLE TABLE STORAGE UNIT = RANDOM; 保留字 SET、DEFAULT、SINGLE、TABLE、STORAGE、UNIT、RANDOM</description>
</item>
<item>
<title>ShardingSphere-JDBC</title>
<link>https://shardingsphere.apache.org/document/current/cn/quick-start/shardingsphere-jdbc-quick-start/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/quick-start/shardingsphere-jdbc-quick-start/</guid>
<description>应用场景 Apache ShardingSphere-JDBC 可以通过 Java 和 YAML 这 2 种方式进行配置,开发者可根据场景选择适合的配置方式。
使用限制 目前仅支持 JAVA 语言
前提条件 开发环境需要具备 Java JRE 8 或更高版本。
操作步骤 规则配置。 详情请参见用户手册。
引入 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-jdbc-core&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${latest.release.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; 注意:请将 ${latest.release.version} 更改为实际的版本号。
创建 YAML 配置文件 # JDBC 逻辑库名称。在集群模式中,使用该参数来联通 ShardingSphere-JDBC 与 ShardingSphere-Proxy。 # 默认值:logic_db databaseName (?): mode: dataSources: rules: - !FOO_XXX ... - !BAR_XXX ... props: key_1: value_1 key_2: value_2 以 spring boot 为例,编辑 application.</description>
</item>
<item>
<title>SHOW AUTHORITY RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/show-authority-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/show-authority-rule/</guid>
<description>描述 SHOW AUTHORITY RULE 语法用于查询权限规则配置。
语法 语法 铁路图 ShowAuthorityRule ::= &amp;#39;SHOW&amp;#39; &amp;#39;AUTHORITY&amp;#39; &amp;#39;RULE&amp;#39; 返回值说明 列 说明 users 用户 provider 权限提供者类型 props 权限参数 示例 查询权限规则配置 SHOW AUTHORITY RULE; mysql&amp;gt; SHOW AUTHORITY RULE; +--------------------+---------------+-------+ | users | provider | props | +--------------------+---------------+-------+ | root@%; sharding@% | ALL_PERMITTED | | +--------------------+---------------+-------+ 1 row in set (0.</description>
</item>
<item>
<title>SHOW ENCRYPT RULES</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/encrypt/show-encrypt-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/encrypt/show-encrypt-rule/</guid>
<description>描述 SHOW ENCRYPT RULES 语法用于查询指定逻辑库中的数据加密规则。
语法 语法 铁路图 ShowEncryptRule::= &amp;#39;SHOW&amp;#39; &amp;#39;ENCRYPT&amp;#39; (&amp;#39;RULES&amp;#39; | &amp;#39;TABLE&amp;#39; &amp;#39;RULE&amp;#39; ruleName) (&amp;#39;FROM&amp;#39; databaseName)? ruleName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 table 逻辑表名 logic_column 逻辑列名 cipher_column 密文列名 assisted_query_column 辅助查询列名 like_query_column 模糊查询列名 encryptor_type 加密算法类型 encryptor_props 加密算法参数 assisted_query_type 辅助查询算法类型 assisted_query_props 辅助查询算法参数 like_query_type 模糊查询算法类型 like_query_props 模糊查询算法参数 示例 查询指定逻辑库中的数据加密规则 SHOW ENCRYPT RULES FROM encrypt_db; mysql&amp;gt; SHOW ENCRYPT RULES FROM encrypt_db; +-----------+--------------+---------------+-----------------------+-------------------+----------------+-------------------------+---------------------+----------------------+-----------------+------------------+ | table | logic_column | cipher_column | assisted_query_column | like_query_column | encryptor_type | encryptor_props | assisted_query_type | assisted_query_props | like_query_type | like_query_props | +-----------+--------------+---------------+-----------------------+-------------------+----------------+-------------------------+---------------------+----------------------+-----------------+------------------+ | t_user | pwd | pwd_cipher | | | AES | aes-key-value=123456abc | | | | | | t_encrypt | pwd | pwd_cipher | | | AES | aes-key-value=123456abc | | | | | +-----------+--------------+---------------+--------------+-----------------------+-------------------+----------------+-------------------------+---------------------+----------------------+-----------------+------------------+ 2 rows in set (0.</description>
</item>
<item>
<title>SHOW MASK RULES</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/mask/show-mask-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/mask/show-mask-rule/</guid>
<description>描述 SHOW MASK RULES 语法用于查询指定逻辑库中的数据脱敏规则。
语法 语法 铁路图 ShowMaskRule::= &amp;#39;SHOW&amp;#39; &amp;#39;MASK&amp;#39; (&amp;#39;RULES&amp;#39; | &amp;#39;RULE&amp;#39; ruleName) (&amp;#39;FROM&amp;#39; databaseName)? ruleName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE, 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 table 表名 column 列名 algorithm_type 数据脱敏算法类型 algorithm_props 数据脱敏算法参数 示例 查询指定逻辑库中的所有数据脱敏规则 SHOW MASK RULES FROM mask_db; mysql&amp;gt; SHOW MASK RULES FROM mask_db; +---------+----------+------------------+--------------------------------+ | table | column | algorithm_type | algorithm_props | +---------+----------+------------------+--------------------------------+ | t_mask | phoneNum | MASK_FROM_X_TO_Y | to-y=2,replace-char=*,from-x=1 | | t_mask | address | MD5 | | | t_order | order_id | MD5 | | | t_user | user_id | MASK_FROM_X_TO_Y | to-y=2,replace-char=*,from-x=1 | +---------+----------+------------------+--------------------------------+ 4 rows in set (0.</description>
</item>
<item>
<title>SHOW MIGRATION RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/show-migration-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/show-migration-rule/</guid>
<description>描述 SHOW MIGRATION RULE 语法用于查询数据迁移规则。
语法 语法 铁路图 ShowMigrationRule ::= &amp;#39;SHOW&amp;#39; &amp;#39;MIGRATION&amp;#39; &amp;#39;RULE&amp;#39; 返回值说明 列 说明 read 数据读取配置 write 数据写入配置 stream_channel 数据通道 示例 查询数据迁移规则 SHOW MIGRATION RULE; mysql&amp;gt; SHOW MIGRATION RULE; +--------------------------------------------------------------+--------------------------------------+------------------------------------------------------+ | read | write | stream_channel | +--------------------------------------------------------------+--------------------------------------+------------------------------------------------------+ | {&amp;#34;workerThread&amp;#34;:40,&amp;#34;batchSize&amp;#34;:1000,&amp;#34;shardingSize&amp;#34;:10000000} | {&amp;#34;workerThread&amp;#34;:40,&amp;#34;batchSize&amp;#34;:1000} | {&amp;#34;type&amp;#34;:&amp;#34;MEMORY&amp;#34;,&amp;#34;props&amp;#34;:{&amp;#34;block-queue-size&amp;#34;:10000}} | +--------------------------------------------------------------+--------------------------------------+------------------------------------------------------+ 1 row in set (0.</description>
</item>
<item>
<title>SHOW READWRITE_SPLITTING RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/readwrite-splitting/show-readwrite-splitting-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/readwrite-splitting/show-readwrite-splitting-rule/</guid>
<description>描述 SHOW READWRITE_SPLITTING RULE 语法用于查询指定逻辑库中的指定读写分离规则。
语法 语法 铁路图 ShowReadWriteSplittingRule::= &amp;#39;SHOW&amp;#39; &amp;#39;READWRITE_SPLITTING&amp;#39; (&amp;#39;RULE&amp;#39; ruleName | &amp;#39;RULES&amp;#39;) (&amp;#39;FROM&amp;#39; databaseName)? ruleName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 name 读写分离规则名称 write_data_source_name 写数据源名称 read_data_source_names 读数据源名称列表 transactional_read_query_strategy 事务内读请求路由策略 load_balancer_type 负载均衡算法类型 load_balancer_props 负载均衡算法参数 示例 查询指定逻辑库中的读写分离规则 SHOW READWRITE_SPLITTING RULES FROM readwrite_splitting_db; mysql&amp;gt; SHOW READWRITE_SPLITTING RULES FROM readwrite_splitting_db; +------------+-------------------------+-------------------------+-----------------------------------+--------------------+---------------------+ | name | write_storage_unit_name | read_storage_unit_names | transactional_read_query_strategy | load_balancer_type | load_balancer_props | +------------+-------------------------+-------------------------+-----------------------------------+--------------------+---------------------+ | ms_group_0 | write_ds | read_ds_0,read_ds_1 | DYNAMIC | random | | +------------+-------------------------+-------------------------+-----------------------------------+--------------------+---------------------+ 1 row in set (0.</description>
</item>
<item>
<title>SHOW SHADOW RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow/show-shadow-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow/show-shadow-rule/</guid>
<description>描述 SHOW SHADOW RULE 语法用于查询指定逻辑库中的影子规则。
语法 语法 铁路图 ShowEncryptRule::= &amp;#39;SHOW&amp;#39; &amp;#39;SHADOW&amp;#39; (&amp;#39;RULES&amp;#39; | &amp;#39;RULE&amp;#39; shadowRuleName) (&amp;#39;FROM&amp;#39; databaseName)? shadowRuleName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 rule_name 规则名称 source_name 数据源名称 shadow_name 影子数据源名称 shadow_table 影子表 示例 查询指定逻辑库中的指定影子规则 SHOW SHADOW RULE shadow_rule FROM shadow_db; mysql&amp;gt; SHOW SHADOW RULE shadow_rule FROM shadow_db; +-------------+-------------+-------------+----------------------+ | rule_name | source_name | shadow_name | shadow_table | +-------------+-------------+-------------+----------------------+ | shadow_rule | ds_0 | ds_1 | t_order_item,t_order | +-------------+-------------+-------------+----------------------+ 1 row in set (0.</description>
</item>
<item>
<title>SHOW SHARDING TABLE RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-table-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-table-rule/</guid>
<description>描述 SHOW SHARDING TABLE RULE 语法用于查询指定逻辑库中的分片规则。
语法 语法 铁路图 ShowShardingTableRule ::= &amp;#39;SHOW&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;TABLE&amp;#39; (&amp;#39;RULE&amp;#39; tableName | &amp;#39;RULES&amp;#39;) (&amp;#39;FROM&amp;#39; databaseName)? tableName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 table 逻辑表名 actual_data_nodes 实际的数据节点 actual_data_sources 实际的数据源(通过 RDL 创建的规则时显示) database_strategy_type 数据库分片策略类型 database_sharding_column 数据库分片键 database_sharding_algorithm_type 数据库分片算法类型 database_sharding_algorithm_props 数据库分片算法参数 table_strategy_type 表分片策略类型 table_sharding_column 表分片键 table_sharding_algorithm_type 表分片算法类型 table_sharding_algorithm_props 表分片算法参数 key_generate_column 分布式主键生成列 key_generator_type 分布式主键生成器类型 key_generator_props 分布式主键生成器参数 示例 查询指定逻辑库的分片规则 SHOW SHARDING TABLE RULES FROM sharding_db; +--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+ | table | actual_data_nodes | actual_data_sources | database_strategy_type | database_sharding_column | database_sharding_algorithm_type | database_sharding_algorithm_props | table_strategy_type | table_sharding_column | table_sharding_algorithm_type | table_sharding_algorithm_props | key_generate_column | key_generator_type | key_generator_props | +--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+ | t_order | | ds_0,ds_1 | | | | | mod | order_id | mod | sharding-count=4 | | | | | t_order_item | | ds_0,ds_1 | | | | | mod | order_id | mod | sharding-count=4 | | | | +--------------+-------------------+---------------------+------------------------+--------------------------+----------------------------------+-----------------------------------+---------------------+-----------------------+-------------------------------+--------------------------------+---------------------+--------------------+---------------------+ 2 rows in set (0.</description>
</item>
<item>
<title>SHOW SINGLE TABLE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/single-table/show-single-table/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/single-table/show-single-table/</guid>
<description>描述 SHOW SINGLE TABLE 语法用于查询指定逻辑库中的单表。
语法 Grammar Railroad diagram ShowSingleTable::= &amp;#39;SHOW&amp;#39; &amp;#39;SINGLE&amp;#39; (&amp;#39;TABLES&amp;#39; (&amp;#39;LIKE&amp;#39; likeLiteral)?|&amp;#39;TABLE&amp;#39; tableName) (&amp;#39;FROM&amp;#39; databaseName)? tableName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 table_name 单表名称 resource_name 单表所在的数据源名称 示例 查询指定逻辑库中的指定单表 SHOW SINGLE TABLE t_user FROM sharding_db; mysql&amp;gt; SHOW SINGLE TABLE t_user FROM sharding_db; +------------+---------------+ | table_name | resource_name | +------------+---------------+ | t_user | ds_0 | +------------+---------------+ 1 row in set (0.</description>
</item>
<item>
<title>SHOW STORAGE UNITS</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/storage-unit-query/show-storage-units/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/storage-unit-query/show-storage-units/</guid>
<description>描述 SHOW STORAGE UNITS 语法用于查询指定逻辑库已经注册的存储单元。
语法 语法 铁路图 ShowStorageUnit ::= &amp;#39;SHOW&amp;#39; &amp;#39;STORAGE&amp;#39; &amp;#39;UNITS&amp;#39; (&amp;#39;WHERE&amp;#39; &amp;#39;USAGE_COUNT&amp;#39; &amp;#39;=&amp;#39; usageCount)? (&amp;#39;FROM&amp;#39; databaseName)? usageCount ::= int databaseName ::= identifier 特别说明 未指定 databaseName 时,默认是当前使用的 DATABASE; 如未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 name 存储单元名称 type 存储单元类型 host 存储单元地址 port 存储单元端口 db 数据库名称 attribute 存储单元参数 示例 查询指定逻辑库中未被使用的存储单元 SHOW STORAGE UNITS WHERE USAGE_COUNT = 0 FROM sharding_db; mysql&amp;gt; SHOW STORAGE UNITS WHERE USAGE_COUNT = 0 FROM sharding_db; +------+-------+-----------+------+------+---------------------------------+---------------------------+---------------------------+---------------+---------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | name | type | host | port | db | connection_timeout_milliseconds | idle_timeout_milliseconds | max_lifetime_milliseconds | max_pool_size | min_pool_size | read_only | other_attributes | +------+-------+-----------+------+------+---------------------------------+---------------------------+---------------------------+---------------+---------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ds_1 | MySQL | 127.</description>
</item>
<item>
<title>SQL 解析测试</title>
<link>https://shardingsphere.apache.org/document/current/cn/test-manual/module-test/parser-test/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/test-manual/module-test/parser-test/</guid>
<description>数据准备 SQL 解析无需真实的测试环境,开发者只需定义好待测试的 SQL,以及解析后的断言数据即可:
SQL数据 在集成测试的部分提到过 sql-case-id,其对应的 SQL,可以在不同模块共享。开发者只需要在 shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/${SQL-TYPE}/*.xml 添加待测试的 SQL 即可。
断言数据 断言的解析数据保存在 shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/${SQL-TYPE}/*.xml 在 xml 文件中,可以针对表名,token,SQL 条件等进行断言,例如如下的配置:
&amp;lt;parser-result-sets&amp;gt; &amp;lt;parser-result sql-case-id=&amp;#34;insert_with_multiple_values&amp;#34;&amp;gt; &amp;lt;tables&amp;gt; &amp;lt;table name=&amp;#34;t_order&amp;#34; /&amp;gt; &amp;lt;/tables&amp;gt; &amp;lt;tokens&amp;gt; &amp;lt;table-token start-index=&amp;#34;12&amp;#34; table-name=&amp;#34;t_order&amp;#34; length=&amp;#34;7&amp;#34; /&amp;gt; &amp;lt;/tokens&amp;gt; &amp;lt;sharding-conditions&amp;gt; &amp;lt;and-condition&amp;gt; &amp;lt;condition column-name=&amp;#34;order_id&amp;#34; table-name=&amp;#34;t_order&amp;#34; operator=&amp;#34;EQUAL&amp;#34;&amp;gt; &amp;lt;value literal=&amp;#34;1&amp;#34; type=&amp;#34;int&amp;#34; /&amp;gt; &amp;lt;/condition&amp;gt; &amp;lt;condition column-name=&amp;#34;user_id&amp;#34; table-name=&amp;#34;t_order&amp;#34; operator=&amp;#34;EQUAL&amp;#34;&amp;gt; &amp;lt;value literal=&amp;#34;1&amp;#34; type=&amp;#34;int&amp;#34; /&amp;gt; &amp;lt;/condition&amp;gt; &amp;lt;/and-condition&amp;gt; &amp;lt;and-condition&amp;gt; &amp;lt;condition column-name=&amp;#34;order_id&amp;#34; table-name=&amp;#34;t_order&amp;#34; operator=&amp;#34;EQUAL&amp;#34;&amp;gt; &amp;lt;value literal=&amp;#34;2&amp;#34; type=&amp;#34;int&amp;#34; /&amp;gt; &amp;lt;/condition&amp;gt; &amp;lt;condition column-name=&amp;#34;user_id&amp;#34; table-name=&amp;#34;t_order&amp;#34; operator=&amp;#34;EQUAL&amp;#34;&amp;gt; &amp;lt;value literal=&amp;#34;2&amp;#34; type=&amp;#34;int&amp;#34; /&amp;gt; &amp;lt;/condition&amp;gt; &amp;lt;/and-condition&amp;gt; &amp;lt;/sharding-conditions&amp;gt; &amp;lt;/parser-result&amp;gt; &amp;lt;/parser-result-sets&amp;gt; 设置好上面两类数据,开发者就可以通过 shardingsphere-sql-parser/shardingsphere-sql-parser-test 下对应的测试引擎启动 SQL 解析的测试了。</description>
</item>
<item>
<title>SQL 错误码</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/error-code/sql-error-code/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/error-code/sql-error-code/</guid>
<description>SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,在 SQL 执行错误时返回给客户端。
目前内容为草稿,错误码仍可能调整。
内核异常 元数据 SQL State Vendor Code 错误信息 42000 10000 There is no storage unit in database `%s`. 08000 10001 The URL `%s` is not recognized, please refer to the pattern `%s`. 42000 10002 Can not support 3-tier structure for actual data node `%s` with JDBC `%s`. HY004 10003 Invalid format for actual data node `%s`.</description>
</item>
<item>
<title>Sysbench ShardingSphere Proxy 空 Rules 性能测试</title>
<link>https://shardingsphere.apache.org/document/current/cn/test-manual/performance-test/sysbench-proxy-norules-test/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/test-manual/performance-test/sysbench-proxy-norules-test/</guid>
<description>测试目的 对 ShardingSphere-Proxy 及 MySQL 进行性能对比
sysbench 直接压测 MySQL 性能 sysbench 压测 ShardingSphere-Proxy(底层透传 MySQL) 基于以上两组实验,得到使用 ShardingSphere-Proxy 对于 MySQL 的损耗。
测试环境搭建 服务器信息 DB 相关配置:推荐内存大于压测的数据量,使得数据均在内存热块中,其余可自行调整; ShardingSphere-Proxy 相关配置:推荐使用高性能多核 CPU,其余可自行调整; 压测涉及服务器均关闭 swap 分区。 数据库 [mysqld] innodb_buffer_pool_size=${MORE_THAN_DATA_SIZE} innodb-log-file-size=3000000000 innodb-log-files-in-group=5 innodb-flush-log-at-trx-commit=0 innodb-change-buffer-max-size=40 back_log=900 innodb_max_dirty_pages_pct=75 innodb_open_files=20480 innodb_buffer_pool_instances=8 innodb_page_cleaners=8 innodb_purge_threads=2 innodb_read_io_threads=8 innodb_write_io_threads=8 table_open_cache=102400 log_timestamps=system thread_cache_size=16384 transaction_isolation=READ-COMMITTED # 可参考进行适当调优,旨在放大底层 DB 性能,不让实验受制于 DB 性能瓶颈。 压测工具 可通过 sysbench 官网自行获取
ShardingSphere-Proxy bin/start.sh -Xmx16g -Xms16g -Xmn8g # 调整 JVM 相关参数 config.</description>
</item>
<item>
<title>XA 事务</title>
<link>https://shardingsphere.apache.org/document/current/cn/reference/transaction/2pc-xa-transaction/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/reference/transaction/2pc-xa-transaction/</guid>
<description>XAShardingSphereTransactionManager 为 Apache ShardingSphere 的分布式事务的 XA 实现类。 它主要负责对多数据源进行管理和适配,并且将相应事务的开启、提交和回滚操作委托给具体的 XA 事务管理器。
开启全局事务 收到接入端的 set autoCommit=0 时,XAShardingSphereTransactionManager 将调用具体的 XA 事务管理器开启 XA 全局事务,以 XID 的形式进行标记。
执行真实分片SQL XAShardingSphereTransactionManager 将数据库连接所对应的 XAResource 注册到当前 XA 事务中之后,事务管理器会在此阶段发送 XAResource.start 命令至数据库。 数据库在收到 XAResource.end 命令之前的所有 SQL 操作,会被标记为 XA 事务。
例如:
XAResource1.start ## Enlist阶段执行 statement.execute(&amp;quot;sql1&amp;quot;); ## 模拟执行一个分片SQL1 statement.execute(&amp;quot;sql2&amp;quot;); ## 模拟执行一个分片SQL2 XAResource1.end ## 提交阶段执行 示例中的 sql1 和 sql2 将会被标记为 XA 事务。
提交或回滚事务 XAShardingSphereTransactionManager 在接收到接入端的提交命令后,会委托实际的 XA 事务管理进行提交动作, 事务管理器将收集到的当前线程中所有注册的 XAResource,并发送 XAResource.end 指令,用以标记此 XA 事务边界。 接着会依次发送 prepare 指令,收集所有参与 XAResource 投票。 若所有 XAResource 的反馈结果均为正确,则调用 commit 指令进行最终提交; 若有任意 XAResource 的反馈结果不正确,则调用 rollback 指令进行回滚。 在事务管理器发出提交指令后,任何 XAResource 产生的异常都会通过恢复日志进行重试,以保证提交阶段的操作原子性,和数据强一致性。</description>
</item>
<item>
<title>使用 Java API</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/transaction/java-api/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/transaction/java-api/</guid>
<description>背景信息 使用 ShardingSphere-JDBC 时,可以通过 API 的方式使用 XA 和 BASE 模式的事务。
前提条件 引入 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-jdbc-core&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${shardingsphere.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; &amp;lt;!-- 使用 XA 事务时,需要引入此模块 --&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.apache.shardingsphere&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;shardingsphere-transaction-xa-core&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${shardingsphere.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; &amp;lt;!-- 使用 XA 的 Narayana 模式时,需要引入此模块 --&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.apache.shardingsphere&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;shardingsphere-transaction-xa-narayana&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${project.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; &amp;lt;!-- 使用 BASE 事务时,需要引入此模块 --&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.apache.shardingsphere&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;shardingsphere-transaction-base-seata-at&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${shardingsphere.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; 操作步骤 使用事务执行业务逻辑
配置示例 // 使用 ShardingSphereDataSource 获取连接,执行事务操作 try (Connection connection = dataSource.getConnection()) { connection.setAutoCommit(false); PreparedStatement preparedStatement = connection.prepareStatement(&amp;#34;INSERT INTO t_order (user_id, status) VALUES (?</description>
</item>
<item>
<title>使用二进制发布包</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/startup/bin/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/startup/bin/</guid>
<description>背景信息 本节主要介绍如何通过二进制发布包启动 ShardingSphere-Proxy。
前提条件 使用二进制发布包启动 Proxy,需要环境具备 Java JRE 8 或更高版本。
操作步骤 获取 ShardingSphere-Proxy 二进制发布包 在下载页面获取。
配置 conf/server.yaml ShardingSphere-Proxy 运行模式在 server.yaml 中配置,配置格式与 ShardingSphere-JDBC 一致,请参考模式配置。
其他配置项请参考:
权限配置 属性配置 配置 conf/config-*.yaml 修改 conf 目录下以 config- 前缀开头的文件,如:conf/config-sharding.yaml 文件,进行分片规则、读写分离规则配置。配置方式请参考配置手册。config-*.yaml 文件的 * 部分可以任意命名。 ShardingSphere-Proxy 支持配置多个逻辑数据源,每个以 config- 前缀命名的 YAML 配置文件,即为一个逻辑数据源。
(可选)引入数据库驱动 如果后端连接 PostgreSQL 或 openGauss 数据库,不需要引入额外依赖。
如果后端连接 MySQL 数据库,请下载 mysql-connector-java-5.1.49.jar 或者 mysql-connector-java-8.0.11.jar,并将其放入 ext-lib 目录。
(可选)引入集群模式所需依赖 ShardingSphere-Proxy 默认集成 ZooKeeper Curator 客户端,集群模式使用 ZooKeeper 无须引入其他依赖。</description>
</item>
<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/props/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/props/</guid>
<description>背景信息 Apache ShardingSphere 提供属性配置的方式配置系统级配置。
参数解释 名称 数据类型 说明 默认值 sql-show (?) boolean 是否在日志中打印 SQL
打印 SQL 可以帮助开发者快速定位系统问题。日志内容包含:逻辑 SQL,真实 SQL 和 SQL 解析结果。
如果开启配置,日志将使用 Topic ShardingSphere-SQL,日志级别是 INFO false sql-simple (?) boolean 是否在日志中打印简单风格的 SQL false kernel-executor-size (?) int 用于设置任务处理线程池的大小
每个 ShardingSphereDataSource 使用一个独立的线程池,同一个 JVM 的不同数据源不共享线程池 infinite max-connections-size-per-query (?) int 一次查询请求在每个数据库实例中所能使用的最大连接数 1 check-table-metadata-enabled (?) boolean 在程序启动和更新时,是否检查分片元数据的结构一致性 false 操作步骤 属性配置直接配置在 ShardingSphere-JDBC 所使用的配置文件中,格式如下:</description>
</item>
<item>
<title>强制路由</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/readwrite-splitting/hint/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/readwrite-splitting/hint/</guid>
<description>背景信息 Apache ShardingSphere 使用 ThreadLocal 管理主库路由标记进行强制路由。 可以通过编程的方式向 HintManager 中添加主库路由标记,该值仅在当前线程内生效。
Hint 在读写分离场景下,主要用于强制在主库进行某些数据操作。
操作步骤 调用 HintManager.getInstance() 获取 HintManager 实例; 调用 HintManager.setWriteRouteOnly() 方法设置主库路由标记; 执行 SQL 语句完成路由和执行; 调用 HintManager.close() 清理 ThreadLocal 中的内容。 配置示例 使用 Hint 强制主库路由 获取 HintManager 与基于 Hint 的数据分片相同。
设置主库路由 使用 hintManager.setWriteRouteOnly 设置主库路由。
清除分片键值 与基于 Hint 的数据分片相同。
完整代码示例 String sql = &amp;#34;SELECT * FROM t_order&amp;#34;; try (HintManager hintManager = HintManager.getInstance(); Connection conn = dataSource.getConnection(); PreparedStatement preparedStatement = conn.prepareStatement(sql)) { hintManager.setWriteRouteOnly(); try (ResultSet rs = preparedStatement.</description>
</item>
<item>
<title>强制路由</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/sharding/hint/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/sharding/hint/</guid>
<description>背景信息 Apache ShardingSphere 使用 ThreadLocal 管理分片键值进行强制路由。 可以通过编程的方式向 HintManager 中添加分片值,该分片值仅在当前线程内生效。
Hint 的主要使用场景:
分片字段不存在 SQL 和数据库表结构中,而存在于外部业务逻辑。 强制在指定数据库进行某些数据操作。 操作步骤 调用 HintManager.getInstance() 获取 HintManager 实例; 调用 HintManager.addDatabaseShardingValue,HintManager.addTableShardingValue 方法设置分片键值; 执行 SQL 语句完成路由和执行; 调用 HintManager.close 清理 ThreadLocal 中的内容。 配置示例 规则配置 Hint 分片算法需要用户实现 org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm 接口。 Apache ShardingSphere 在进行路由时,将会从 HintManager 中获取分片值进行路由操作。
参考配置如下:
rules: - !SHARDING tables: t_order: actualDataNodes: demo_ds_${0..1}.t_order_${0..1} databaseStrategy: hint: algorithmClassName: xxx.xxx.xxx.HintXXXAlgorithm tableStrategy: hint: algorithmClassName: xxx.xxx.xxx.HintXXXAlgorithm defaultTableStrategy: none: defaultKeyGenerateStrategy: type: SNOWFLAKE column: order_id props: sql-show: true 获取 HintManager HintManager hintManager = HintManager.</description>
</item>
<item>
<title>数据分片</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/sharding/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/sharding/</guid>
<description>背景信息 数据分片 Java API 规则配置允许用户直接通过编写 Java 代码的方式,完成 ShardingSphereDataSource 对象的创建,Java API 的配置方式非常灵活,不需要依赖额外的 jar 包就能够集成各种类型的业务系统。
参数解释 配置入口 类名称:org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration
可配置属性:
名称 数据类型 说明 默认值 tables (+) Collection&amp;lt;ShardingTableRuleConfiguration&amp;gt; 分片表规则列表 - autoTables (+) Collection&amp;lt;ShardingAutoTableRuleConfiguration&amp;gt; 自动分片表规则列表 - bindingTableGroups (*) Collection&amp;lt;String&amp;gt; 绑定表规则列表 无 broadcastTables (*) Collection&amp;lt;String&amp;gt; 广播表规则列表 无 defaultDatabaseShardingStrategy (?) ShardingStrategyConfiguration 默认分库策略 不分片 defaultTableShardingStrategy (?) ShardingStrategyConfiguration 默认分表策略 不分片 defaultKeyGenerateStrategy (?</description>
</item>
<item>
<title>数据分片</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding/</guid>
<description>背景信息 数据分片 YAML 配置方式具有非凡的可读性,通过 YAML 格式,能够快速地理解分片规则之间的依赖关系,ShardingSphere 会根据 YAML 配置,自动完成 ShardingSphereDataSource 对象的创建,减少用户不必要的编码工作。
参数解释 rules: - !SHARDING tables: # 数据分片规则配置 &amp;lt;logic_table_name&amp;gt; (+): # 逻辑表名称 actualDataNodes (?): # 由数据源名 + 表名组成(参考 Inline 语法规则) databaseStrategy (?): # 分库策略,缺省表示使用默认分库策略,以下的分片策略只能选其一 standard: # 用于单分片键的标准分片场景 shardingColumn: # 分片列名称 shardingAlgorithmName: # 分片算法名称 complex: # 用于多分片键的复合分片场景 shardingColumns: # 分片列名称,多个列以逗号分隔 shardingAlgorithmName: # 分片算法名称 hint: # Hint 分片策略 shardingAlgorithmName: # 分片算法名称 none: # 不分片 tableStrategy: # 分表策略,同分库策略 keyGenerateStrategy: # 分布式序列策略 column: # 自增列名称,缺省表示不使用自增主键生成器 keyGeneratorName: # 分布式序列算法名称 auditStrategy: # 分片审计策略 auditorNames: # 分片审计算法名称 - &amp;lt;auditor_name&amp;gt; - &amp;lt;auditor_name&amp;gt; allowHintDisable: true # 是否禁用分片审计hint autoTables: # 自动分片表规则配置 t_order_auto: # 逻辑表名称 actualDataSources (?</description>
</item>
<item>
<title>数据分片</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/usage/sharding-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/usage/sharding-rule/</guid>
<description>存储单元操作 REGISTER STORAGE UNIT ds_0 ( HOST=&amp;#34;127.0.0.1&amp;#34;, PORT=3306, DB=&amp;#34;ds_1&amp;#34;, USER=&amp;#34;root&amp;#34;, PASSWORD=&amp;#34;root&amp;#34; ),ds_1 ( HOST=&amp;#34;127.0.0.1&amp;#34;, PORT=3306, DB=&amp;#34;ds_2&amp;#34;, USER=&amp;#34;root&amp;#34;, PASSWORD=&amp;#34;root&amp;#34; ); 规则操作 创建分片规则 CREATE SHARDING TABLE RULE t_order( STORAGE_UNITS(ds_0,ds_1), SHARDING_COLUMN=order_id, TYPE(NAME=&amp;#34;hash_mod&amp;#34;,PROPERTIES(&amp;#34;sharding-count&amp;#34;=&amp;#34;4&amp;#34;)), KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=&amp;#34;snowflake&amp;#34;)) ); 创建切分表 CREATE TABLE `t_order` ( `order_id` int NOT NULL, `user_id` int NOT NULL, `status` varchar(45) DEFAULT NULL, PRIMARY KEY (`order_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 删除切分表 DROP TABLE t_order; 删除分片规则 DROP SHARDING TABLE RULE t_order; 移除数据源 UNREGISTER STORAGE UNIT ds_0, ds_1; 删除分布式数据库 DROP DATABASE foo_db; </description>
</item>
<item>
<title>核心概念</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/db-gateway/concept/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/db-gateway/concept/</guid>
<description>SQL 方言 SQL 方言也就是数据库方言,指的是某些数据库产品除了支持 SQL 之外,还会有一些自己独有的语法,这就称之为方言,不同的数据库产品,也可能会有不同的 SQL 方言。</description>
</item>
<item>
<title>核心概念</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/encrypt/concept/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/encrypt/concept/</guid>
<description>逻辑列 用于计算加解密列的逻辑名称,是 SQL 中列的逻辑标识。 逻辑列包含密文列(必须)、查询辅助列(可选)、模糊查询辅助列(可选)、和明文列(可选)。
密文列 加密后的数据列。
查询辅助列 用于查询的辅助列。 对于一些安全级别更高的非幂等加密算法,提供不可逆的幂等列用于查询。
模糊查询列 用于模糊查询的列。</description>
</item>
<item>
<title>核心概念</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/management/concept/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/management/concept/</guid>
<description>熔断 阻断 Apache ShardingSphere 和数据库的连接。 当某个 Apache ShardingSphere 节点超过负载后,停止该节点对数据库的访问,使数据库能够保证足够的资源为其他节点提供服务。
限流 面对超负荷的请求开启限流,以保护部分请求可以得以高质量的响应。</description>
</item>
<item>
<title>核心概念</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/mask/concept/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/mask/concept/</guid>
<description>逻辑列 用于计算脱敏列的逻辑名称,它是 SQL 中列的逻辑标识。</description>
</item>
<item>
<title>核心概念</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/migration/concept/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/migration/concept/</guid>
<description>节点 运行计算层或存储层组件进程的实例,可以是物理机、虚拟机、容器等。
集群 为了提供特定服务而集合在一起的多个节点。
源端 原始数据所在的存储集群。
目标端 原始数据将要迁移的目标存储集群。
数据迁移作业 把数据从某一个存储集群复制到另一个存储集群的完整流程。
存量数据 在数据迁移作业开始前,数据节点中已有的数据。
增量数据 在数据迁移作业执行过程中,业务系统所产生的新数据。</description>
</item>
<item>
<title>核心概念</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/observability/concept/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/observability/concept/</guid>
<description>Agent 基于字节码增强和插件化设计,以提供 Tracing 和 Metrics 埋点,以及日志输出功能。 需要开启 Agent 的插件功能后,才能将监控指标数据输出至第三方 APM 中展示。
APM APM 是应用性能监控的缩写。 着眼于分布式系统的性能诊断,其主要功能包括调用链展示,应用拓扑分析等。
Tracing 链路跟踪,通过探针收集调用链数据,并发送到第三方 APM 系统。
Metrics 系统统计指标,通过探针收集,供第三方应用展示。
Logging 日志,通过 Agent 能够方便的扩展日志内容,为分析系统运行状态提供更多信息。</description>
</item>
<item>
<title>核心概念</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/readwrite-splitting/concept/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/readwrite-splitting/concept/</guid>
<description>主库 添加、更新以及删除数据操作所使用的数据库,目前仅支持单主库。
从库 查询数据操作所使用的数据库,可支持多从库。
主从同步 将主库的数据异步的同步到从库的操作。 由于主从同步的异步性,从库与主库的数据会短时间内不一致。
负载均衡策略 通过负载均衡策略将查询请求疏导至不同从库。</description>
</item>
<item>
<title>核心概念</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/shadow/concept/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/shadow/concept/</guid>
<description>生产库 生产环境使用的数据库。
影子库 压测数据隔离的影子数据库,与生产数据库应当使用相同的配置。
影子算法 影子算法和业务实现紧密相关,目前提供 2 种类型影子算法。
基于列的影子算法 通过识别 SQL 中的数据,匹配路由至影子库的场景。 适用于由压测数据名单驱动的压测场景。
基于 Hint 的影子算法 通过识别 SQL 中的注释,匹配路由至影子库的场景。 适用于由上游系统透传标识驱动的压测场景。
</description>
</item>
<item>
<title>核心概念</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/sharding/concept/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/sharding/concept/</guid>
<description>表 表是透明化数据分片的关键概念。 Apache ShardingSphere 通过提供多样化的表类型,适配不同场景下的数据分片需求。
逻辑表 相同结构的水平拆分数据库(表)的逻辑名称,是 SQL 中表的逻辑标识。 例:订单数据根据主键尾数拆分为 10 张表,分别是 t_order_0 到 t_order_9,他们的逻辑表名为 t_order。
真实表 在水平拆分的数据库中真实存在的物理表。 即上个示例中的 t_order_0 到 t_order_9。
绑定表 指分片规则一致的一组分片表。 使用绑定表进行多表关联查询时,必须使用分片键进行关联,否则会出现笛卡尔积关联或跨库关联,从而影响查询效率。 例如:t_order 表和 t_order_item 表,均按照 order_id 分片,并且使用 order_id 进行关联,则此两张表互为绑定表关系。 绑定表之间的多表关联查询不会出现笛卡尔积关联,关联查询效率将大大提升。 举例说明,如果 SQL 为:
SELECT i.* FROM t_order o JOIN t_order_item i ON o.order_id=i.order_id WHERE o.order_id in (10, 11); 在不配置绑定表关系时,假设分片键 order_id 将数值 10 路由至第 0 片,将数值 11 路由至第 1 片,那么路由后的 SQL 应该为 4 条,它们呈现为笛卡尔积:
SELECT i.* FROM t_order_0 o JOIN t_order_item_0 i ON o.</description>
</item>
<item>
<title>核心概念</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/transaction/concept/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/transaction/concept/</guid>
<description>XA 协议 XA 协议最早的分布式事务模型是由 X/Open 国际联盟提出的 X/Open Distributed Transaction Processing (DTP) 模型,简称 XA 协议。</description>
</item>
<item>
<title>模式配置</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/mode/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/mode/</guid>
<description>背景信息 通过 Java API 方式构建运行模式。
参数解释 类名称:org.apache.shardingsphere.infra.config.mode.ModeConfiguration
可配置属性:
名称 数据类型 说明 默认值 type String 运行模式类型
可选配置:Standalone、Cluster Standalone repository PersistRepositoryConfiguration 持久化仓库配置
Standalone 类型使用 StandalonePersistRepositoryConfiguration
Cluster 类型使用 ClusterPersistRepositoryConfiguration Standalone 持久化配置 类名称:org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepositoryConfiguration
可配置属性:
名称 数据类型 说明 type String 持久化仓库类型 props Properties 持久化仓库所需属性 Cluster 持久化配置 类名称:org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration
可配置属性:
名称 数据类型 说明 type String 持久化仓库类型 namespace String 注册中心命名空间 server-lists String 注册中心连接地址 props Properties 持久化仓库所需属性 注意事项 生产环境建议使用集群模式部署。 集群模式部署推荐使用 ZooKeeper 注册中心。 ZooKeeper 存在配置信息时,则以 ZooKeeper 中的配置为准。 操作步骤 引入Maven 依赖。 &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.</description>
</item>
<item>
<title>模式配置</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/mode/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/mode/</guid>
<description>参数解释 mode (?): # 不配置则默认单机模式 type: # 运行模式类型。可选配置:Standalone、Cluster repository (?): # 持久化仓库配置 单机模式 mode: type: Standalone repository: type: # 持久化仓库类型 props: # 持久化仓库所需属性 foo_key: foo_value bar_key: bar_value 集群模式 (推荐) mode: type: Cluster repository: type: # 持久化仓库类型 props: # 持久化仓库所需属性 namespace: # 注册中心命名空间 server-lists: # 注册中心连接地址 foo_key: foo_value bar_key: bar_value 注意事项 生产环境建议使用集群模式部署。 集群模式部署推荐使用 ZooKeeper 注册中心。 ZooKeeper 存在配置信息时,则以 ZooKeeper 中的配置为准。 配置示例 单机模式 mode: type: Standalone repository: type: JDBC 集群模式 (推荐) mode: type: Cluster repository: type: ZooKeeper props: namespace: governance server-lists: localhost:2181 retryIntervalMilliseconds: 500 timeToLiveSeconds: 60 使用持久化仓库需要额外引入对应的 Maven 依赖,推荐使用:</description>
</item>
<item>
<title>添加 Bitronix 依赖</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/startup/dependencies-download/add_bitronix_dependency/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/startup/dependencies-download/add_bitronix_dependency/</guid>
<description>添加 Bitronix 依赖包 添加 Bitronix 依赖需要下载以下 jar 文件并将其添加 ext-lib 目录下。
jar 文件下载地址 btm-2.1.3.jar shardingsphere-transaction-xa-bitronix.jar 请根据 proxy 版本下载对应 shardingsphere-transaction-xa-bitronix.jar 文件。</description>
</item>
<item>
<title>解析引擎</title>
<link>https://shardingsphere.apache.org/document/current/cn/reference/sharding/parse/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/reference/sharding/parse/</guid>
<description>相对于其他编程语言,SQL 是比较简单的。 不过,它依然是一门完善的编程语言,因此对 SQL 的语法进行解析,与解析其他编程语言(如:Java 语言、C 语言、Go 语言等)并无本质区别。
抽象语法树 解析过程分为词法解析和语法解析。 词法解析器用于将 SQL 拆解为不可再分的原子符号,称为 Token。并根据不同数据库方言所提供的字典,将其归类为关键字,表达式,字面量和操作符。 再使用语法解析器将词法解析器的输出转换为抽象语法树。
例如,以下 SQL:
SELECT id, name FROM t_user WHERE status = &amp;#39;ACTIVE&amp;#39; AND age &amp;gt; 18 解析之后的为抽象语法树见下图。
为了便于理解,抽象语法树中的关键字的 Token 用绿色表示,变量的 Token 用红色表示,灰色表示需要进一步拆分。
最后,通过 visitor 对抽象语法树遍历构造域模型,通过域模型(SQLStatement)去提炼分片所需的上下文,并标记有可能需要改写的位置。 供分片使用的解析上下文包含查询选择项(Select Items)、表信息(Table)、分片条件(Sharding Condition)、自增主键信息(Auto increment Primary Key)、排序信息(Order By)、分组信息(Group By)以及分页信息(Limit、Rownum、Top)。 SQL 的一次解析过程是不可逆的,一个个 Token 按 SQL 原本的顺序依次进行解析,性能很高。 考虑到各种数据库 SQL 方言的异同,在解析模块提供了各类数据库的 SQL 方言字典。
SQL 解析引擎 历史 SQL 解析作为分库分表类产品的核心,其性能和兼容性是最重要的衡量指标。 ShardingSphere 的 SQL 解析器经历了 3 代产品的更新迭代。
第一代 SQL 解析器为了追求性能与快速实现,在 1.</description>
</item>
<item>
<title>认证和授权</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/yaml-config/authority/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/yaml-config/authority/</guid>
<description>背景信息 在 ShardingSphere-Proxy 中,通过 authority 来配置用户的认证和授权信息。
得益于 ShardingSphere 的可插拔架构,Proxy 提供了两种级别的权限提供者,分别是:
ALL_PERMITTED:每个用户都拥有所有权限,无需专门授权; DATABASE_PERMITTED:为用户授予指定逻辑库的权限,通过 user-database-mappings 进行定义。 在配置 authority 时,管理员可根据需要选择使用哪一种权限提供者。
参数解释 authority: users: - user: # 用于登录计算节点的用户名和授权主机的组合,格式:&amp;lt;username&amp;gt;@&amp;lt;hostname&amp;gt;,hostname 为 % 或空字符串表示不限制授权主机 password: # 用户密码 authenticationMethodName: # 可选项,用于为用户指定密码认证方式 authenticators: # 可选项,默认不需要配置,Proxy 根据前端协议类型自动选择 authenticatorName: type: # 密码认证类型 defaultAuthenticator: # 可选项,指定一个 authenticatorName 作为默认的密码认证方式 privilege: type: # 权限提供者类型,缺省值为 ALL_PERMITTED 配置示例 极简配置 authority: users: - user: root@% password: root - user: sharding password: sharding 说明:
定义了两个用户:root@% 和 sharding; 未定义 authenticators 和 authenticationMethodName,Proxy 将根据前端协议自动选择; 未指定 privilege type,采用默认的 ALL_PERMITTED。 认证配置 自定义认证配置能够满足用户在一些特定场景下的需求。 以 openGauss 作为前端协议类型为例,其默认的认证算法为 scram-sha-256。 如果用户 sharding 需要用旧版本的 psql 客户端(不支持 scram-sha-256)连接 Proxy,则管理员可能允许 sharding 使用 md5 方式进行密码认证。 配置方式如下:</description>
</item>
<item>
<title>运行模式</title>
<link>https://shardingsphere.apache.org/document/current/cn/dev-manual/mode/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/mode/</guid>
<description>StandalonePersistRepository 全限定类名 org.apache.shardingsphere.mode.repository.standalone.StandalonePersistRepository
定义 单机模式配置信息持久化定义
已知实现 配置标识 详细说明 全限定类名 JDBC 基于 JDBC 的持久化 org.apache.shardingsphere.mode.repository.standalone.jdbc.JDBCRepository ClusterPersistRepository 全限定类名 org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository
定义 集群模式配置信息持久化定义
已知实现 配置标识 详细说明 全限定类名 ZooKeeper 基于 ZooKeeper 的持久化 org.apache.shardingsphere.mode.repository.cluster.zookeeper.ZookeeperRepository etcd 基于 Etcd 的持久化 org.apache.shardingsphere.mode.repository.cluster.etcd.EtcdRepository Nacos 基于 Nacos 的持久化 org.apache.shardingsphere.mode.repository.cluster.nacos.NacosRepository Consul 基于 Consul 的持久化 org.apache.shardingsphere.mode.repository.cluster.consul.ConsulRepository GovernanceWatcher 全限定类名 org.</description>
</item>
<item>
<title>运行部署</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/migration/build/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/migration/build/</guid>
<description>背景信息 对于使用单数据库运行的系统来说,如何安全简单地将数据迁移至水平分片的数据库上,一直以来都是一个迫切的需求。
前提条件 Proxy 采用纯 JAVA 开发,JDK 建议 1.8 或以上版本。 数据迁移使用集群模式,目前支持 ZooKeeper 作为注册中心。 操作步骤 获取 ShardingSphere-Proxy。详情请参见 proxy 启动手册。
修改配置文件 conf/server.yaml,详情请参见模式配置。
目前 mode 必须是 Cluster,需要提前启动对应的注册中心。
配置示例:
mode: type: Cluster repository: type: ZooKeeper props: namespace: governance_ds server-lists: localhost:2181 retryIntervalMilliseconds: 500 timeToLiveSeconds: 60 maxRetries: 3 operationTimeoutMilliseconds: 500 引入 JDBC 驱动。 proxy 已包含 PostgreSQL JDBC 驱动。
如果后端连接以下数据库,请下载相应 JDBC 驱动 jar 包,并将其放入 ${shardingsphere-proxy}/ext-lib 目录。
数据库 JDBC 驱动 参考 MySQL mysql-connector-java-5.</description>
</item>
<item>
<title>ALTER ENCRYPT RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt/alter-encrypt-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt/alter-encrypt-rule/</guid>
<description>说明 ALTER ENCRYPT RULE 语法用于修改加密规则。
语法 语法 铁路图 AlterEncryptRule ::= &amp;#39;ALTER&amp;#39; &amp;#39;ENCRYPT&amp;#39; &amp;#39;RULE&amp;#39; encryptDefinition (&amp;#39;,&amp;#39; encryptDefinition)* encryptDefinition ::= ruleName &amp;#39;(&amp;#39; &amp;#39;COLUMNS&amp;#39; &amp;#39;(&amp;#39; columnDefinition (&amp;#39;,&amp;#39; columnDefinition)* &amp;#39;)&amp;#39; &amp;#39;)&amp;#39; columnDefinition ::= &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; columnName &amp;#39;,&amp;#39; &amp;#39;CIPHER&amp;#39; &amp;#39;=&amp;#39; cipherColumnName (&amp;#39;,&amp;#39; &amp;#39;ASSISTED_QUERY&amp;#39; &amp;#39;=&amp;#39; assistedQueryColumnName)? (&amp;#39;,&amp;#39; &amp;#39;LIKE_QUERY&amp;#39; &amp;#39;=&amp;#39; likeQueryColumnName)? &amp;#39;,&amp;#39; encryptAlgorithmDefinition (&amp;#39;,&amp;#39; assistedQueryAlgorithmDefinition)? (&amp;#39;,&amp;#39; likeQueryAlgorithmDefinition)? &amp;#39;)&amp;#39; encryptAlgorithmDefinition ::= &amp;#39;ENCRYPT_ALGORITHM&amp;#39; &amp;#39;(&amp;#39; &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; encryptAlgorithmType (&amp;#39;,&amp;#39; propertiesDefinition)? &amp;#39;)&amp;#39; assistedQueryAlgorithmDefinition ::= &amp;#39;ASSISTED_QUERY_ALGORITHM&amp;#39; &amp;#39;(&amp;#39; &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; encryptAlgorithmType (&amp;#39;,&amp;#39; propertiesDefinition)?</description>
</item>
<item>
<title>ALTER MASK RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/mask/alter-mask-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/mask/alter-mask-rule/</guid>
<description>描述 ALTER MASK RULE 语法用于修改数据脱敏规则。
语法定义 语法 铁路图 CreateEncryptRule ::= &amp;#39;ALTER&amp;#39; &amp;#39;MASK&amp;#39; &amp;#39;RULE&amp;#39; maskRuleDefinition (&amp;#39;,&amp;#39; maskRuleDefinition)* maskRuleDefinition ::= ruleName &amp;#39;(&amp;#39; &amp;#39;COLUMNS&amp;#39; &amp;#39;(&amp;#39; columnDefinition (&amp;#39;,&amp;#39; columnDefinition)* &amp;#39;)&amp;#39; &amp;#39;)&amp;#39; columnDefinition ::= &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; columnName &amp;#39;,&amp;#39; maskAlgorithmDefinition &amp;#39;)&amp;#39; maskAlgorithmDefinition ::= &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; maskAlgorithmType (&amp;#39;,&amp;#39; propertiesDefinition)? &amp;#39;)&amp;#39; propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; ruleName ::= identifier columnName ::= identifier maskAlgorithmType ::= literal key ::= string value ::= literal 补充说明 maskAlgorithmType 指定数据脱敏算法类型,请参考 数据脱敏算法。 示例 修改数据脱敏规则 ALTER MASK RULE t_mask ( COLUMNS( (NAME=phone_number,TYPE(NAME=&amp;#39;MASK_FROM_X_TO_Y&amp;#39;, PROPERTIES(&amp;#34;from-x&amp;#34;=1, &amp;#34;to-y&amp;#34;=2, &amp;#34;replace-char&amp;#34;=&amp;#34;*&amp;#34;))), (NAME=address,TYPE(NAME=&amp;#39;MD5&amp;#39;)) )); 保留字 ALTER、MASK、RULE、COLUMNS、NAME、TYPE</description>
</item>
<item>
<title>ALTER MIGRATION RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/alter-migration-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/alter-migration-rule/</guid>
<description>描述 ALTER MIGRATION RULE 语法用于修改数据迁移规则。
语法 语法 铁路图 AlterMigrationRule ::= &amp;#39;ALTER&amp;#39; &amp;#39;MIGRATION&amp;#39; &amp;#39;RULE&amp;#39; (&amp;#39;(&amp;#39; (readConfiguration &amp;#39;,&amp;#39;)? (writeConfiguration &amp;#39;,&amp;#39;)? (dataChannel)? &amp;#39;)&amp;#39;)? readConfiguration ::= &amp;#39;READ&amp;#39; &amp;#39;(&amp;#39; (&amp;#39;WORKER_THREAD&amp;#39; &amp;#39;=&amp;#39; workerThreadPoolSize &amp;#39;,&amp;#39;)? (&amp;#39;BATCH_SIZE&amp;#39; &amp;#39;=&amp;#39; batchSize &amp;#39;,&amp;#39;)? (&amp;#39;SHARDING_SIZE&amp;#39; &amp;#39;=&amp;#39; shardingSize &amp;#39;,&amp;#39;)? (rateLimiter)? &amp;#39;)&amp;#39; writeConfiguration ::= &amp;#39;WRITE&amp;#39; &amp;#39;(&amp;#39; (&amp;#39;WORKER_THREAD&amp;#39; &amp;#39;=&amp;#39; workerThreadPoolSize &amp;#39;,&amp;#39;)? (&amp;#39;BATCH_SIZE&amp;#39; &amp;#39;=&amp;#39; batchSize &amp;#39;,&amp;#39;)? (&amp;#39;SHARDING_SIZE&amp;#39; &amp;#39;=&amp;#39; shardingSize &amp;#39;,&amp;#39;)? (rateLimiter)? &amp;#39;)&amp;#39; dataChannel ::= &amp;#39;STREAM_CHANNEL&amp;#39; &amp;#39;(&amp;#39; &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; algorithmName &amp;#39;,&amp;#39; propertiesDefinition &amp;#39;)&amp;#39; &amp;#39;)&amp;#39; workerThreadPoolSize ::= int batchSize ::= int shardingSize ::= int rateLimiter ::= &amp;#39;RATE_LIMITER&amp;#39; &amp;#39;(&amp;#39; &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; algorithmName &amp;#39;,&amp;#39; propertiesDefinition &amp;#39;)&amp;#39; &amp;#39;)&amp;#39; algorithmName ::= string propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; key ::= string value ::= literal 补充说明 ALTER MIGRATION RULE 可以只修改数据迁移规则中一项配置并不影响其他配置 示例 修改数据迁移规则 ALTER MIGRATION RULE ( READ( WORKER_THREAD=40, BATCH_SIZE=1000, SHARDING_SIZE=10000000, RATE_LIMITER (TYPE(NAME=&amp;#39;QPS&amp;#39;,PROPERTIES(&amp;#39;qps&amp;#39;=&amp;#39;500&amp;#39;)))), WRITE( WORKER_THREAD=40, BATCH_SIZE=1000, RATE_LIMITER (TYPE(NAME=&amp;#39;TPS&amp;#39;,PROPERTIES(&amp;#39;tps&amp;#39;=&amp;#39;2000&amp;#39;)))), STREAM_CHANNEL ( TYPE(NAME=&amp;#39;MEMORY&amp;#39;,PROPERTIES(&amp;#39;block-queue-size&amp;#39;=&amp;#39;10000&amp;#39;))) ); 仅修改数据迁移规则中的数据读取配置 ALTER MIGRATION RULE ( READ(WORKER_THREAD=40, BATCH_SIZE=1000, SHARDING_SIZE=10000000, RATE_LIMITER (TYPE(NAME=&amp;#39;QPS&amp;#39;,PROPERTIES(&amp;#39;qps&amp;#39;=&amp;#39;500&amp;#39;)))) ); 仅修改数据迁移规则中的数据写入配置 ALTER MIGRATION RULE ( WRITE(WORKER_THREAD=40, BATCH_SIZE=1000, SHARDING_SIZE=10000000, RATE_LIMITER (TYPE(NAME=&amp;#39;QPS&amp;#39;,PROPERTIES(&amp;#39;qps&amp;#39;=&amp;#39;500&amp;#39;)))) ); 仅修改数据迁移规则中的数据通道配置 ALTER MIGRATION RULE ( STREAM_CHANNEL ( TYPE( NAME=&amp;#39;MEMORY&amp;#39;, PROPERTIES(&amp;#39;block-queue-size&amp;#39;=&amp;#39;10000&amp;#39;))) ); 保留字 ALTER、MIGRATION、RULE、READ、WRITE、WORKER_THREAD、BATCH_SIZE、SHARDING_SIZE、STREAM_CHANNEL、TYPE、NAME、PROPERTIES</description>
</item>
<item>
<title>ALTER READWRITE_SPLITTING RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting/alter-readwrite-splitting-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting/alter-readwrite-splitting-rule/</guid>
<description>描述 ALTER READWRITE_SPLITTING RULE 语法用于修改读写分离规则。
语法定义 语法 铁路图 AlterReadwriteSplittingRule ::= &amp;#39;ALTER&amp;#39; &amp;#39;READWRITE_SPLITTING&amp;#39; &amp;#39;RULE&amp;#39; readwriteSplittingDefinition (&amp;#39;,&amp;#39; readwriteSplittingDefinition)* readwriteSplittingDefinition ::= ruleName &amp;#39;(&amp;#39; dataSourceDefinition (&amp;#39;,&amp;#39; transactionalReadQueryStrategyDefinition)? (&amp;#39;,&amp;#39; loadBalancerDefinition)? &amp;#39;)&amp;#39; dataSourceDefinition ::= &amp;#39;WRITE_STORAGE_UNIT&amp;#39; &amp;#39;=&amp;#39; writeStorageUnitName &amp;#39;,&amp;#39; &amp;#39;READ_STORAGE_UNITS&amp;#39; &amp;#39;(&amp;#39; storageUnitName (&amp;#39;,&amp;#39; storageUnitName)* &amp;#39;)&amp;#39; transactionalReadQueryStrategyDefinition ::= &amp;#39;TRANSACTIONAL_READ_QUERY_STRATEGY&amp;#39; &amp;#39;=&amp;#39; transactionalReadQueryStrategyType loadBalancerDefinition ::= &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; loadBalancerType (&amp;#39;,&amp;#39; propertiesDefinition)? &amp;#39;)&amp;#39; ruleName ::= identifier writeStorageUnitName ::= identifier storageUnitName ::= identifier transactionalReadQueryStrategyType ::= string loadBalancerType ::= string propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; key ::= string value ::= literal 补充说明 transactionalReadQueryStrategyType 指定事务内读请求路由策略,请参考YAML 配置; loadBalancerType 指定负载均衡算法类型,请参考负载均衡算法。 示例 修改读写分离规则 ALTER READWRITE_SPLITTING RULE ms_group_0 ( WRITE_STORAGE_UNIT=write_ds, READ_STORAGE_UNITS(read_ds_0,read_ds_1), TYPE(NAME=&amp;#34;random&amp;#34;) ); 保留字 ALTER、READWRITE_SPLITTING、RULE、WRITE_STORAGE_UNIT、READ_STORAGE_UNITS 、TYPE、NAME、PROPERTIES、TRUE、FALSE</description>
</item>
<item>
<title>ALTER SHADOW RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/alter-shadow-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/alter-shadow-rule/</guid>
<description>描述 ALTER SHADOW RULE 语法用于修改影子库压测规则。
语法定义 语法 铁路图 AlterShadowRule ::= &amp;#39;ALTER&amp;#39; &amp;#39;SHADOW&amp;#39; &amp;#39;RULE&amp;#39; shadowRuleDefinition (&amp;#39;,&amp;#39; shadowRuleDefinition)* shadowRuleDefinition ::= ruleName &amp;#39;(&amp;#39; storageUnitMapping shadowTableRule (&amp;#39;,&amp;#39; shadowTableRule)* &amp;#39;)&amp;#39; storageUnitMapping ::= &amp;#39;SOURCE&amp;#39; &amp;#39;=&amp;#39; storageUnitName &amp;#39;,&amp;#39; &amp;#39;SHADOW&amp;#39; &amp;#39;=&amp;#39; storageUnitName shadowTableRule ::= tableName &amp;#39;(&amp;#39; shadowAlgorithm &amp;#39;)&amp;#39; shadowAlgorithm ::= &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; shadowAlgorithmType &amp;#39;,&amp;#39; propertiesDefinition &amp;#39;)&amp;#39; ruleName ::= identifier storageUnitName ::= identifier tableName ::= identifier algorithmName ::= identifier shadowAlgorithmType ::= string propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; key ::= string value ::= literal 补充说明 storageUnitMapping 指定源数据库和影子库的映射关系,需使用 RDL 管理的 STORAGE UNIT ,请参考 存储单元; shadowAlgorithm 可同时作用于多个 shadowTableRule; algorithmName 会根据 ruleName、tableName 和 shadowAlgorithmType 自动生成; shadowAlgorithmType 目前支持 VALUE_MATCH、REGEX_MATCH 和 SQL_HINT。 示例 修改影子库压测规则 ALTER SHADOW RULE shadow_rule( SOURCE=demo_ds, SHADOW=demo_ds_shadow, t_order(TYPE(NAME=&amp;#34;SQL_HINT&amp;#34;)), t_order_item(TYPE(NAME=&amp;#34;VALUE_MATCH&amp;#34;, PROPERTIES(&amp;#34;operation&amp;#34;=&amp;#34;insert&amp;#34;,&amp;#34;column&amp;#34;=&amp;#34;user_id&amp;#34;, &amp;#34;value&amp;#34;=&amp;#39;1&amp;#39;))) ); 保留字 ALTER、SHADOW、RULE、SOURCE、SHADOW、TYPE、NAME、PROPERTIES</description>
</item>
<item>
<title>ALTER SHARDING TABLE RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/alter-sharding-table-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/alter-sharding-table-rule/</guid>
<description>描述 ALTER SHARDING TABLE RULE 语法用于修改当前所选逻辑库的分片规则。
语法定义 语法 铁路图 AlterShardingTableRule ::= &amp;#39;ALTER&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;RULE&amp;#39; (tableDefinition | autoTableDefinition) (&amp;#39;,&amp;#39; (tableDefinition | autoTableDefinition))* tableDefinition ::= tableName &amp;#39;(&amp;#39; &amp;#39;DATANODES&amp;#39; &amp;#39;(&amp;#39; dataNode (&amp;#39;,&amp;#39; dataNode)* &amp;#39;)&amp;#39; (&amp;#39;,&amp;#39; &amp;#39;DATABASE_STRATEGY&amp;#39; &amp;#39;(&amp;#39; strategyDefinition &amp;#39;)&amp;#39;)? (&amp;#39;,&amp;#39; &amp;#39;TABLE_STRATEGY&amp;#39; &amp;#39;(&amp;#39; strategyDefinition &amp;#39;)&amp;#39;)? (&amp;#39;,&amp;#39; &amp;#39;KEY_GENERATE_STRATEGY&amp;#39; &amp;#39;(&amp;#39; keyGenerateStrategyDefinition &amp;#39;)&amp;#39;)? (&amp;#39;,&amp;#39; &amp;#39;AUDIT_STRATEGY&amp;#39; &amp;#39;(&amp;#39; auditStrategyDefinition &amp;#39;)&amp;#39;)? &amp;#39;)&amp;#39; autoTableDefinition ::= tableName &amp;#39;(&amp;#39; &amp;#39;STORAGE_UNITS&amp;#39; &amp;#39;(&amp;#39; storageUnitName (&amp;#39;,&amp;#39; storageUnitName)* &amp;#39;)&amp;#39; &amp;#39;,&amp;#39; &amp;#39;SHARDING_COLUMN&amp;#39; &amp;#39;=&amp;#39; columnName &amp;#39;,&amp;#39; algorithmDefinition (&amp;#39;,&amp;#39; &amp;#39;KEY_GENERATE_STRATEGY&amp;#39; &amp;#39;(&amp;#39; keyGenerateStrategyDefinition &amp;#39;)&amp;#39;)?</description>
</item>
<item>
<title>ALTER STORAGE UNIT</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/storage-unit-definition/alter-storage-unit/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/storage-unit-definition/alter-storage-unit/</guid>
<description>描述 ALTER STORAGE UNIT 语法用于修改当前所选逻辑库(DATABASE)的存储单元。
语法 语法 铁路图 AlterStorageUnit ::= &amp;#39;ALTER&amp;#39; &amp;#39;STORAGE&amp;#39; &amp;#39;UNIT&amp;#39; storageUnitDefinition (&amp;#39;,&amp;#39; storageUnitDefinition)* storageUnitDefinition ::= storageUnitName &amp;#39;(&amp;#39; (&amp;#39;HOST&amp;#39; &amp;#39;=&amp;#39; hostName &amp;#39;,&amp;#39; &amp;#39;PORT&amp;#39; &amp;#39;=&amp;#39; port &amp;#39;,&amp;#39; &amp;#39;DB&amp;#39; &amp;#39;=&amp;#39; dbName | &amp;#39;URL&amp;#39; &amp;#39;=&amp;#39; url) &amp;#39;,&amp;#39; &amp;#39;USER&amp;#39; &amp;#39;=&amp;#39; user (&amp;#39;,&amp;#39; &amp;#39;PASSWORD&amp;#39; &amp;#39;=&amp;#39; password)? (&amp;#39;,&amp;#39; propertiesDefinition)?&amp;#39;)&amp;#39; storageUnitName ::= identifier hostname ::= string port ::= int dbName ::= string url ::= string user ::= string password ::= string propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; key ::= string value ::= literal 补充说明 修改存储单元前请确认已经在 Proxy 中创建逻辑数据库,并执行 use 命令成功选择一个逻辑数据库; ALTER STORAGE UNIT不允许改变该存储单元关联的真实数据源; ALTER STORAGE UNIT会发生连接池的切换,这个操作可能对进行中的业务造成影响,请谨慎使用; 确认添加的存储单元是可以正常连接的, 否则将不能添加成功; storageUnitName 区分大小写; storageUnitName 在当前逻辑库中需要唯一; storageUnitName 命名只允许使用字母、数字以及 _ ,且必须以字母开头; poolProperty 用于自定义连接池参数,key 必须和连接池参数名一致。 示例 使用标准模式修改存储单元 ALTER STORAGE UNIT ds_0 ( HOST=&amp;#34;127.</description>
</item>
<item>
<title>BenchmarkSQL ShardingSphere Proxy 分片性能测试</title>
<link>https://shardingsphere.apache.org/document/current/cn/test-manual/performance-test/benchmarksql-proxy-sharding-test/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/test-manual/performance-test/benchmarksql-proxy-sharding-test/</guid>
<description>测试目的 使用 BenchmarkSQL 工具测试 ShardingSphere Proxy 的分片性能。
测试方法 ShardingSphere Proxy 支持通过 BenchmarkSQL 5.0 进行 TPC-C 测试。 除本文说明的内容外,BenchmarkSQL 操作步骤按照原文档 HOW-TO-RUN.txt 即可。
测试工具微调 与单机数据库压测不同,分布式数据库解决方案难免在功能支持上有所取舍。使用 BenchmarkSQL 压测 ShardingSphere Proxy 建议进行如下调整。
移除外键与 extraHistID 修改 BenchmarkSQL 目录下 run/runDatabaseBuild.sh,文件第 17 行。
修改前:
AFTER_LOAD=&amp;#34;indexCreates foreignKeys extraHistID buildFinish&amp;#34; 修改后:
AFTER_LOAD=&amp;#34;indexCreates buildFinish&amp;#34; 压测环境或参数建议 注意:本节中提到的任何参数都不是绝对值,都需要根据实际测试结果进行调整或取舍。
建议使用 Java 17 运行 ShardingSphere 编译 ShardingSphere 可以使用 Java 8。
使用 Java 17 可以在默认情况下尽量提升 ShardingSphere 的性能。
ShardingSphere 数据分片建议 对 BenchmarkSQL 的数据分片,可以考虑以各个表中的 warehouse id 作为分片键。
其中一个表 bmsql_item 没有 warehouse id,数据量固定 10 万行:</description>
</item>
<item>
<title>COUNT ENCRYPT RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/encrypt/count-encrypt-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/encrypt/count-encrypt-rule/</guid>
<description>描述 COUNT ENCRYPT RULE 语法用于查询指定逻辑库中的加密规则数量。
语法 语法 铁路图 CountEncryptRule::= &amp;#39;COUNT&amp;#39; &amp;#39;ENCRYPT&amp;#39; &amp;#39;RULE&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 rule_name 规则类型 database 规则所属逻辑库 count 规则数量 示例 查询指定逻辑库中的加密规则数量 COUNT ENCRYPT RULE FROM encrypt_db; mysql&amp;gt; COUNT ENCRYPT RULE FROM encrypt_db; +-----------+---------------+-------+ | rule_name | database | count | +-----------+---------------+-------+ | encrypt | encrypt_db | 2 | +-----------+---------------+-------+ 1 row in set (0.</description>
</item>
<item>
<title>COUNT MASK RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/mask/count-mask-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/mask/count-mask-rule/</guid>
<description>描述 COUNT MASK RULE 语法用于查询指定逻辑库中的数据脱敏规则数量。
语法 语法 铁路图 CountMaskRule::= &amp;#39;COUNT&amp;#39; &amp;#39;MASK&amp;#39; &amp;#39;RULE&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE,如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 rule_name 规则类型 database 规则所属逻辑库 count 规则数量 示例 查询指定逻辑库中的数据脱敏规则数量 COUNT MASK RULE FROM mask_db; mysql&amp;gt; COUNT MASK RULE FROM mask_db; +-----------+----------+-------+ | rule_name | database | count | +-----------+----------+-------+ | mask | mask_db | 3 | +-----------+----------+-------+ 1 row in set (0.</description>
</item>
<item>
<title>COUNT READWRITE_SPLITTING RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/readwrite-splitting/count-readwrite-splitting-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/readwrite-splitting/count-readwrite-splitting-rule/</guid>
<description>描述 COUNT READWRITE_SPLITTING RULE 语法用于查询指定逻辑库中的读写分离规则数量。
语法 语法 铁路图 CountReadwriteSplittingRule::= &amp;#39;COUNT&amp;#39; &amp;#39;READWRITE_SPLITTING&amp;#39; &amp;#39;RULE&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 rule_name 规则类型 database 规则所属逻辑库 count 规则数量 示例 查询指定逻辑库中的读写分离规则数量 COUNT READWRITE_SPLITTING RULE FROM readwrite_splitting_db; mysql&amp;gt; COUNT READWRITE_SPLITTING RULE FROM readwrite_splitting_db; +---------------------+---------------------------+-------+ | rule_name | database | count | +---------------------+---------------------------+-------+ | readwrite_splitting | readwrite_splitting_db | 1 | +---------------------+---------------------------+-------+ 1 row in set (0.</description>
</item>
<item>
<title>FORMAT SQL</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rul/format-sql/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rul/format-sql/</guid>
<description>描述 FORMAT SQL 语法用于解析并输出格式化后的 SQL 语句。
语法 语法 铁路图 FormatSql ::= &amp;#39;FORMAT&amp;#39; sqlStatement 返回值说明 列 说明 formatted_result 格式化后的SQL语句 示例 解析并输出格式化后的 SQL 语句 FORMAT SELECT * FROM t_order; mysql&amp;gt; FORMAT SELECT * FROM t_order; +-------------------------+ | formatted_result | +-------------------------+ | SELECT * FROM t_order; | +-------------------------+ 1 row in set (0.00 sec) 保留字 FORMAT</description>
</item>
<item>
<title>Seata 柔性事务</title>
<link>https://shardingsphere.apache.org/document/current/cn/reference/transaction/base-transaction-seata/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/reference/transaction/base-transaction-seata/</guid>
<description>整合 Seata AT 事务时,需要将 TM,RM 和 TC 的模型融入 Apache ShardingSphere 的分布式事务生态中。 在数据库资源上,Seata 通过对接 DataSource 接口,让 JDBC 操作可以同 TC 进行远程通信。 同样,Apache ShardingSphere 也是面向 DataSource 接口,对用户配置的数据源进行聚合。 因此,将 DataSource 封装为 基于Seata 的 DataSource 后,就可以将 Seata AT 事务融入到 Apache ShardingSphere的分片生态中。
引擎初始化 包含 Seata 柔性事务的应用启动时,用户配置的数据源会根据 seata.conf 的配置,适配为 Seata 事务所需的 DataSourceProxy,并且注册至 RM 中。
开启全局事务 TM 控制全局事务的边界,TM 通过向 TC 发送 Begin 指令,获取全局事务 ID,所有分支事务通过此全局事务 ID,参与到全局事务中;全局事务 ID 的上下文存放在当前线程变量中。
执行真实分片SQL 处于 Seata 全局事务中的分片 SQL 通过 RM 生成 undo 快照,并且发送 participate 指令至 TC,加入到全局事务中。 由于 Apache ShardingSphere 的分片物理 SQL 采取多线程方式执行,因此整合 Seata AT 事务时,需要在主线程和子线程间进行全局事务 ID 的上下文传递。</description>
</item>
<item>
<title>ShardingSphere-Proxy</title>
<link>https://shardingsphere.apache.org/document/current/cn/quick-start/shardingsphere-proxy-quick-start/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/quick-start/shardingsphere-proxy-quick-start/</guid>
<description>应用场景 ShardingSphere-Proxy 的定位为透明化的数据库代理,理论上支持任何使用 MySQL、PostgreSQL、openGauss 协议的客户端操作数据,对异构语言、运维场景更友好。
使用限制 ShardingSphere-Proxy 对系统库/表(如 information_schema、pg_catalog)支持有限,通过部分图形化数据库客户端连接 Proxy 时,可能客户端或 Proxy 会有错误提示。可以使用命令行客户端(mysql、psql、gsql 等)连接 Proxy 验证功能。
前提条件 使用 Docker 启动 ShardingSphere-Proxy 无须额外依赖。 使用二进制分发包启动 Proxy,需要环境具备 Java JRE 8 或更高版本。
操作步骤 获取 ShardingSphere-Proxy 目前 ShardingSphere-Proxy 可以通过以下方式:
二进制发布包 Docker Helm 规则配置 编辑 %SHARDINGSPHERE_PROXY_HOME%/conf/server.yaml。
编辑 %SHARDINGSPHERE_PROXY_HOME%/conf/config-xxx.yaml。
%SHARDINGSPHERE_PROXY_HOME% 为 Proxy 解压后的路径,例:/opt/shardingsphere-proxy-bin/
详情请参见 配置手册。
引入依赖 如果后端连接 PostgreSQL 或 openGauss 数据库,不需要引入额外依赖。
如果后端连接 MySQL 数据库,请下载 mysql-connector-java-5.1.49.jar 或者 mysql-connector-java-8.0.11.jar,并将其放入 %SHARDINGSPHERE_PROXY_HOME%/ext-lib 目录。</description>
</item>
<item>
<title>SHOW DEFAULT SINGLE TABLE STORAGE UNIT</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/single-table/show-deafult-single-table-storage-unit/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/single-table/show-deafult-single-table-storage-unit/</guid>
<description>描述 SHOW DEFAULT SINGLE TABLE STORAGE UNIT 语法用于查询指定逻辑库中的存储单元信息。
语法 Grammar Railroad diagram ShowDefaultSingleTableStorageUnit::= &amp;#39;SHOW&amp;#39; &amp;#39;DEFAULT&amp;#39; &amp;#39;SINGLE&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;STORAGE&amp;#39; &amp;#39;UNIT&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 storage_unit_name 存储单元名称 示例 查询当前逻辑库中的存储单元信息 SHOW DEFAULT SINGLE TABLE STORAGE UNIT sql&amp;gt; SHOW DEFAULT SINGLE TABLE STORAGE UNIT; +-------------------+ | storage_unit_name | +-------------------+ | ds_0 | +-------------------+ 1 row in set (0.</description>
</item>
<item>
<title>SHOW SHADOW TABLE RULES</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow/show-shadow-table-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow/show-shadow-table-rule/</guid>
<description>描述 SHOW SHADOW TABLE RULES 语法用于查询指定逻辑库中的影子表规则。
语法 语法 铁路图 ShowEncryptRule::= &amp;#39;SHOW&amp;#39; &amp;#39;SHADOW&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;RULES&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 shadow_table 影子表 shadow_algorithm_name 影子算法名称 示例 查询指定逻辑库中的影子表规则 SHOW SHADOW TABLE RULES FROM shadow_db; mysql&amp;gt; SHOW SHADOW TABLE RULES FROM shadow_db; +--------------+-------------------------------------------------------+ | shadow_table | shadow_algorithm_name | +--------------+-------------------------------------------------------+ | t_order_item | shadow_rule_t_order_item_value_match | | t_order | sql_hint_algorithm,shadow_rule_t_order_regex_match | +--------------+-------------------------------------------------------+ 2 rows in set (0.</description>
</item>
<item>
<title>SHOW SHARDING ALGORITHMS</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-algorithms/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-algorithms/</guid>
<description>描述 SHOW SHARDING ALGORITHMS 语法用于查询指定逻辑库的分片算法。
语法 语法 铁路图 ShowShardingAlgorithms::= &amp;#39;SHOW&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;ALGORITHMS&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 name 分片算法名称 type 分片算法类型 props 分片算法参数 示例 查询指定逻辑库的分片算法 SHOW SHARDING ALGORITHMS FROM sharding_db; mysql&amp;gt; SHOW SHARDING ALGORITHMS FROM sharding_db; +-------------------------+--------+-----------------------------------------------------+ | name | type | props | +-------------------------+--------+-----------------------------------------------------+ | t_order_inline | INLINE | algorithm-expression=t_order_${order_id % 2} | | t_order_item_inline | INLINE | algorithm-expression=t_order_item_${order_id % 2} | +-------------------------+--------+-----------------------------------------------------+ 2 rows in set (0.</description>
</item>
<item>
<title>SHOW STATUS FROM READWRITE_SPLITTING RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/circuit-breaker/show-status-from-readwrite-splitting-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/circuit-breaker/show-status-from-readwrite-splitting-rule/</guid>
<description>描述 SHOW STATUS FROM READWRITE_SPLITTING RULE 语法用于查询指定逻辑库中指定读写分离规则中读写分离存储单元状态。
语法 语法 铁路图 ShowStatusFromReadwriteSplittingRule ::= &amp;#39;SHOW&amp;#39; &amp;#39;STATUS&amp;#39; &amp;#39;FROM&amp;#39; &amp;#39;READWRITE_SPLITTING&amp;#39; (&amp;#39;RULES&amp;#39; | &amp;#39;RULE&amp;#39; groupName) (&amp;#39;FROM&amp;#39; databaseName)? groupName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 resource 存储单元名称 status 存储单元状态 示例 查询指定逻辑库中指定读写分离规则中读写分离存储单元状态 SHOW STATUS FROM READWRITE_SPLITTING RULE ms_group_0 FROM sharding_db; mysql&amp;gt; SHOW STATUS FROM READWRITE_SPLITTING RULE ms_group_0 FROM sharding_db; +----------+---------+ | resource | status | +----------+---------+ | ds_0 | enabled | | ds_1 | enabled | | ds_2 | enabled | | ds_3 | enabled | +----------+---------+ 4 rows in set (0.</description>
</item>
<item>
<title>SHOW TRANSACTION RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/show-transaction-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/show-transaction-rule/</guid>
<description>描述 SHOW TRANSACTION RULE 语法用于查询事务规则配置。
语法 语法 铁路图 ShowTransactionRule ::= &amp;#39;SHOW&amp;#39; &amp;#39;TRANSACTION&amp;#39; &amp;#39;RULE&amp;#39; 返回值说明 列 说明 default_type 默认事务类型 provider_type 事务提供者类型 props 事务参数 示例 查询权限规则配置 SHOW TRANSACTION RULE; mysql&amp;gt; SHOW TRANSACTION RULE; +--------------+---------------+-------+ | default_type | provider_type | props | +--------------+---------------+-------+ | LOCAL | | | +--------------+---------------+-------+ 1 row in set (0.</description>
</item>
<item>
<title>SQL 改写测试</title>
<link>https://shardingsphere.apache.org/document/current/cn/test-manual/module-test/rewrite-test/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/test-manual/module-test/rewrite-test/</guid>
<description>目标 面向逻辑库与逻辑表书写的 SQL,并不能够直接在真实的数据库中执行,SQL 改写用于将逻辑 SQL 改写为在真实数据库中可以正确执行的 SQL。它包括正确性改写和优化改写两部分,所以 SQL 改写的测试都是基于这些改写方向进行校验的。
测试 SQL 改写测试用例位于 sharding-core/sharding-core-rewrite 下的 test 中。SQL 改写的测试主要依赖如下几个部分:
测试引擎 环境配置 验证数据 测试引擎是 SQL 改写测试的入口,跟其他引擎一样,通过 Junit 的 Parameterized 逐条读取 test\resources 目录中测试类型下对应的 xml 文件,然后按读取顺序一一进行验证。
环境配置存放在 test\resources\yaml 路径中测试类型下对应的 yaml 中。配置了 dataSources,shardingRule,encryptRule 等信息,例子如下:
dataSources: db: !!com.zaxxer.hikari.HikariDataSource driverClassName: org.h2.Driver jdbcUrl: jdbc:h2:mem:db;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL username: sa password: ## sharding 规则 rules: - !SHARDING tables: t_account: actualDataNodes: db.t_account_${0..1} tableStrategy: standard: shardingColumn: account_id shardingAlgorithmName: account_table_inline keyGenerateStrategy: column: account_id keyGeneratorName: snowflake t_account_detail: actualDataNodes: db.</description>
</item>
<item>
<title>使用 Docker</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/startup/docker/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/startup/docker/</guid>
<description>背景信息 本节主要介绍如何通过 Docker 启动 ShardingSphere-Proxy。
注意事项 使用 Docker 启动 ShardingSphere-Proxy 无须额外依赖。
操作步骤 获取 Docker 镜像 方式一(推荐):从 DockerHub 获取 docker pull apache/shardingsphere-proxy 方式二:获取 master 分支最新镜像:https://github.com/apache/shardingsphere/pkgs/container/shardingsphere-proxy
方式三:自行构建镜像
git clone https://github.com/apache/shardingsphere mvn clean install cd shardingsphere-distribution/shardingsphere-proxy-distribution mvn clean package -Prelease,docker 如果遇到以下问题,请确保 Docker daemon 进程已经运行。
I/O exception (java.io.IOException) caught when processing request to {}-&amp;gt;unix://localhost:80: Connection refused? 配置 conf/server.yaml 和 conf/config-*.yaml 可以从 Docker 容器中获取配置文件模板,拷贝到宿主机任意目录中:</description>
</item>
<item>
<title>使用手册</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/migration/usage/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/migration/usage/</guid>
<description>MySQL 使用手册 环境要求 支持的 MySQL 版本:5.1.15 ~ 8.0.x。
权限要求 源端开启 binlog MySQL 5.7 my.cnf 示例配置:
[mysqld] server-id=1 log-bin=mysql-bin binlog-format=row binlog-row-image=full max_connections=600 执行以下命令,确认是否有开启 binlog:
show variables like &#39;%log_bin%&#39;; show variables like &#39;%binlog%&#39;; 如以下显示,则说明 binlog 已开启
+-----------------------------------------+---------------------------------------+ | Variable_name | Value | +-----------------------------------------+---------------------------------------+ | log_bin | ON | | binlog_format | ROW | | binlog_row_image | FULL | +-----------------------------------------+---------------------------------------+ 赋予源端 MySQL 账号 replication 相关权限。 执行以下命令,查看该用户是否有迁移权限:
SHOW GRANTS FOR &#39;migration_user&#39;; 示例结果:</description>
</item>
<item>
<title>使用限制</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/db-gateway/limitations/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/db-gateway/limitations/</guid>
<description>Apache ShardingSphere 的 SQL 方言翻译处于实验阶段。
目前仅支持 MySQL/PostgreSQL 的方言自动翻译,工程师可以使用 MySQL 的方言和协议,访问 PostgreSQL 数据库,反之亦然。</description>
</item>
<item>
<title>使用限制</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/encrypt/limitations/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/encrypt/limitations/</guid>
<description> 需自行处理数据库中原始的存量数据; 模糊查询支持 %、_,暂不支持 escape; 加密字段无法支持查询不区分大小写功能; 加密字段无法支持比较操作,如:大于、小于、ORDER BY、BETWEEN 等; 加密字段无法支持计算操作,如:AVG、SUM 以及计算表达式; 当投影子查询中包含加密字段时,必须使用别名。 </description>
</item>
<item>
<title>使用限制</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/mask/limitations/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/mask/limitations/</guid>
<description> 脱敏列只支持字符串类型,不支持其他非字符串类型。 </description>
</item>
<item>
<title>使用限制</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/migration/limitations/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/migration/limitations/</guid>
<description>支持项 将外围数据迁移至 Apache ShardingSphere 所管理的数据库; 目标端 proxy 不配置规则或配置任意规则; 迁移单字段主键或唯一键的表,首字段类型:整型、字符型、部分二进制类型(比如 MySQL VARBINARY); 迁移复合主键或复合唯一键的表。 不支持项 不支持在当前存储节点之上做迁移,需要准备一个全新的数据库集群作为迁移目标库; 不支持目标端 proxy 使用 HINT 分片策略; 不支持目标端表结构和源端不一致; 不支持迁移过程中源端表结构变更。 </description>
</item>
<item>
<title>使用限制</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/readwrite-splitting/limitations/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/readwrite-splitting/limitations/</guid>
<description> 不处理主库和从库的数据同步 不处理主库和从库的数据同步延迟导致的数据不一致 不支持主库多写 不处理主从库间的事务一致性。主从模型中,事务中的数据读写均用主库。 </description>
</item>
<item>
<title>使用限制</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/shadow/limitations/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/shadow/limitations/</guid>
<description>基于 Hint 的影子算法 无。 基于列的影子算法 不支持 DDL;
不支持范围、分组和子查询,如:BETWEEN、GROUP BY &amp;hellip; HAVING 等。 SQL 支持列表:
INSERT SQL 是否支持 INSERT INTO table (column,&amp;hellip;) VALUES (value,&amp;hellip;) 支持 INSERT INTO table (column,&amp;hellip;) VALUES (value,&amp;hellip;),(value,&amp;hellip;),&amp;hellip; 支持 INSERT INTO table (column,&amp;hellip;) SELECT column1 from table1 where column1 = value1 不支持 SELECT/UPDATE/DELETE 条件类型 SQL 是否支持 = SELECT/UPDATE/DELETE &amp;hellip; WHERE column = value 支持 LIKE/NOT LIKE SELECT/UPDATE/DELETE &amp;hellip; WHERE column LIKE/NOT LIKE value 支持 IN/NOT IN SELECT/UPDATE/DELETE &amp;hellip; WHERE column IN/NOT IN (value1,value2,&amp;hellip;) 支持 BETWEEN SELECT/UPDATE/DELETE &amp;hellip; WHERE column BETWEEN value1 AND value2 不支持 GROUP BY &amp;hellip; HAVING&amp;hellip; SELECT/UPDATE/DELETE &amp;hellip; WHERE &amp;hellip; GROUP BY column HAVING column &amp;gt; value 不支持 子查询 SELECT/UPDATE/DELETE &amp;hellip; WHERE column = (SELECT column FROM table WHERE column = value) 不支持 </description>
</item>
<item>
<title>使用限制</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/sharding/limitation/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/sharding/limitation/</guid>
<description>兼容全部常用的路由至单数据节点的 SQL; 路由至多数据节点的 SQL 由于场景复杂,分为稳定支持、实验性支持和不支持这三种情况。
稳定支持 全面支持 DML、DDL、DCL、TCL 和常用 DAL。 支持分页、去重、排序、分组、聚合、表关联等复杂查询。 支持 PostgreSQL 和 openGauss 数据库的 schema DDL 和 DML 语句,当 SQL 中不指定 schema 时,默认访问 public schema,其他 schema 则需要在表名前显示声明,暂不支持 SEARCH_PATH 修改 schema 搜索路径。
常规查询 SELECT 主语句 SELECT select_expr [, select_expr ...] FROM table_reference [, table_reference ...] [WHERE predicates] [GROUP BY {col_name | position} [ASC | DESC], ...] [ORDER BY {col_name | position} [ASC | DESC], ...] [LIMIT {[offset,] row_count | row_count OFFSET offset}] select_expr * | [DISTINCT] COLUMN_NAME [AS] [alias] | (MAX | MIN | SUM | AVG)(COLUMN_NAME | alias) [AS] [alias] | COUNT(* | COLUMN_NAME | alias) [AS] [alias] table_reference tbl_name [AS] alias] [index_hint_list] | table_reference ([INNER] | {LEFT|RIGHT} [OUTER]) JOIN table_factor [JOIN ON conditional_expr | USING (column_list)] 子查询 子查询和外层查询同时指定分片键,且分片键的值保持一致时,由内核提供稳定支持。</description>
</item>
<item>
<title>使用限制</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/transaction/limitations/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/transaction/limitations/</guid>
<description>虽然 Apache ShardingSphere 希望能够完全兼容所有的分布式事务场景,并在性能上达到最优,但在 CAP 定理所指导下,分布式事务必然有所取舍。 Apache ShardingSphere 希望能够将分布式事务的选择权交给使用者,在不同的场景使用最适合的分布式事务解决方案。
LOCAL 事务 不支持项 不支持因网络、硬件异常导致的跨库事务。例如:同一事务中,跨两个库更新,更新完毕后、未提交之前,第一个库宕机,则只有第二个库数据提交,且无法回滚。 XA 事务 不支持项 服务宕机后,在其它机器上恢复提交/回滚中的数据; MySQL 事务块内,SQL 执行出现异常,执行 Commit,数据保持一致; 配置 XA 事务后,存储单元名称最大长度不超过45个字符。 BASE 事务 不支持项 不支持隔离级别。 </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/shardingsphere-proxy/yaml-config/props/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/yaml-config/props/</guid>
<description>背景信息 Apache ShardingSphere 提供了丰富的系统配置属性,用户可通过 server.yaml 进行配置。
参数解释 名称 数据类型 说明 默认值 动态生效 system-log-level (?) String 系统日志输出级别,支持 DEBUG、INFO、WARN 和 ERROR,默认级别是 INFO。 false 是 sql-show (?) boolean 是否在日志中打印 SQL。 打印 SQL 可以帮助开发者快速定位系统问题。日志内容包含:逻辑 SQL,真实 SQL 和 SQL 解析结果。
如果开启配置,日志将使用 Topic ShardingSphere-SQL,日志级别是 INFO。 false 是 sql-simple (?) boolean 是否在日志中打印简单风格的 SQL。 false 是 kernel-executor-size (?) int 用于设置任务处理线程池的大小。每个 ShardingSphereDataSource 使用一个独立的线程池,同一个 JVM 的不同数据源不共享线程池。 infinite 否 max-connections-size-per-query (?</description>
</item>
<item>
<title>数据源配置</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/data-source/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/data-source/</guid>
<description>背景信息 ShardingSphere-JDBC 支持所有的数据库 JDBC 驱动和连接池。
本节将介绍,通过 JAVA API 的方式配置数据源。
操作步骤 1. 引入 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-jdbc-core&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${latest.release.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; 注意:请将 ${latest.release.version} 更改为实际的版本号。
配置示例 ModeConfiguration modeConfig = // 构建运行模式 Map&amp;lt;String, DataSource&amp;gt; dataSourceMap = createDataSources(); Collection&amp;lt;RuleConfiguration&amp;gt; ruleConfigs = ... // 构建具体规则 Properties props = ... // 构建属性配置 DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(databaseName, modeConfig, dataSourceMap, ruleConfigs, props); private Map&amp;lt;String, DataSource&amp;gt; createDataSources() { Map&amp;lt;String, DataSource&amp;gt; dataSourceMap = new HashMap&amp;lt;&amp;gt;(); // 配置第 1 个数据源 HikariDataSource dataSource1 = new HikariDataSource(); dataSource1.</description>
</item>
<item>
<title>数据源配置</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/data-source/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/data-source/</guid>
<description>背景信息 ShardingSphere-JDBC 支持所有的数据库 JDBC 驱动和连接池。
示例的数据库驱动为 MySQL,连接池为 HikariCP,可以更换为其他数据库驱动和连接池。当使用 ShardingSphere-JDBC 时,JDBC 池的属性名取决于各自 JDBC 池自己的定义,并不由 ShardingSphere 硬定义,相关的处理可以参考类org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator。例如对于 Alibaba Druid 1.2.9 而言,使用 url 代替如下示例中的 jdbcUrl 是预期行为。
参数解释 dataSources: # 数据源配置,可配置多个 &amp;lt;data-source-name&amp;gt; &amp;lt;data_source_name&amp;gt;: # 数据源名称 dataSourceClassName: # 数据源完整类名 driverClassName: # 数据库驱动类名,以数据库连接池自身配置为准 jdbcUrl: # 数据库 URL 连接,以数据库连接池自身配置为准 username: # 数据库用户名,以数据库连接池自身配置为准 password: # 数据库密码,以数据库连接池自身配置为准 # ... 数据库连接池的其它属性 配置示例 dataSources: ds_1: dataSourceClassName: com.zaxxer.hikari.HikariDataSource driverClassName: com.mysql.jdbc.Driver jdbcUrl: jdbc:mysql://localhost:3306/ds_1 username: root password: ds_2: dataSourceClassName: com.zaxxer.hikari.HikariDataSource driverClassName: com.mysql.jdbc.Driver jdbcUrl: jdbc:mysql://localhost:3306/ds_2 username: root password: # 配置其他数据源 </description>
</item>
<item>
<title>服务器错误码</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/error-code/server-error-code/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/error-code/server-error-code/</guid>
<description>服务器发生错误时所提供的唯一错误码,打印在 Proxy 后端或 JDBC 启动日志中。
错误码 错误信息 SPI-00001 No implementation class load from SPI `%s` with type `%s`. DATA-SOURCE-00001 Data source unavailable. PROPS-00001 Value `%s` of `%s` cannot convert to type `%s`. PROXY-00001 Load database server info failed. SPRING-00001 Can not find JNDI data source. SPRING-SHARDING-00001 Can not support type `%s`. </description>
</item>
<item>
<title>构建 GraalVM Native Image(Alpha)</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/startup/graalvm-native-image/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/startup/graalvm-native-image/</guid>
<description>背景信息 本节主要介绍如何通过 GraalVM 的 native-image 组件构建 ShardingSphere-Proxy 的 Native Image 和对应的 Docker Image 。
注意事项 ShardingSphere Proxy 尚未准备好与 GraalVM Native Image 集成。 其在 https://github.com/apache/shardingsphere/pkgs/container/shardingsphere-proxy-native 存在每夜构建。 假设存在包含server.yaml 的 conf 文件夹为 ./custom/conf,你可通过如下的 docker-compose.yml 文件进行测试。 version: &amp;#34;3.8&amp;#34; services: apache-shardingsphere-proxy-native: image: ghcr.io/apache/shardingsphere-proxy-native:latest volumes: - ./custom/conf:/opt/shardingsphere-proxy-native/conf ports: - &amp;#34;3307:3307&amp;#34; 若你发现构建过程存在缺失的 GraalVM Reachability Metadata, 应当在 https://github.com/oracle/graalvm-reachability-metadata 打开新的 issue , 并提交包含 ShardingSphere 自身或依赖的第三方库缺失的 GraalVM Reachability Metadata 的 PR。
ShardingSphere 的 master 分支尚未准备好处理 Native Image 中的单元测试, 需要等待 Junit 5 Platform 的集成,你总是需要在构建 GraalVM Native Image 的过程中, 加上特定于 GraalVM Native Build Tools 的 -DskipNativeTests 或 -DskipTests 参数跳过 Native Image 中的单元测试。</description>
</item>
<item>
<title>添加 Narayana 依赖</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/startup/dependencies-download/add_narayana_dependency/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/startup/dependencies-download/add_narayana_dependency/</guid>
<description>添加 Narayana 依赖包 添加 Narayana 依赖需要下载以下 jar 文件并将其添加至 ext-lib 下。
jar 文件下载地址 arjuna-5.12.4.Final.jar common-5.12.4.Final.jar javax.activation-api-1.2.0.jar jaxb-api-2.3.0.jar jaxb-core-2.3.0.jar jaxb-impl-2.3.0.jar jboss-connector-api_1.7_spec-1.0.0.Final.jar jboss-logging-3.2.1.Final.jar jboss-transaction-api_1.2_spec-1.0.0.Alpha3.jar jboss-transaction-spi-7.6.0.Final.jar jta-5.12.4.Final.jar narayana-jts-integration-5.12.4.Final.jar shardingsphere-transaction-xa-narayana.jar 请根据 proxy 版本下载对应 shardingsphere-transaction-xa-narayana.jar 文件。</description>
</item>
<item>
<title>读写分离</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/readwrite-splitting/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/readwrite-splitting/</guid>
<description>背景信息 Java API 形式配置的读写分离可以方便的适用于各种场景,不依赖额外的 jar 包,用户只需要通过 java 代码构造读写分离数据源便可以使用读写分离功能。
参数解释 配置入口 类名称:org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration
可配置属性:
名称 数据类型 说明 dataSources (+) Collection&amp;lt;ReadwriteSplittingDataSourceRuleConfiguration&amp;gt; 读写数据源配置 loadBalancers (*) Map&amp;lt;String, AlgorithmConfiguration&amp;gt; 从库负载均衡算法配置 主从数据源配置 类名称:org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration
可配置属性:
名称 数据类型 说明 默认值 name String 读写分离数据源名称 - writeDataSourceName String 写库数据源名称 - readDataSourceNames List&amp;lt;String&amp;gt; 读库数据源名称 - transactionalReadQueryStrategy (?) TransactionalReadQueryStrategy 事务内读请求的路由策略,可选值:PRIMARY(路由至主库)、FIXED(同一事务内路由至固定数据源)、DYNAMIC(同一事务内路由至非固定数据源) DYNAMIC loadBalancerName (?</description>
</item>
<item>
<title>读写分离</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/readwrite-splitting/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/readwrite-splitting/</guid>
<description>背景信息 读写分离 YAML 配置方式可读性高,通过 YAML 格式,能够快速地理解读写分片规则之间的依赖关系,ShardingSphere 会根据 YAML 配置,自动完成 ShardingSphereDataSource 对象的创建,减少用户不必要的编码工作。
参数解释 读写分离 rules: - !READWRITE_SPLITTING dataSources: &amp;lt;data_source_name&amp;gt; (+): # 读写分离逻辑数据源名称 write_data_source_name: # 写库数据源名称 read_data_source_names: # 读库数据源名称,多个从数据源用逗号分隔 transactionalReadQueryStrategy (?): # 事务内读请求的路由策略,可选值:PRIMARY(路由至主库)、FIXED(同一事务内路由至固定数据源)、DYNAMIC(同一事务内路由至非固定数据源)。默认值:DYNAMIC loadBalancerName: # 负载均衡算法名称 # 负载均衡算法配置 loadBalancers: &amp;lt;load_balancer_name&amp;gt; (+): # 负载均衡算法名称 type: # 负载均衡算法类型 props: # 负载均衡算法属性配置 # ... 算法类型的详情,请参见内置负载均衡算法列表。 查询一致性路由的详情,请参见核心特性:读写分离。
操作步骤 添加读写分离数据源 设置负载均衡算法 使用读写分离数据源 配置示例 rules: - !READWRITE_SPLITTING dataSources: readwrite_ds: writeDataSourceName: write_ds readDataSourceNames: - read_ds_0 - read_ds_1 transactionalReadQueryStrategy: PRIMARY loadBalancerName: random loadBalancers: random: type: RANDOM 相关参考 核心特性:读写分离 Java API:读写分离 </description>
</item>
<item>
<title>读写分离</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/usage/readwirte-splitting-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/usage/readwirte-splitting-rule/</guid>
<description>存储单元操作 REGISTER STORAGE UNIT write_ds ( HOST=&amp;#34;127.0.0.1&amp;#34;, PORT=3306, DB=&amp;#34;ds_0&amp;#34;, USER=&amp;#34;root&amp;#34;, PASSWORD=&amp;#34;root&amp;#34; ),read_ds ( HOST=&amp;#34;127.0.0.1&amp;#34;, PORT=3307, DB=&amp;#34;ds_0&amp;#34;, USER=&amp;#34;root&amp;#34;, PASSWORD=&amp;#34;root&amp;#34; ); 规则操作 创建读写分离规则 CREATE READWRITE_SPLITTING RULE group_0 ( WRITE_STORAGE_UNIT=write_ds, READ_STORAGE_UNITS(read_ds), TYPE(NAME=&amp;#34;random&amp;#34;) ); 修改读写分离规则 ALTER READWRITE_SPLITTING RULE group_0 ( WRITE_STORAGE_UNIT=write_ds, READ_STORAGE_UNITS(read_ds), TYPE(NAME=&amp;#34;random&amp;#34;,PROPERTIES(&amp;#34;read_weight&amp;#34;=&amp;#34;2:0&amp;#34;)) ); 删除读写分离规则 DROP READWRITE_SPLITTING RULE group_0; 移除数据源 UNREGISTER STORAGE UNIT write_ds,read_ds; 删除分布式数据库 DROP DATABASE readwrite_splitting_db; </description>
</item>
<item>
<title>路由引擎</title>
<link>https://shardingsphere.apache.org/document/current/cn/reference/sharding/route/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/reference/sharding/route/</guid>
<description>根据解析上下文匹配数据库和表的分片策略,并生成路由路径。 对于携带分片键的 SQL,根据分片键的不同可以划分为单片路由(分片键的操作符是等号)、多片路由(分片键的操作符是 IN)和范围路由(分片键的操作符是 BETWEEN)。 不携带分片键的 SQL 则采用广播路由。
分片策略通常可以采用由数据库内置或由用户方配置。 数据库内置的方案较为简单,内置的分片策略大致可分为尾数取模、哈希、范围、标签、时间等。 由用户方配置的分片策略则更加灵活,可以根据使用方需求定制复合分片策略。 如果配合数据自动迁移来使用,可以做到无需用户关注分片策略,自动由数据库中间层分片和平衡数据即可,进而做到使分布式数据库具有的弹性伸缩的能力。 在 ShardingSphere 的线路规划中,弹性伸缩将于 4.x 开启。
分片路由 用于根据分片键进行路由的场景,又细分为直接路由、标准路由和笛卡尔积路由这 3 种类型。
直接路由 满足直接路由的条件相对苛刻,它需要通过 Hint(使用 HintAPI 直接指定路由至库表)方式分片,并且是只分库不分表的前提下,则可以避免 SQL 解析和之后的结果归并。 因此它的兼容性最好,可以执行包括子查询、自定义函数等复杂情况的任意 SQL。直接路由还可以用于分片键不在 SQL 中的场景。例如,设置用于数据库分片的键为 3,
hintManager.setDatabaseShardingValue(3); 假如路由算法为 value % 2,当一个逻辑库 t_order 对应 2 个真实库 t_order_0 和 t_order_1 时,路由后 SQL 将在 t_order_1 上执行。下方是使用 API 的代码样例:
String sql = &amp;#34;SELECT * FROM t_order&amp;#34;; try ( HintManager hintManager = HintManager.getInstance(); Connection conn = dataSource.getConnection(); PreparedStatement pstmt = conn.</description>
</item>
<item>
<title>配置</title>
<link>https://shardingsphere.apache.org/document/current/cn/dev-manual/configuration/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/configuration/</guid>
<description>RuleBuilder 全限定类名 org.apache.shardingsphere.infra.rule.builder.RuleBuilder
定义 用于将用户配置转化为规则对象的接口
已知实现 配置标识 详细说明 全限定类名 AuthorityRuleConfiguration 用于将权限用户配置转化为权限规则对象 org.apache.shardingsphere.authority.rule.builder.AuthorityRuleBuilder SQLParserRuleConfiguration 用于将 SQL 解析用户配置转化为 SQL 解析规则对象 org.apache.shardingsphere.parser.rule.builder.SQLParserRuleBuilder TransactionRuleConfiguration 用于将事务用户配置转化为事务规则对象 org.apache.shardingsphere.transaction.rule.builder.TransactionRuleBuilder SingleRuleConfiguration 用于将单表用户配置转化为单表规则对象 org.apache.shardingsphere.singletable.rule.builder.SingleRuleBuilder ShardingRuleConfiguration 用于将分片用户配置转化为分片规则对象 org.apache.shardingsphere.sharding.rule.builder.ShardingRuleBuilder ReadwriteSplittingRuleConfiguration 用于将读写分离用户配置转化为读写分离规则对象 org.apache.shardingsphere.readwritesplitting.rule.builder.ReadwriteSplittingRuleBuilder DatabaseDiscoveryRuleConfiguration 用于将数据库发现用户配置转化为数据库发现规则对象 org.apache.shardingsphere.dbdiscovery.rule.builder.DatabaseDiscoveryRuleBuilder EncryptRuleConfiguration 用于将加密用户配置转化为加密规则对象 org.apache.shardingsphere.encrypt.rule.builder.EncryptRuleBuilder ShadowRuleConfiguration 用于将影子库用户配置转化为影子库规则对象 org.apache.shardingsphere.shadow.rule.builder.ShadowRuleBuilder YamlRuleConfigurationSwapper 全限定类名 org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper
定义 用于将 YAML 配置转化为标准用户配置</description>
</item>
<item>
<title>ALTER TRANSACTION RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/alter-transaction-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/alter-transaction-rule/</guid>
<description>描述 ALTER TRANSACTION RULE 语法用于修改事务规则。
语法 语法 铁路图 AlterTransactionRule ::= &amp;#39;ALTER&amp;#39; &amp;#39;TRANSACTION&amp;#39; &amp;#39;RULE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;DEFAULT&amp;#39; &amp;#39;=&amp;#39; defaultTransactionType &amp;#39;,&amp;#39; &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; transactionManager &amp;#39;,&amp;#39; propertiesDefinition &amp;#39;)&amp;#39; &amp;#39;)&amp;#39; propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; defaultTransactionType ::= string transactionManager ::= string key ::= string value ::= literal 补充说明 defaultTransactionType 支持 LOCAL、XA、BASE
transactionManager 支持 Atomikos、Narayana 和 Bitronix</description>
</item>
<item>
<title>COUNT SINGLE_TABLE RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/single-table/count-single-table/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/single-table/count-single-table/</guid>
<description>描述 COUNT SINGLE TABLE 语法用于查询指定逻辑库中的单表个数。
语法 Grammar Railroad diagram CountSingleTable::= &amp;#39;COUNT&amp;#39; &amp;#39;SINGLE&amp;#39; &amp;#39;TABLE&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 database 单表所在的数据库名称 count 单表个数 示例 查询当前逻辑库中的单表规则个数 COUNT SINGLE TABLE mysql&amp;gt; COUNT SINGLE TABLE; +----------+--------+ | database | count | +----------+--------+ | ds | 2 | +----------+--------+ 1 row in set (0.</description>
</item>
<item>
<title>DROP ENCRYPT RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt/drop-encrypt-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/encrypt/drop-encrypt-rule/</guid>
<description>说明 DROP ENCRYPT RULE 语法用于删除加密规则。
语法 语法 铁路图 DropEncryptRule ::= &amp;#39;DROP&amp;#39; &amp;#39;ENCRYPT&amp;#39; &amp;#39;RULE&amp;#39; ifExists? encryptRuleName (&amp;#39;,&amp;#39; encryptRuleName)* ifExists ::= &amp;#39;IF&amp;#39; &amp;#39;EXISTS&amp;#39; encryptRuleName ::= identifier 补充说明 ifExists 子句用于避免 Encrypt rule not exists 错误。 示例 删除加密规则 DROP ENCRYPT RULE t_encrypt, t_encrypt_2; 使用 ifExists 删除加密规则 DROP ENCRYPT RULE IF EXISTS t_encrypt, t_encrypt_2; 保留字 DROP, ENCRYPT, RULE
相关链接 保留字 </description>
</item>
<item>
<title>DROP MASK RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/mask/drop-mask-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/mask/drop-mask-rule/</guid>
<description>说明 DROP MASK RULE 语法用于删除数据脱敏规则。
语法 语法 铁路图 DropEncryptRule ::= &amp;#39;DROP&amp;#39; &amp;#39;MASK&amp;#39; &amp;#39;RULE&amp;#39; ifExists? maskRuleName (&amp;#39;,&amp;#39; maskRuleName)* ifExists ::= &amp;#39;IF&amp;#39; &amp;#39;EXISTS&amp;#39; maskRuleName ::= identifier 补充说明 ifExists 子句用于避免 Mask rule not exists 错误。 示例 删除数据脱敏规则 DROP MASK RULE t_mask, t_mask_1; 使用 ifExists 子句删除数据脱敏规则 DROP MASK RULE IF EXISTS t_mask, t_mask_1; 保留字 DROP, MASK, RULE
相关链接 保留字 </description>
</item>
<item>
<title>DROP READWRITE_SPLITTING RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting/drop-readwrite-splitting-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/readwrite-splitting/drop-readwrite-splitting-rule/</guid>
<description>描述 DROP READWRITE_SPLITTING RULE 语法用于为指定逻辑库删除读写分离。
语法定义 语法 铁路图 DropReadwriteSplittingRule ::= &amp;#39;DROP&amp;#39; &amp;#39;READWRITE_SPLITTING&amp;#39; &amp;#39;RULE&amp;#39; ifExists? readwriteSplittingRuleName (&amp;#39;,&amp;#39; readwriteSplittingRuleName)* (&amp;#39;FROM&amp;#39; databaseName)? ifExists ::= &amp;#39;IF&amp;#39; &amp;#39;EXISTS&amp;#39; readwriteSplittingRuleName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected; ifExists 子句用于避免 Readwrite-splitting rule not exists 错误。 示例 为指定逻辑库删除读写分离规则 DROP READWRITE_SPLITTING RULE ms_group_1 FROM readwrite_splitting_db; 为当前逻辑库删除读写分离规则 DROP READWRITE_SPLITTING RULE ms_group_1; 使用 ifExists 子句删除读写分离规则 DROP READWRITE_SPLITTING RULE IF EXISTS ms_group_1; 保留字 DROP、READWRITE_SPLITTING、RULE</description>
</item>
<item>
<title>DROP SHADOW RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/drop-shadow-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/drop-shadow-rule/</guid>
<description>描述 DROP SHADOW RULE 语法用于为指定逻辑库删除影子库压测规则。
语法定义 语法 铁路图 DropShadowRule ::= &amp;#39;DROP&amp;#39; &amp;#39;SHADOW&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;RULE&amp;#39; ifExists? shadowRuleName (&amp;#39;FROM&amp;#39; databaseName)? ifExists ::= &amp;#39;IF&amp;#39; &amp;#39;EXISTS&amp;#39; shadowRuleName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected; ifExists 子句用于避免 Shadow rule not exists 错误。 示例 为指定数据库删除影子库压测规则 DROP SHADOW RULE shadow_rule FROM shadow_db; 为当前数据库删除影子库压测规则 DROP SHADOW RULE shadow_rule; 使用 ifExists 子句删除影子库压测规则 DROP SHADOW RULE IF EXISTS shadow_rule; 保留字 DROP、SHADOW、RULE、FROM</description>
</item>
<item>
<title>DROP SHARDING TABLE RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/drop-sharding-table-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/drop-sharding-table-rule/</guid>
<description>描述 DROP SHARDING TABLE RULE 语法用于删除指定逻辑库的指定分片规则。
语法定义 语法 铁路图 DropShardingTableRule ::= &amp;#39;DROP&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;RULE&amp;#39; ifExists? shardingRuleName (&amp;#39;,&amp;#39; shardingRuleName)* (&amp;#39;FROM&amp;#39; databaseName)? ifExists ::= &amp;#39;IF&amp;#39; &amp;#39;EXISTS&amp;#39; shardingRuleName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected; ifExists 子句用于避免 Sharding rule not exists 错误。 示例 为指定逻辑库删除多个指定分片规则 DROP SHARDING TABLE RULE t_order, t_order_item FROM sharding_db; 为当前逻辑库删除单个指定分片规则 DROP SHARDING TABLE RULE t_order; 使用 ifExists 子句删除分片规则 DROP SHARDING TABLE RULE IF EXISTS t_order; 保留字 DROP、SHARDING、TABLE、RULE、FROM</description>
</item>
<item>
<title>PREVIEW SQL</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rul/preview-sql/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rul/preview-sql/</guid>
<description>描述 PREVIEW SQL 语法用于预览 SQL 执行计划。
语法 语法 铁路图 PreviewSql ::= &amp;#39;PREVIEW&amp;#39; sqlStatement 返回值说明 列 说明 data_source_name 存储单元名称 actual_sql 实际执行 SQL 语句 示例 预览 SQL 执行计划 PREVIEW SELECT * FROM t_order; mysql&amp;gt; PREVIEW SELECT * FROM t_order; +------------------+-----------------------+ | data_source_name | actual_sql | +------------------+-----------------------+ | su_1 | SELECT * FROM t_order | +------------------+-----------------------+ 1 row in set (0.</description>
</item>
<item>
<title>REGISTER MIGRATION SOURCE STORAGE UNIT</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/register-migration-source-storage-unit/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/register-migration-source-storage-unit/</guid>
<description>描述 REGISTER MIGRATION SOURCE STORAGE UNIT 语法用于为当前连接注册数据迁移源存储单元。
语法 语法 铁路图 RegisterStorageUnit ::= &amp;#39;REGISTER&amp;#39; &amp;#39;MIGRATION&amp;#39; &amp;#39;SOURCE&amp;#39; &amp;#39;STORAGE&amp;#39; &amp;#39;UNIT&amp;#39; storageUnitDefinition (&amp;#39;,&amp;#39; storageUnitDefinition)* storageUnitDefinition ::= StorageUnitName &amp;#39;(&amp;#39; &amp;#39;URL&amp;#39; &amp;#39;=&amp;#39; url &amp;#39;,&amp;#39; &amp;#39;USER&amp;#39; &amp;#39;=&amp;#39; user (&amp;#39;,&amp;#39; &amp;#39;PASSWORD&amp;#39; &amp;#39;=&amp;#39; password)? (&amp;#39;,&amp;#39; propertiesDefinition)?&amp;#39;)&amp;#39; storageUnitName ::= identifier url ::= string user ::= string password ::= string propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; ( key &amp;#39;=&amp;#39; value ) ( &amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value )* &amp;#39;)&amp;#39; key ::= string value ::= literal 特别说明 确认注册的数据迁移源存储单元是可以正常连接的, 否则将不能注册成功; storageUnitName 区分大小写; storageUnitName 在当前连接中需要唯一; storageUnitName 命名只允许使用字母、数字以及 _ ,且必须以字母开头; poolProperty 用于自定义连接池参数,key 必须和连接池参数名一致,value 支持 int 和 String 类型; 当 password 包含特殊字符时,建议使用 string 形式;例如 password@123的 string 形式为 &amp;quot;password@123&amp;quot;; 数据迁移源存储单元暂时仅支持使用 URL 注册,暂时不支持使用 HOST 和 PORT。 示例 注册数据迁移源存储单元 REGISTER MIGRATION SOURCE STORAGE UNIT ds_0 ( URL=&amp;#34;jdbc:mysql://127.</description>
</item>
<item>
<title>SHOW COMPUTE NODES</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/circuit-breaker/show-compute-nodes/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/circuit-breaker/show-compute-nodes/</guid>
<description>描述 SHOW COMPUTE NODES 语法用于查询 proxy 实例信息。
语法 语法 铁路图 ShowComputeNodes ::= &amp;#39;SHOW&amp;#39; &amp;#39;COMPUTE&amp;#39; &amp;#39;NODES&amp;#39; 返回值说明 列 说明 instance_id proxy 实例编号 host 主机地址 port 端口号 status proxy 实例状态 mode_type proxy 实例模式 worker_id worker id labels 标签 version 版本 示例 查询 proxy 实例信息 SHOW COMPUTE NODES; mysql&amp;gt; SHOW COMPUTE NODES; +--------------------------------------+---------------+------+--------+-----------+-----------+--------+---------+ | instance_id | host | port | status | mode_type | worker_id | labels | version | +--------------------------------------+---------------+------+--------+-----------+-----------+--------+---------+ | 734bb036-b15d-4af0-be87-2372d8b6a0cd | 192.</description>
</item>
<item>
<title>SHOW SHADOW ALGORITHMS</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow/show-shadow-algorithm/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow/show-shadow-algorithm/</guid>
<description>描述 SHOW SHADOW ALGORITHMS 语法用于查询指定逻辑库中的影子算法。
语法 语法 铁路图 ShowEncryptAlgorithm::= &amp;#39;SHOW&amp;#39; &amp;#39;SHADOW&amp;#39; &amp;#39;ALGORITHMS&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 shadow_algorithm_name 影子算法名称 type 算法类型 props 算法参数 is_default 是否默认 示例 查询指定逻辑库中的影子算法 SHOW SHADOW ALGORITHMS FROM shadow_db; mysql&amp;gt; SHOW SHADOW ALGORITHMS FROM shadow_db; +-------------------------+-------------+-----------------------------------------+------------+ | shadow_algorithm_name | type | props | is_default | +-------------------------+-------------+-----------------------------------------+------------+ | user_id_match_algorithm | VALUE_MATCH | column=user_id,operation=insert,value=1 | false | +-------------------------+-------------+-----------------------------------------+------------+ 1 row in set (0.</description>
</item>
<item>
<title>SHOW UNUSED SHARDING ALGORITHMS</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-unused-sharding-algorithms/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-unused-sharding-algorithms/</guid>
<description>描述 SHOW UNUSED SHARDING ALGORITHMS 语法用于查询指定逻辑库未使用的分片算法。
语法 语法 铁路图 ShowShardingAlgorithms::= &amp;#39;SHOW&amp;#39; &amp;#39;UNUSED&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;ALGORITHMS&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 name 分片算法名称 type 分片算法类型 props 分片算法参数 示例 查询指定逻辑库未使用的分片算法 SHOW UNUSED SHARDING ALGORITHMS; mysql&amp;gt; SHOW UNUSED SHARDING ALGORITHMS; +---------------+--------+-----------------------------------------------------+ | name | type | props | +---------------+--------+-----------------------------------------------------+ | t1_inline | INLINE | algorithm-expression=t_order_${order_id % 2} | +---------------+--------+-----------------------------------------------------+ 1 row in set (0.</description>
</item>
<item>
<title>SQL Hint</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/sql-hint/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/sql-hint/</guid>
<description>背景信息 目前,主流的关系型数据库基本都提供了 SQL Hint 作为 SQL 语法的补充,SQL Hint 允许用户通过数据库内置的 Hint 语法来干预 SQL 的执行过程,从而完成一些特殊的功能,或实现对 SQL 执行的优化。 ShardingSphere 同样提供了丰富的 SQL Hint 语法,允许用户进行数据分片、读写分离的强制路由以及数据源透传等灵活控制。
使用规范 ShardingSphere 的 SQL Hint 语法需要以注释的形式编写在 SQL 中,SQL Hint 语法格式暂时只支持 /* */,Hint 内容需要以 SHARDINGSPHERE_HINT: 为起始,然后定义不同功能所对应的属性键值对,当存在多个属性时使用逗号分隔。 ShardingSphere 的 SQL Hint 语法格式如下:
/* SHARDINGSPHERE_HINT: {key} = {value}, {key} = {value} */ SELECT * FROM t_order; 使用 SQL Hint 功能,需要将 ShardingSphere SQL Parser 规则中的 sqlCommentParseEnabled 设置为 true,开启 SQL 注释解析功能。此外,如果使用 MySQL 客户端连接,需要添加 -c 选项保留注释,客户端默认是 --skip-comments 过滤注释。</description>
</item>
<item>
<title>UNREGISTER STORAGE UNIT</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/storage-unit-definition/unregister-storage-unit/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/storage-unit-definition/unregister-storage-unit/</guid>
<description>描述 UNREGISTER STORAGE UNIT 语法用于从当前逻辑库中移除存储单元。
语法 语法 铁路图 UnregisterStorageUnit ::= &amp;#39;UNREGISTER&amp;#39; &amp;#39;STORAGE&amp;#39; &amp;#39;UNIT&amp;#39; ifExists? storageUnitName (&amp;#39;,&amp;#39; storageUnitName)* (&amp;#39;IGNORE&amp;#39; &amp;#39;SINGLE&amp;#39; &amp;#39;TABLES&amp;#39;)? ifExists ::= &amp;#39;IF&amp;#39; &amp;#39;EXISTS&amp;#39; storageUnitName ::= identifier 补充说明 UNREGISTER STORAGE UNIT 只会移除 Proxy 中的存储单元,不会删除与存储单元对应的真实数据源; 无法移除已经被规则使用的存储单元。移除被规则使用的存储单元时会提示 Storage unit are still in used; 将要移除的存储单元中仅包含 SINGLE RULE,且用户确认可以忽略该限制时,可添加 IGNORE SINGLE TABLES 关键字移除存储单元; ifExists 子句用于避免 Storage unit not exists 错误。 示例 移除存储单元 UNREGISTER STORAGE UNIT ds_0; 移除多个存储单元 UNREGISTER STORAGE UNIT ds_0, ds_1; 忽略单表移除存储单元 UNREGISTER STORAGE UNIT ds_0 IGNORE SINGLE TABLES; 使用 ifExists 子句移除存储单元 UNREGISTER STORAGE UNIT IF EXISTS ds_0; 保留字 DROP、STORAGE、UNIT、IF、EXISTS、IGNORE、SINGLE、TABLES</description>
</item>
<item>
<title>使用 Helm</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/startup/helm/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/startup/helm/</guid>
<description>背景信息 使用 Helm 在 Kubernetes 集群中引导 ShardingSphere-Proxy 实例进行安装。关于 ShardingSphere Helm Charts 的更多内容可以参考:ShardingSphere-on-Cloud 子项目。
前提条件 kubernetes 1.18+ kubectl helm 3.3.0+ 可以动态申请 PV(Persistent Volumes) 的 StorageClass 用于持久化数据。(可选) 操作步骤 在线安装 将 ShardingSphere-Proxy 添加到 Helm 本地仓库: helm repo add shardingsphere https://shardingsphere.apache.org/charts 以 ShardingSphere-Proxy 命名安装 charts: helm install shardingsphere-proxy shardingsphere/shardingsphere-proxy 源码安装 执行下述命令以执行默认配置进行安装。 git clone https://github.com/apache/shardingsphere-on-cloud.git cd charts/shardingsphere-proxy/charts/governance helm dependency build cd ../.. helm dependency build cd .. helm install shardingsphere-proxy shardingsphere-proxy 说明:</description>
</item>
<item>
<title>内核</title>
<link>https://shardingsphere.apache.org/document/current/cn/dev-manual/kernel/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/kernel/</guid>
<description>SQLRouter 全限定类名 org.apache.shardingsphere.infra.route.SQLRouter
定义 用于处理路由结果
已知实现 配置标识 详细说明 全限定类名 SingleRule 用于处理单表路由结果 org.apache.shardingsphere.singletable.route.SingleTableSQLRouter ShardingRule 用于处理分片路由结果 org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter ReadwriteSplittingRule 用于处理读写分离路由结果 org.apache.shardingsphere.readwritesplitting.route.ReadwriteSplittingSQLRouter DatabaseDiscoveryRule 用于处理数据库发现路由结果 org.apache.shardingsphere.dbdiscovery.route.DatabaseDiscoverySQLRouter ShadowRule 用于处理影子库路由结果 org.apache.shardingsphere.shadow.route.ShadowSQLRouter SQLRewriteContextDecorator 全限定类名 org.apache.shardingsphere.infra.rewrite.context.SQLRewriteContextDecorator
定义 用于处理 SQL 改写结果
已知实现 配置标识 详细说明 全限定类名 ShardingRule 用于处理分片 SQL 改写结果 org.</description>
</item>
<item>
<title>分布式事务</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/transaction/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/transaction/</guid>
<description>配置入口 org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration
可配置属性:
名称 数据类型 说明 defaultType String 默认事务类型 providerType (?) String 事务提供者类型 props (?) Properties 事务属性配置 </description>
</item>
<item>
<title>分布式事务</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/transaction/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/transaction/</guid>
<description>背景信息 ShardingSphere 提供了三种模式的分布式事务 LOCAL, XA, BASE。
参数解释 transaction: defaultType: # 事务模式,可选值 LOCAL/XA/BASE providerType: # 指定模式下的具体实现 操作步骤 使用 LOCAL 模式 server.yaml 配置文件内容如下:
transaction: defaultType: LOCAL 使用 XA 模式 server.yaml 配置文件内容如下:
transaction: defaultType: XA providerType: Narayana/Atomikos 手动添加 Narayana 相关依赖:
jta-5.12.4.Final.jar arjuna-5.12.4.Final.jar common-5.12.4.Final.jar jboss-connector-api_1.7_spec-1.0.0.Final.jar jboss-logging-3.2.1.Final.jar jboss-transaction-api_1.2_spec-1.0.0.Alpha3.jar jboss-transaction-spi-7.6.0.Final.jar narayana-jts-integration-5.12.4.Final.jar shardingsphere-transaction-xa-narayana-x.x.x-SNAPSHOT.jar 使用 BASE 模式 server.yaml 配置文件内容如下:
transaction: defaultType: BASE providerType: Seata 搭建 Seata Server,添加相关配置文件,和 Seata 依赖,具体步骤参考 ShardingSphere 集成 Seata 柔性事务</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/reference/sharding/rewrite/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/reference/sharding/rewrite/</guid>
<description>工程师面向逻辑库与逻辑表书写的 SQL,并不能够直接在真实的数据库中执行,SQL 改写用于将逻辑 SQL 改写为在真实数据库中可以正确执行的 SQL。 它包括正确性改写和优化改写两部分。
正确性改写 在包含分表的场景中,需要将分表配置中的逻辑表名称改写为路由之后所获取的真实表名称。仅分库则不需要表名称的改写。除此之外,还包括补列和分页信息修正等内容。
标识符改写 需要改写的标识符包括表名称、索引名称以及 Schema 名称。
表名称改写是指将找到逻辑表在原始 SQL 中的位置,并将其改写为真实表的过程。表名称改写是一个典型的需要对 SQL 进行解析的场景。 从一个最简单的例子开始,若逻辑 SQL 为:
SELECT order_id FROM t_order WHERE order_id=1; 假设该 SQL 配置分片键 order_id,并且 order_id=1 的情况,将路由至分片表 1。那么改写之后的 SQL 应该为:
SELECT order_id FROM t_order_1 WHERE order_id=1; 在这种最简单的 SQL 场景中,是否将 SQL 解析为抽象语法树似乎无关紧要,只要通过字符串查找和替换就可以达到 SQL 改写的效果。 但是下面的场景,就无法仅仅通过字符串的查找替换来正确的改写 SQL 了:
SELECT order_id FROM t_order WHERE order_id=1 AND remarks=&amp;#39; t_order xxx&amp;#39;; 正确改写的 SQL 应该是:
SELECT order_id FROM t_order_1 WHERE order_id=1 AND remarks=&amp;#39; t_order xxx&amp;#39;; 而非:</description>
</item>
<item>
<title>数据加密</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/usage/encrypt-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/usage/encrypt-rule/</guid>
<description>存储单元操作 REGISTER STORAGE UNIT ds_0 ( HOST=&amp;#34;127.0.0.1&amp;#34;, PORT=3306, DB=&amp;#34;ds_0&amp;#34;, USER=&amp;#34;root&amp;#34;, PASSWORD=&amp;#34;root&amp;#34; ); 规则操作 创建加密规则 CREATE ENCRYPT RULE t_encrypt ( COLUMNS( (NAME=user_id,CIPHER=user_cipher,ENCRYPT_ALGORITHM(TYPE(NAME=&amp;#39;AES&amp;#39;,PROPERTIES(&amp;#39;aes-key-value&amp;#39;=&amp;#39;123456abc&amp;#39;)))), (NAME=order_id,CIPHER =order_cipher,ENCRYPT_ALGORITHM(TYPE(NAME=&amp;#39;RC4&amp;#39;,PROPERTIES(&amp;#39;rc4-key-value&amp;#39;=&amp;#39;123456abc&amp;#39;)))) )); 创建加密表 CREATE TABLE `t_encrypt` ( `id` int(11) NOT NULL, `user_id` varchar(45) DEFAULT NULL, `order_id` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 修改加密规则 ALTER ENCRYPT RULE t_encrypt ( COLUMNS( (NAME=user_id,CIPHER=user_cipher,ENCRYPT_ALGORITHM(TYPE(NAME=&amp;#39;AES&amp;#39;,PROPERTIES(&amp;#39;aes-key-value&amp;#39;=&amp;#39;123456abc&amp;#39;)))) )); 删除加密规则 DROP ENCRYPT RULE t_encrypt; 移除数据源 UNREGISTER STORAGE UNIT ds_0; 删除分布式数据库 DROP DATABASE encrypt_db; </description>
</item>
<item>
<title>规则配置</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/yaml-config/rules/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/yaml-config/rules/</guid>
<description>背景信息 本节介绍如何进行 ShardingSphere-Proxy 的规则配置。
参数解释 ShardingSphere-Proxy 的规则配置与 ShardingSphere-JDBC 一致,具体规则请参考 ShardingSphere-JDBC 规则配置。
注意事项 与 ShardingSphere-JDBC 不同的是,以下规则需要配置在 ShardingSphere-Proxy 的 server.yaml 中:
SQL 解析 sqlParser: sqlCommentParseEnabled: true sqlStatementCache: initialCapacity: 2000 maximumSize: 65535 parseTreeCache: initialCapacity: 128 maximumSize: 1024 分布式事务 transaction: defaultType: XA providerType: Atomikos SQL 翻译 sqlTranslator: type: useOriginalSQLWhenTranslatingFailed: </description>
</item>
<item>
<title>附录</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/encrypt/appendix/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/encrypt/appendix/</guid>
<description>不支持的 SQL:
加密字段无法支持查询不区分大小写功能; 加密字段无法支持比较操作,如:大于、小于、ORDER BY、BETWEEN 等; 加密字段无法支持计算操作,如:AVG、SUM 以及计算表达式。 </description>
</item>
<item>
<title>附录</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/sharding/appendix/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/sharding/appendix/</guid>
<description>有限支持的 SQL:
使用 JDBC 规范 getGeneratedKeys 接口返回自增主键时,需要配合使用支持自增的分布式主键生成器,不支持其他类型的分布式主键生成器 不支持的 SQL:
CASE WHEN 中包含子查询 CASE WHEN 中使用逻辑表名(请使用表别名) INSERT INTO tbl_name (col1, col2, …) SELECT * FROM tbl_name WHERE col3 = ?(SELECT 子句不支持 * 和内置分布式主键生成器) REPLACE INTO tbl_name (col1, col2, …) SELECT * FROM tbl_name WHERE col3 = ?(SELECT 子句不支持 * 和内置分布式主键生成器) SELECT MAX(tbl_name.col1) FROM tbl_name(查询列是函数表达式时,查询列前不能使用表名,可以使用表别名) </description>
</item>
<item>
<title>附录</title>
<link>https://shardingsphere.apache.org/document/current/cn/features/transaction/appendix/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/features/transaction/appendix/</guid>
<description>不支持的 SQL:
事务中使用 DistSQL 里的 RAL、RDL 操作; XA 事务中使用 DDL 语句。 XA 事务所需的权限:
在 MySQL8 中需要授予用户 XA_RECOVER_ADMIN 权限,否则 XA 事务管理器执行 XA RECOVER 语句时会报错。</description>
</item>
<item>
<title>Atomikos 事务</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/transaction/atomikos/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/transaction/atomikos/</guid>
<description>背景信息 Apache ShardingSphere 提供 XA 事务,默认的 XA 事务实现为 Atomikos。
操作步骤 配置事务类型 配置 Atomikos 配置示例 配置事务类型 Yaml:
transaction: defaultType: XA providerType: Atomikos 配置 Atomikos 可以通过在项目的 classpath 中添加 jta.properties 来定制化 Atomikos 配置项。
详情请参见 Atomikos 官方文档 。
数据恢复 在项目的 logs 目录中会生成 xa_tx.log, 这是 XA 崩溃恢复时所需的日志,请勿删除。</description>
</item>
<item>
<title>CREATE DEFAULT SHADOW ALGORITHM</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/create-default-shadow-algorithm/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/create-default-shadow-algorithm/</guid>
<description>描述 CREATE DEFAULT SHADOW ALGORITHM 语法用于创建影子库默认算法规则。
语法定义 语法 铁路图 CreateDefaultShadowAlgorithm ::= &amp;#39;CREATE&amp;#39; &amp;#39;DEFAULT&amp;#39; &amp;#39;SHADOW&amp;#39; &amp;#39;ALGORITHM&amp;#39; ifNotExists? shadowAlgorithm ifNotExists ::= &amp;#39;IF&amp;#39; &amp;#39;NOT&amp;#39; &amp;#39;EXISTS&amp;#39; shadowAlgorithm ::= &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; shadowAlgorithmType &amp;#39;,&amp;#39; propertiesDefiinition &amp;#39;)&amp;#39; shadowAlgorithmType ::= string propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; key ::= string value ::= literal 补充说明 shadowAlgorithmType 目前支持 VALUE_MATCH、REGEX_MATCH 和 SQL_HINT; ifNotExists 子句用于避免出现 Duplicate default shadow algorithm 错误。 示例 创建默认影子库压测算法 CREATE DEFAULT SHADOW ALGORITHM TYPE(NAME=&amp;#34;SQL_HINT&amp;#34;); 使用 ifNotExists 子句创建默认影子库压测算法 CREATE DEFAULT SHADOW ALGORITHM IF NOT EXISTS TYPE(NAME=&amp;#34;SQL_HINT&amp;#34;); 保留字 CREATE、DEFAULT、SHADOW、ALGORITHM、TYPE、NAME、PROPERTIES</description>
</item>
<item>
<title>CREATE DEFAULT SHARDING STRATEGY</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/create-default-sharding-strategy/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/create-default-sharding-strategy/</guid>
<description>描述 CREATE DEFAULT SHARDING STRATEGY 语法用于创建默认的分片策略。
语法定义 语法 铁路图 CreateDefaultShardingStrategy ::= &amp;#39;CREATE&amp;#39; &amp;#39;DEFAULT&amp;#39; &amp;#39;SHARDING&amp;#39; (&amp;#39;DATABASE&amp;#39; | &amp;#39;TABLE&amp;#39;) &amp;#39;STRATEGY&amp;#39; ifNotExists? &amp;#39;(&amp;#39; shardingStrategy &amp;#39;)&amp;#39; ifNotExists ::= &amp;#39;IF&amp;#39; &amp;#39;NOT&amp;#39; &amp;#39;EXISTS&amp;#39; shardingStrategy ::= &amp;#39;TYPE&amp;#39; &amp;#39;=&amp;#39; strategyType &amp;#39;,&amp;#39; (&amp;#39;SHARDING_COLUMN&amp;#39; &amp;#39;=&amp;#39; columnName | &amp;#39;SHARDING_COLUMNS&amp;#39; &amp;#39;=&amp;#39; columnNames) &amp;#39;,&amp;#39; &amp;#39;SHARDING_ALGORITHM&amp;#39; &amp;#39;=&amp;#39; algorithmDefinition strategyType ::= string algorithmDefinition ::= &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; algorithmType &amp;#39;,&amp;#39; propertiesDefinition &amp;#39;)&amp;#39; columnNames ::= columnName (&amp;#39;,&amp;#39; columnName)+ columnName ::= identifier algorithmType ::= string propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; key ::= string value ::= literal 补充说明 当使用复合分片算法时,需要通过 SHARDING_COLUMNS 指定多个分片键; algorithmType 为分片算法类型,详细的分片算法类型信息请参考分片算法; ifNotExists 子句用于避免出现 Duplicate default sharding strategy 错误。 示例 创建默认分表策略 CREATE DEFAULT SHARDING TABLE STRATEGY ( TYPE=&amp;#34;standard&amp;#34;, SHARDING_COLUMN=user_id, SHARDING_ALGORITHM(TYPE(NAME=inline, PROPERTIES(&amp;#34;algorithm-expression&amp;#34;=&amp;#34;t_order_${user_id % 2}&amp;#34;))) ); 使用 ifNotExists 创建默认分表策略 CREATE DEFAULT SHARDING TABLE STRATEGY IF NOT EXISTS ( TYPE=&amp;#34;standard&amp;#34;, SHARDING_COLUMN=user_id, SHARDING_ALGORITHM(TYPE(NAME=inline, PROPERTIES(&amp;#34;algorithm-expression&amp;#34;=&amp;#34;t_order_${user_id % 2}&amp;#34;))) ); 保留字 CREATE、DEFAULT、SHARDING、DATABASE、TABLE、STRATEGY、TYPE、SHARDING_COLUMN、SHARDING_COLUMNS、SHARDING_ALGORITHM、NAME、PROPERTIES</description>
</item>
<item>
<title>ENABLE/DISABLE COMPUTE NODE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/circuit-breaker/enable-disable-compute-node/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/circuit-breaker/enable-disable-compute-node/</guid>
<description>描述 ENABLE/DISABLE COMPUTE NODE 语法用于启用/禁用指定 proxy 实例。
语法定义 语法 铁路图 EnableDisableComputeNode ::= (&amp;#39;ENABLE&amp;#39; | &amp;#39;DISABLE&amp;#39;) &amp;#39;COMPUTE&amp;#39; &amp;#39;NODE&amp;#39; instanceId instanceId ::= string 补充说明 instanceId 需要通过 SHOW COMPUTE NODES 语法查询得到
不可禁用当前正在使用的 proxy 实例
示例 禁用指定 proxy 实例 DISABLE COMPUTE NODE &amp;#39;734bb086-b15d-4af0-be87-2372d8b6a0cd&amp;#39;; 启用指定 proxy 实例 ENABLE COMPUTE NODE &amp;#39;734bb086-b15d-4af0-be87-2372d8b6a0cd&amp;#39;; 保留字 ENABLE、DISABLE、COMPUTE、NODE
相关链接 保留字 SHOW COMPUTE NODES </description>
</item>
<item>
<title>SHOW COMPUTE NODE INFO</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-compute-node-info/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-compute-node-info/</guid>
<description>描述 SHOW COMPUTE NODE INFO 语法用于查询当前 proxy 实例信息。
语法 语法 铁路图 ShowComputeNodeInfo ::= &amp;#39;SHOW&amp;#39; &amp;#39;COMPUTE&amp;#39; &amp;#39;NODE&amp;#39; &amp;#39;INFO&amp;#39; 返回值说明 列 说明 instance_id proxy 实例编号 host 主机地址 port 端口号 status proxy 实例状态 mode_type proxy 实例模式 worker_id worker id labels 标签 示例 查询当前 proxy 实例信息 SHOW COMPUTE NODE INFO; mysql&amp;gt; SHOW COMPUTE NODE INFO; +--------------------------------------+---------------+------+--------+-----------+-----------+--------+ | instance_id | host | port | status | mode_type | worker_id | labels | +--------------------------------------+---------------+------+--------+-----------+-----------+--------+ | 734bb036-b15d-4af0-be87-2372d8b6a0cd | 192.</description>
</item>
<item>
<title>SHOW DEFAULT SHADOW ALGORITHM</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow/show-default-shadow-algorithm/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow/show-default-shadow-algorithm/</guid>
<description>描述 SHOW DEFAULT SHADOW ALGORITHM 语法用于查询指定逻辑库中的默认影子算法。
语法 语法 铁路图 ShowEncryptAlgorithm::= &amp;#39;SHOW&amp;#39; &amp;#39;DEFAULT&amp;#39; &amp;#39;SHADOW&amp;#39; &amp;#39;ALGORITHMS&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 shadow_algorithm_name 影子算法名称 type 算法类型 props 算法参数 示例 查询指定逻辑库中的默认影子算法 SHOW DEFAULT SHADOW ALGORITHMS FROM shadow_db; mysql&amp;gt; SHOW DEFAULT SHADOW ALGORITHMS FROM shadow_db; +-------------------------+-------------+-----------------------------------------+ | shadow_algorithm_name | type | props | +-------------------------+-------------+-----------------------------------------+ | user_id_match_algorithm | VALUE_MATCH | column=user_id,operation=insert,value=1 | +-------------------------+-------------+-----------------------------------------+ 1 row in set (0.</description>
</item>
<item>
<title>SHOW DEFAULT SHARDING STRATEGY</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-default-sharding-strategy/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-default-sharding-strategy/</guid>
<description>描述 SHOW DEFAULT SHARDING STRATEGY 语法用于查询指定逻辑库的默认分片策略。
语法 语法 铁路图 ShowDefaultShardingStrategy::= &amp;#39;SHOW&amp;#39; &amp;#39;DEFAULT&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;STRATEGY&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 name 分片策略范围 type 分片策略类型 sharding_column 分片键 sharding_algorithm_name 分片算法名称 sharding_algorithm_type 分片算法类型 sharding_algorithm_props 分片算法参数 示例 查询指定逻辑库的默认分片策略 SHOW DEFAULT SHARDING STRATEGY FROM sharding_db; mysql&amp;gt; SHOW DEFAULT SHARDING STRATEGY FROM sharding_db; +----------+----------+-----------------+-------------------------+-------------------------+-----------------------------------------------------+ | name | type | sharding_column | sharding_algorithm_name | sharding_algorithm_type | sharding_algorithm_props | +----------+----------+-----------------+-------------------------+-------------------------+-----------------------------------------------------+ | TABLE | STANDARD | order_id | table_inline | inline | {algorithm-expression=t_order_item_${order_id % 2}} | | DATABASE | STANDARD | order_id | table_inline | inline | {algorithm-expression=t_order_item_${order_id % 2}} | +----------+----------+-----------------+-------------------------+-------------------------+-----------------------------------------------------+ 2 rows in set (0.</description>
</item>
<item>
<title>SHOW SQL_PARSER RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/show-sql-parser-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/show-sql-parser-rule/</guid>
<description>描述 SHOW SQL_PARSER RULE 语法用于查询解析引擎规则配置。
语法 语法 铁路图 ShowSqlParserRule ::= &amp;#39;SHOW&amp;#39; &amp;#39;SQL_PARSER&amp;#39; &amp;#39;RULE&amp;#39; 返回值说明 列 说明 sql_comment_parse_enabled SQL 注释解析启用状态 parse_tree_cache 语法树缓存 sql_statement_cache SQL 语句缓存 示例 查询解析引擎规则配置 SHOW SQL_PARSER RULE; mysql&amp;gt; SHOW SQL_PARSER RULE; +---------------------------+-----------------------------------------+-------------------------------------------+ | sql_comment_parse_enabled | parse_tree_cache | sql_statement_cache | +---------------------------+-----------------------------------------+-------------------------------------------+ | false | initialCapacity: 128, maximumSize: 1024 | initialCapacity: 2000, maximumSize: 65535 | +---------------------------+-----------------------------------------+-------------------------------------------+ 1 row in set (0.</description>
</item>
<item>
<title>UNREGISTER MIGRATION SOURCE STORAGE UNIT</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/unregister-storage-unit/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/unregister-storage-unit/</guid>
<description>描述 UNREGISTER MIGRATION SOURCE STORAGE UNIT 语法用于从当前逻辑库中移除存储单元。
语法 语法 铁路图 UnregisterMigrationSourceStorageUnit ::= &amp;#39;UNREGISTER&amp;#39; &amp;#39;MIGRATION&amp;#39; &amp;#39;SOURCE&amp;#39; &amp;#39;STORAGE&amp;#39; &amp;#39;UNIT&amp;#39; storageUnitName (&amp;#39;,&amp;#39; storageUnitName)* storageUnitName ::= identifier 补充说明 UNREGISTER MIGRATION SOURCE STORAGE UNIT 只会移除 Proxy 中的存储单元,不会删除与存储单元对应的真实数据源; 示例 移除数据迁移源存储单元 UNREGISTER MIGRATION SOURCE STORAGE UNIT ds_0; 移除多个数据迁移源存储单元 UNREGISTER MIGRATION SOURCE STORAGE UNIT ds_0, ds_1; 保留字 UNREGISTER、MIGRATION、SOURCE、STORAGE、UNIT
相关链接 保留字 </description>
</item>
<item>
<title>执行引擎</title>
<link>https://shardingsphere.apache.org/document/current/cn/reference/sharding/execute/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/reference/sharding/execute/</guid>
<description>ShardingSphere 采用一套自动化的执行引擎,负责将路由和改写完成之后的真实 SQL 安全且高效发送到底层数据源执行。 它不是简单地将 SQL 通过 JDBC 直接发送至数据源执行;也并非直接将执行请求放入线程池去并发执行。它更关注平衡数据源连接创建以及内存占用所产生的消耗,以及最大限度地合理利用并发等问题。 执行引擎的目标是自动化的平衡资源控制与执行效率。
连接模式 从资源控制的角度看,业务方访问数据库的连接数量应当有所限制。 它能够有效地防止某一业务操作过多的占用资源,从而将数据库连接的资源耗尽,以致于影响其他业务的正常访问。 特别是在一个数据库实例中存在较多分表的情况下,一条不包含分片键的逻辑 SQL 将产生落在同库不同表的大量真实 SQL ,如果每条真实SQL都占用一个独立的连接,那么一次查询无疑将会占用过多的资源。
从执行效率的角度看,为每个分片查询维持一个独立的数据库连接,可以更加有效的利用多线程来提升执行效率。 为每个数据库连接开启独立的线程,可以将 I/O 所产生的消耗并行处理。为每个分片维持一个独立的数据库连接,还能够避免过早的将查询结果数据加载至内存。 独立的数据库连接,能够持有查询结果集游标位置的引用,在需要获取相应数据时移动游标即可。
以结果集游标下移进行结果归并的方式,称之为流式归并,它无需将结果数据全数加载至内存,可以有效的节省内存资源,进而减少垃圾回收的频次。 当无法保证每个分片查询持有一个独立数据库连接时,则需要在复用该数据库连接获取下一张分表的查询结果集之前,将当前的查询结果集全数加载至内存。 因此,即使可以采用流式归并,在此场景下也将退化为内存归并。
一方面是对数据库连接资源的控制保护,一方面是采用更优的归并模式达到对中间件内存资源的节省,如何处理好两者之间的关系,是 ShardingSphere 执行引擎需要解决的问题。 具体来说,如果一条 SQL 在经过 ShardingSphere 的分片后,需要操作某数据库实例下的 200 张表。 那么,是选择创建 200 个连接并行执行,还是选择创建一个连接串行执行呢?效率与资源控制又应该如何抉择呢?
针对上述场景,ShardingSphere 提供了一种解决思路。 它提出了连接模式(Connection Mode)的概念,将其划分为内存限制模式(MEMORY_STRICTLY)和连接限制模式(CONNECTION_STRICTLY)这两种类型。
内存限制模式 使用此模式的前提是,ShardingSphere 对一次操作所耗费的数据库连接数量不做限制。 如果实际执行的 SQL 需要对某数据库实例中的 200 张表做操作,则对每张表创建一个新的数据库连接,并通过多线程的方式并发处理,以达成执行效率最大化。 并且在 SQL 满足条件情况下,优先选择流式归并,以防止出现内存溢出或避免频繁垃圾回收情况。
连接限制模式 使用此模式的前提是,ShardingSphere 严格控制对一次操作所耗费的数据库连接数量。 如果实际执行的 SQL 需要对某数据库实例中的 200 张表做操作,那么只会创建唯一的数据库连接,并对其 200 张表串行处理。 如果一次操作中的分片散落在不同的数据库,仍然采用多线程处理对不同库的操作,但每个库的每次操作仍然只创建一个唯一的数据库连接。 这样即可以防止对一次请求对数据库连接占用过多所带来的问题。该模式始终选择内存归并。
内存限制模式适用于 OLAP 操作,可以通过放宽对数据库连接的限制提升系统吞吐量; 连接限制模式适用于 OLTP 操作,OLTP 通常带有分片键,会路由到单一的分片,因此严格控制数据库连接,以保证在线系统数据库资源能够被更多的应用所使用,是明智的选择。</description>
</item>
<item>
<title>数据加密</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/encrypt/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/encrypt/</guid>
<description>背景信息 数据加密 Java API 规则配置允许用户直接通过编写 Java 代码的方式,完成 ShardingSphereDataSource 对象的创建,Java API 的配置方式非常灵活,不需要依赖额外的 jar 包 就能够集成各种类型的业务系统。
参数解释 配置入口 类名称:org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration
可配置属性:
名称 数据类型 说明 默认值 tables (+) Collection&amp;lt;EncryptTableRuleConfiguration&amp;gt; 加密表规则配置 encryptors (+) Map&amp;lt;String, AlgorithmConfiguration&amp;gt; 加解密算法名称和配置 加密表规则配置 类名称:org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration
可配置属性:
名称 数据类型 说明 name String 表名称 columns (+) Collection&amp;lt;EncryptColumnRuleConfiguration&amp;gt; 加密列规则配置列表 加密列规则配置 类名称:org.</description>
</item>
<item>
<title>数据加密</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/encrypt/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/encrypt/</guid>
<description>背景信息 数据加密 YAML 配置方式具有非凡的可读性,通过 YAML 格式,能够快速地理解加密规则之间的依赖关系,ShardingSphere 会根据 YAML 配置,自动完成 ShardingSphereDataSource 对象的创建,减少用户不必要的编码工作。
参数解释 rules: - !ENCRYPT tables: &amp;lt;table_name&amp;gt; (+): # 加密表名称 columns: &amp;lt;column_name&amp;gt; (+): # 加密列名称 cipher: name: # 密文列名称 encryptorName: # 密文列加密算法名称 assistedQuery (?): name: # 查询辅助列名称 encryptorName: # 查询辅助列加密算法名称 likeQuery (?): name: # 模糊查询列名称 encryptorName: # 模糊查询列加密算法名称 # 加密算法配置 encryptors: &amp;lt;encrypt_algorithm_name&amp;gt; (+): # 加解密算法名称 type: # 加解密算法类型 props: # 加解密算法属性配置 # ... 算法类型的详情,请参见内置加密算法列表。
操作步骤 在 YAML 文件中配置数据加密规则,包含数据源、加密规则、全局属性等配置项; 调用 YamlShardingSphereDataSourceFactory 对象的 createDataSource 方法,根据 YAML 文件中的配置信息创建 ShardingSphereDataSource。 配置示例 数据加密 YAML 配置如下:</description>
</item>
<item>
<title>数据源</title>
<link>https://shardingsphere.apache.org/document/current/cn/dev-manual/data-source/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/data-source/</guid>
<description>DatabaseType 全限定类名 org.apache.shardingsphere.infra.database.type.DatabaseType
定义 支持的数据库类型
已知实现 配置标识 详细说明 全限定类名 SQL92 遵循 SQL92 标准的数据库类型 org.apache.shardingsphere.infra.database.type.dialect.SQL92DatabaseType MySQL MySQL 数据库 org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType MariaDB MariaDB 数据库 org.apache.shardingsphere.infra.database.type.dialect.MariaDBDatabaseType PostgreSQL PostgreSQL 数据库 org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType Oracle Oracle 数据库 org.apache.shardingsphere.infra.database.type.dialect.OracleDatabaseType SQLServer SQLServer 数据库 org.apache.shardingsphere.infra.database.type.dialect.SQLServerDatabaseType H2 H2 数据库 org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType openGauss OpenGauss 数据库 org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType DialectSchemaMetaDataLoader 全限定类名 org.apache.shardingsphere.infra.metadata.database.schema.loader.metadata.DialectSchemaMetaDataLoader
定义 使用 SQL 方言快速加载元数据</description>
</item>
<item>
<title>数据脱敏</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/usage/mask-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/usage/mask-rule/</guid>
<description>存储单元操作 REGISTER STORAGE UNIT ds_0 ( HOST=&amp;#34;127.0.0.1&amp;#34;, PORT=3306, DB=&amp;#34;ds_0&amp;#34;, USER=&amp;#34;root&amp;#34;, PASSWORD=&amp;#34;root&amp;#34; ); 规则操作 创建数据脱敏规则 CREATE MASK RULE t_mask ( COLUMNS( (NAME=phone_number,TYPE(NAME=&amp;#39;MASK_FROM_X_TO_Y&amp;#39;, PROPERTIES(&amp;#34;from-x&amp;#34;=1, &amp;#34;to-y&amp;#34;=2, &amp;#34;replace-char&amp;#34;=&amp;#34;*&amp;#34;))), (NAME=address,TYPE(NAME=&amp;#39;MD5&amp;#39;)) )); 创建数据脱敏表 CREATE TABLE `t_mask` ( `id` int(11) NOT NULL, `user_id` varchar(45) DEFAULT NULL, `phone_number` varchar(45) DEFAULT NULL, `address` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 修改数据脱敏规则 ALTER MASK RULE t_mask ( COLUMNS( (NAME=user_id,TYPE(NAME=&amp;#39;MD5&amp;#39;)) )); 删除数据脱敏规则 DROP MASK RULE t_mask; 移除数据源 UNREGISTER STORAGE UNIT ds_0; 删除分布式数据库 DROP DATABASE mask_db; </description>
</item>
<item>
<title>算法配置</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/algorithm/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/algorithm/</guid>
<description>分片算法 ShardingRuleConfiguration ruleConfiguration = new ShardingRuleConfiguration(); // algorithmName 由用户指定,需要和分片策略中的分片算法一致 // type 和 props,请参考分片内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/sharding/ ruleConfiguration.getShardingAlgorithms().put(&amp;#34;algorithmName&amp;#34;, new AlgorithmConfiguration(&amp;#34;xxx&amp;#34;, new Properties())); 加密算法 // encryptorName 由用户指定,需要和加密规则中的 encryptorName 属性一致 // type 和 props,请参考加密内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/encrypt/ Map&amp;lt;String, AlgorithmConfiguration&amp;gt; algorithmConfigs = new HashMap&amp;lt;&amp;gt;(); algorithmConfigs.put(&amp;#34;encryptorName&amp;#34;, new AlgorithmConfiguration(&amp;#34;xxx&amp;#34;, new Properties())); 读写分离负载均衡算法 // loadBalancerName 由用户指定,需要和读写分离规则中的 loadBalancerName 属性一致 // type 和 props,请参考读写分离负载均衡内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/load-balance/ Map&amp;lt;String, AlgorithmConfiguration&amp;gt; algorithmConfigs = new HashMap&amp;lt;&amp;gt;(); algorithmConfigs.put(&amp;#34;loadBalancerName&amp;#34;, new AlgorithmConfiguration(&amp;#34;xxx&amp;#34;, new Properties())); 影子算法 // shadowAlgorithmName 由用户指定,需要和影子库规则中的 shadowAlgorithmNames 属性一致 // type 和 props,请参考影子库内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/shadow/ Map&amp;lt;String, AlgorithmConfiguration&amp;gt; algorithmConfigs = new HashMap&amp;lt;&amp;gt;(); algorithmConfigs.</description>
</item>
<item>
<title>算法配置</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/algorithm/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/algorithm/</guid>
<description>分片算法 shardingAlgorithms: # algorithmName 由用户指定,需要和分片策略中的 shardingAlgorithmName 属性一致 &amp;lt;algorithmName&amp;gt;: # type 和 props,请参考分片内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/sharding/ type: xxx props: xxx: xxx 加密算法 encryptors: # encryptorName 由用户指定,需要和加密规则中的 encryptorName 属性一致 &amp;lt;encryptorName&amp;gt;: # type 和 props,请参考加密内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/encrypt/ type: xxx props: xxx: xxx 读写分离负载均衡算法 loadBalancers: # loadBalancerName 由用户指定,需要和读写分离规则中的 loadBalancerName 属性一致 &amp;lt;loadBalancerName&amp;gt;: # type 和 props,请参考读写分离负载均衡内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/load-balance/ type: xxx props: xxx: xxx 影子算法 shadowAlgorithms: # shadowAlgorithmName 由用户指定,需要和影子库规则中的 shadowAlgorithmNames 属性一致 &amp;lt;shadowAlgorithmName&amp;gt;: # type 和 props,请参考影子库内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/common-config/builtin-algorithm/shadow/ type: xxx props: xxx: xxx 脱敏算法 maskAlgorithms: # maskAlgorithmName 由用户指定,需要和脱敏规则中的 maskAlgorithm 属性一致 &amp;lt;maskAlgorithmName&amp;gt;: # type 和 props,请参考脱敏内置算法:https://shardingsphere.</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>ALTER DEFAULT SHADOW ALGORITHM</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/alter-default-shadow-algorithm/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/alter-default-shadow-algorithm/</guid>
<description>描述 ALTER DEFAULT SHADOW ALGORITHM 语法用于修改影子库默认算法规则。
语法定义 语法 铁路图 AlterDefaultShadowAlgorithm ::= &amp;#39;ALTER&amp;#39; &amp;#39;DEFAULT&amp;#39; &amp;#39;SHADOW&amp;#39; &amp;#39;ALGORITHM&amp;#39; shadowAlgorithm shadowAlgorithm ::= &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; shadowAlgorithmType &amp;#39;,&amp;#39; propertiesDefiinition &amp;#39;)&amp;#39; shadowAlgorithmType ::= string propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; key ::= string value ::= literal 补充说明 shadowAlgorithmType 目前支持 VALUE_MATCH、REGEX_MATCH 和 SQL_HINT。 示例 修改默认影子库压测算法 ALTER DEFAULT SHADOW ALGORITHM TYPE(NAME=&amp;#34;SQL_HINT&amp;#34;); 保留字 ALTER、DEFAULT、SHADOW、ALGORITHM、TYPE、NAME、PROPERTIES</description>
</item>
<item>
<title>ALTER DEFAULT SHARDING STRATEGY</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/alter-default-sharding-strategy/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/alter-default-sharding-strategy/</guid>
<description>描述 ALTER DEFAULT SHARDING STRATEGY 语法用于修改默认的分片策略。
语法定义 语法 铁路图 AlterDefaultShardingStrategy ::= &amp;#39;ALTER&amp;#39; &amp;#39;DEFAULT&amp;#39; &amp;#39;SHARDING&amp;#39; (&amp;#39;DATABASE&amp;#39; | &amp;#39;TABLE&amp;#39;) &amp;#39;STRATEGY&amp;#39; &amp;#39;(&amp;#39; shardingStrategy &amp;#39;)&amp;#39; shardingStrategy ::= &amp;#39;TYPE&amp;#39; &amp;#39;=&amp;#39; strategyType &amp;#39;,&amp;#39; (&amp;#39;SHARDING_COLUMN&amp;#39; &amp;#39;=&amp;#39; columnName | &amp;#39;SHARDING_COLUMNS&amp;#39; &amp;#39;=&amp;#39; columnNames) &amp;#39;,&amp;#39; &amp;#39;SHARDING_ALGORITHM&amp;#39; &amp;#39;=&amp;#39; algorithmDefinition strategyType ::= string algorithmDefinition ::= &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; algorithmType &amp;#39;,&amp;#39; propertiesDefinition &amp;#39;)&amp;#39; columnNames ::= columnName (&amp;#39;,&amp;#39; columnName)+ columnName ::= identifier algorithmType ::= string propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; key ::= string value ::= literal 补充说明 当使用复合分片算法时,需要通过 SHARDING_COLUMNS 指定多个分片键; algorithmType 为分片算法类型,详细的分片算法类型信息请参考分片算法。 示例 修改默认分表策略 ALTER DEFAULT SHARDING TABLE STRATEGY ( TYPE=&amp;#34;standard&amp;#34;, SHARDING_COLUMN=user_id, SHARDING_ALGORITHM(TYPE(NAME=inline, PROPERTIES(&amp;#34;algorithm-expression&amp;#34;=&amp;#34;t_order_${user_id % 2}&amp;#34;))) ); 保留字 ALTER、DEFAULT、SHARDING、DATABASE、TABLE、STRATEGY、TYPE、SHARDING_COLUMN、SHARDING_COLUMNS、SHARDING_ALGORITHM、NAME、PROPERTIES</description>
</item>
<item>
<title>ALTER SQL_PARSER RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/alter-sql-parser-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/alter-sql-parser-rule/</guid>
<description>描述 ALTER SQL_PARSER RULE 语法用于修改解析引擎规则配置。
语法 语法 铁路图 AlterSqlParserRule ::= &amp;#39;ALTER&amp;#39; &amp;#39;SQL_PARSER&amp;#39; &amp;#39;RULE&amp;#39; &amp;#39;(&amp;#39; sqlParserRuleDefinition &amp;#39;)&amp;#39; sqlParserRuleDefinition ::= commentDefinition? (&amp;#39;,&amp;#39; parseTreeCacheDefinition)? (&amp;#39;,&amp;#39; sqlStatementCacheDefinition)? commentDefinition ::= &amp;#39;SQL_COMMENT_PARSE_ENABLED&amp;#39; &amp;#39;=&amp;#39; sqlCommentParseEnabled parseTreeCacheDefinition ::= &amp;#39;PARSE_TREE_CACHE&amp;#39; &amp;#39;(&amp;#39; cacheOption &amp;#39;)&amp;#39; sqlStatementCacheDefinition ::= &amp;#39;SQL_STATEMENT_CACHE&amp;#39; &amp;#39;(&amp;#39; cacheOption &amp;#39;)&amp;#39; sqlCommentParseEnabled ::= boolean cacheOption ::= (&amp;#39;INITIAL_CAPACITY&amp;#39; &amp;#39;=&amp;#39; initialCapacity)? (&amp;#39;,&amp;#39;? &amp;#39;MAXIMUM_SIZE&amp;#39; &amp;#39;=&amp;#39; maximumSize)? initialCapacity ::= int maximumSize ::= int 补充说明 SQL_COMMENT_PARSE_ENABLE:是否解析 SQL 注释</description>
</item>
<item>
<title>COUNT SHADOW RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow/count-shadow-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/shadow/count-shadow-rule/</guid>
<description>描述 COUNT SHADOW RULE 语法用于查询指定逻辑库中的影子库压测规则数量。
语法 语法 铁路图 CountShadowRule::= &amp;#39;COUNT&amp;#39; &amp;#39;SHADOW&amp;#39; &amp;#39;RULE&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 rule_name 规则类型 database 规则所属逻辑库 count 规则数量 示例 查询指定逻辑库中的影子库压测规则数量 COUNT SHADOW RULE FROM shadow_db; mysql&amp;gt; COUNT SHADOW RULE FROM shadow_db; +-----------+--------------+-------+ | rule_name | database | count | +-----------+--------------+-------+ | shadow | shadow_db | 1 | +-----------+--------------+-------+ 1 row in set (0.</description>
</item>
<item>
<title>LABEL|RELABEL COMPUTE NODE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/circuit-breaker/label-relabel-compute-node/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/circuit-breaker/label-relabel-compute-node/</guid>
<description>描述 LABEL|RELABEL COMPUTE NODE 语法用于为 PROXY 实例添加标签。
语法 语法 铁路图 LableRelabelComputeNodes ::= (&amp;#39;LABEL&amp;#39; | &amp;#39;RELABEL&amp;#39;) &amp;#39;COMPUTE&amp;#39; &amp;#39;NODE&amp;#39; instance_id &amp;#39;WITH&amp;#39; labelName instance_id ::= string labelName ::= identifier 补充说明 instance_id 需要通过 SHOW COMPUTE NODES 语法查询获得
RELABEL 用于为 PROXY 实例修改标签
示例 为 PROXY 实例添加标签 LABEL COMPUTE NODE &amp;#34;0699e636-ade9-4681-b37a-65240c584bb3&amp;#34; WITH label_1; 为 PROXY 实例修改标签 RELABEL COMPUTE NODE &amp;#34;0699e636-ade9-4681-b37a-65240c584bb3&amp;#34; WITH label_2; 保留字 LABEL、RELABEL、COMPUTE、NODE 、WITH</description>
</item>
<item>
<title>Narayana 事务</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/transaction/narayana/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/transaction/narayana/</guid>
<description>背景信息 Apache ShardingSphere 提供 XA 事务,集成了 Narayana 的实现。
前提条件 引入 Maven 依赖
&amp;lt;properties&amp;gt; &amp;lt;narayana.version&amp;gt;5.12.4.Final&amp;lt;/narayana.version&amp;gt; &amp;lt;jboss-transaction-spi.version&amp;gt;7.6.0.Final&amp;lt;/jboss-transaction-spi.version&amp;gt; &amp;lt;jboss-logging.version&amp;gt;3.2.1.Final&amp;lt;/jboss-logging.version&amp;gt; &amp;lt;/properties&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.apache.shardingsphere&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;shardingsphere-jdbc-core&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${shardingsphere.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; &amp;lt;!-- 使用 XA 事务时,需要引入此模块 --&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.apache.shardingsphere&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;shardingsphere-transaction-xa-core&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${shardingsphere.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.apache.shardingsphere&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;shardingsphere-transaction-xa-narayana&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${shardingsphere.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.jboss.narayana.jta&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;jta&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${narayana.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.jboss.narayana.jts&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;narayana-jts-integration&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${narayana.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.jboss&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;jboss-transaction-spi&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${jboss-transaction-spi.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.jboss.logging&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;jboss-logging&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${jboss-logging.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; 操作步骤 配置 Narayana 设置 XA 事务类型 配置示例 配置 Narayana 可以通过在项目的 classpath 中添加 jbossts-properties.</description>
</item>
<item>
<title>SHOW COMPUTE NODE MODE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-compute-node-mode/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-compute-node-mode/</guid>
<description>描述 SHOW COMPUTE NODE MODE 语法用于查询当前 proxy 的模式配置信息。
语法 语法 铁路图 ShowComputeNodeMode ::= &amp;#39;SHOW&amp;#39; &amp;#39;COMPUTE&amp;#39; &amp;#39;NODE&amp;#39; &amp;#39;MODE&amp;#39; 返回值说明 列 说明 type proxy 模式类型 repository proxy 持久化仓库类型 props proxy 持久化仓库属性参数 示例 查询当前 proxy 实例模式配置信息 SHOW COMPUTE NODE MODE; mysql&amp;gt; SHOW COMPUTE NODE MODE; +---------+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | type | repository | props | +---------+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Cluster | ZooKeeper | {&amp;#34;operationTimeoutMilliseconds&amp;#34;:500,&amp;#34;timeToLiveSeconds&amp;#34;:60,&amp;#34;maxRetries&amp;#34;:3,&amp;#34;namespace&amp;#34;:&amp;#34;governance_ds&amp;#34;,&amp;#34;server-lists&amp;#34;:&amp;#34;localhost:2181&amp;#34;,&amp;#34;retryIntervalMilliseconds&amp;#34;:500} | +---------+------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.</description>
</item>
<item>
<title>SHOW MIGRATION SOURCE STORAGE UNITS</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/show-migration-source-storage-units/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/show-migration-source-storage-units/</guid>
<description>描述 SHOW MIGRATION SOURCE STORAGE UNITS 语法用于查询已经注册的数据迁移源存储单元。
语法 语法 铁路图 ShowStorageUnit ::= &amp;#39;SHOW&amp;#39; &amp;#39;MIGRATION&amp;#39; &amp;#39;SOURCE&amp;#39; &amp;#39;STORAGE&amp;#39; &amp;#39;UNITS&amp;#39; 返回值说明 列 说明 name 存储单元名称 type 存储单元类型 host 存储单元地址 port 存储单元端口 db 数据库名称 attribute 存储单元参数 示例 查询指定逻辑库中未被使用的存储单元 SHOW MIGRATION SOURCE STORAGE UNITS; mysql&amp;gt; SHOW MIGRATION SOURCE STORAGE UNITS; +------+-------+-----------+------+----------------+---------------------------------+---------------------------+---------------------------+---------------+---------------+-----------+------------------+ | name | type | host | port | db | connection_timeout_milliseconds | idle_timeout_milliseconds | max_lifetime_milliseconds | max_pool_size | min_pool_size | read_only | other_attributes | +------+-------+-----------+------+----------------+---------------------------------+---------------------------+---------------------------+---------------+---------------+-----------+------------------+ | ds_1 | MySQL | 127.</description>
</item>
<item>
<title>SHOW SHARDING KEY GENERATORS</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-key-generator/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-key-generator/</guid>
<description>描述 SHOW SHARDING KEY GENERATORS 语法用于查询指定逻辑库的分布式主键生成器。
语法 语法 铁路图 ShowShardingKeyGenerators::= &amp;#39;SHOW&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;KEY&amp;#39; &amp;#39;GENERATORS&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 name 分布式主键生成器名称 type 分布式主键生成器类型 props 分布式主键生成器参数 示例 查询指定逻辑库的分布式主键生成器 SHOW SHARDING KEY GENERATORS FROM sharding_db; mysql&amp;gt; SHOW SHARDING KEY GENERATORS FROM sharding_db; +-------------------------+-----------+-------+ | name | type | props | +-------------------------+-----------+-------+ | snowflake_key_generator | snowflake | {} | +-------------------------+-----------+-------+ 1 row in set (0.</description>
</item>
<item>
<title>SQL 解析</title>
<link>https://shardingsphere.apache.org/document/current/cn/dev-manual/sql-parser/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/sql-parser/</guid>
<description>DatabaseTypedSQLParserFacade 全限定类名 org.apache.shardingsphere.sql.parser.spi.SQLDialectParserFacade
定义 配置用于 SQL 解析的词法分析器和语法分析器入口
已知实现 配置标识 详细说明 全限定类名 MySQL 基于 MySQL 的 SQL 解析器入口 org.apache.shardingsphere.sql.parser.mysql.parser.MySQLParserFacade PostgreSQL 基于 PostgreSQL 的 SQL 解析器入口 org.apache.shardingsphere.sql.parser.postgresql.parser.PostgreSQLParserFacade SQLServer 基于 SQLServer 的 SQL 解析器入口 org.apache.shardingsphere.sql.parser.sqlserver.parser.SQLServerParserFacade Oracle 基于 Oracle 的 SQL 解析器入口 org.apache.shardingsphere.sql.parser.oracle.parser.OracleParserFacade SQL92 基于 SQL92 的 SQL 解析器入口 org.apache.shardingsphere.sql.parser.sql92.parser.SQL92ParserFacade openGauss 基于 openGauss 的 SQL 解析器入口 org.apache.shardingsphere.sql.parser.opengauss.parser.OpenGaussParserFacade SQLVisitorFacade 全限定类名 org.</description>
</item>
<item>
<title>保留字</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/reserved-word/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/reserved-word/</guid>
<description>RDL 基础保留字 CREATE、ALTER、DROP、TABLE、RULE、TYPE、NAME、PROPERTIES、TRUE、FALSE、IF、NOT、EXISTS
储存单元定义 REGISTER、UNREGISTER、STORAGE、UNIT、HOST、PORT、DB、USER、PASSWORD、PROPERTIES、URL、IGNORE、SINGLE、TABLES
规则定义 分片 DEFAULT、SHARDING、BROADCAST、REFERENCE、DATABASE、STRATEGY、RULES、ALGORITHM 、DATANODES、DATABASE_STRATEGY、TABLE_STRATEGY、KEY_GENERATE_STRATEGY、RESOURCES、SHARDING_COLUMN、KEY 、GENERATOR、SHARDING_COLUMNS、KEY_GENERATOR、SHARDING_ALGORITHM、COLUMN、AUDIT_STRATEGY、AUDITORS 、ALLOW_HINT_DISABLE
单表 SET、DEFAULT、SINGLE、STORAGE、UNIT、RANDOM
读写分离 READWRITE_SPLITTING、WRITE_STORAGE_UNIT、READ_STORAGE_UNITS 、AUTO_AWARE_RESOURCE
数据加密 ENCRYPT、COLUMNS、CIPHER、ENCRYPT_ALGORITHM
数据库发现 DB_DISCOVERY、STORAGE_UNITS、HEARTBEAT
影子压测 SHADOW、DEFAULT、SOURCE、SHADOW
数据脱敏 MASK、COLUMNS
RQL 基础保留字 SHOW、COUNT、DEFAULT、RULE、RULES、TABLE、DATABASE、FROM、UNUSED、USED
储存单元查询 STORAGE、UNIT、UNITS
规则查询 分片 DEFAULT、SHARDING、BROADCAST、REFERENCE、STRATEGY、ALGORITHM、ALGORITHMS、AUDITORS 、KEY、GENERATOR、GENERATORS、AUDITOR、AUDITORS、NODES
单表 SINGLE、STORAGE、UNIT
读写分离 READWRITE_SPLITTING
数据加密 ENCRYPT
数据库发现 DB_DISCOVERY、TYPES、HEARTBEATS
影子压测 SHADOW、ALGORITHMS
数据脱敏 MASK
RAL ALTER、READWRITE_SPLITTING、RULE、RULES、FROM、ENABLE、DISABLE、SHOW、COMPUTE、NODES、NODE 、STATUS、LABEL、RELABEL、WITH、UNLABEL、AUTHORITY、TRANSACTION、SQL_PARSER、DEFAULT、TYPE 、NAME、PROPERTIES、SQL_COMMENT_PARSE_ENABLE、PARSE_TREE_CACHE、INITIAL_CAPACITY、MAXIMUM_SIZE 、CONCURRENCY_LEVEL、SQL_STATEMENT_CACHE、TRAFFIC、TRAFFIC_ALGORITHM、LOAD_BALANCER、CREATE 、DATABASE_VALUE、TABLE_VALUE、CLEAR、MIGRATION、READ、WRITE、WORKER_THREAD、BATCH_SIZE、SHARDING_SIZE 、STREAM_CHANNEL、REGISTER、URL、UNREGISTER、UNITS、INTO、LIST、CHECK、BY、STOP、START、ROLLBACK 、COMMIT、INFO、MODE、DIST、VARIABLE、VARIABLES、WHERE、DROPSET、SET、HINT、SOURCE、ADD 、SHARDING、STORAGE、UNIT、USER、PASSWORD、REFRESH、METADATA、TABLE、DATABASE、GOVERNANCE、CENTER 、EXPORT、CONFIGURATION、TO、FILE、IMPORT、USED
RUL PARSE、FORMAT、PREVIEW
补充说明 上述保留字大小写不敏感 </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/reference/sharding/merge/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/reference/sharding/merge/</guid>
<description>将从各个数据节点获取的多数据结果集,组合成为一个结果集并正确的返回至请求客户端,称为结果归并。
ShardingSphere 支持的结果归并从功能上分为遍历、排序、分组、分页和聚合 5 种类型,它们是组合而非互斥的关系。 从结构划分,可分为流式归并、内存归并和装饰者归并。流式归并和内存归并是互斥的,装饰者归并可以在流式归并和内存归并之上做进一步的处理。
由于从数据库中返回的结果集是逐条返回的,并不需要将所有的数据一次性加载至内存中,因此,在进行结果归并时,沿用数据库返回结果集的方式进行归并,能够极大减少内存的消耗,是归并方式的优先选择。
流式归并是指每一次从结果集中获取到的数据,都能够通过逐条获取的方式返回正确的单条数据,它与数据库原生的返回结果集的方式最为契合。遍历、排序以及流式分组都属于流式归并的一种。
内存归并则是需要将结果集的所有数据都遍历并存储在内存中,再通过统一的分组、排序以及聚合等计算之后,再将其封装成为逐条访问的数据结果集返回。
装饰者归并是对所有的结果集归并进行统一的功能增强,目前装饰者归并有分页归并和聚合归并这 2 种类型。
遍历归并 它是最为简单的归并方式。 只需将多个数据结果集合并为一个单向链表即可。在遍历完成链表中当前数据结果集之后,将链表元素后移一位,继续遍历下一个数据结果集即可。
排序归并 由于在 SQL 中存在 ORDER BY 语句,因此每个数据结果集自身是有序的,因此只需要将数据结果集当前游标指向的数据值进行排序即可。 这相当于对多个有序的数组进行排序,归并排序是最适合此场景的排序算法。
ShardingSphere 在对排序的查询进行归并时,将每个结果集的当前数据值进行比较(通过实现 Java 的 Comparable 接口完成),并将其放入优先级队列。 每次获取下一条数据时,只需将队列顶端结果集的游标下移,并根据新游标重新进入优先级排序队列找到自己的位置即可。
通过一个例子来说明 ShardingSphere 的排序归并,下图是一个通过分数进行排序的示例图。 图中展示了 3 张表返回的数据结果集,每个数据结果集已经根据分数排序完毕,但是 3 个数据结果集之间是无序的。 将 3 个数据结果集的当前游标指向的数据值进行排序,并放入优先级队列,t_score_0 的第一个数据值最大,t_score_2 的第一个数据值次之,t_score_1 的第一个数据值最小,因此优先级队列根据 t_score_0,t_score_2 和 t_score_1 的方式排序队列。
下图则展现了进行 next 调用的时候,排序归并是如何进行的。 通过图中我们可以看到,当进行第一次 next 调用时,排在队列首位的 t_score_0 将会被弹出队列,并且将当前游标指向的数据值(也就是 100)返回至查询客户端,并且将游标下移一位之后,重新放入优先级队列。 而优先级队列也会根据 t_score_0 的当前数据结果集指向游标的数据值(这里是 90)进行排序,根据当前数值,t_score_0 排列在队列的最后一位。 之前队列中排名第二的 t_score_2 的数据结果集则自动排在了队列首位。
在进行第二次 next 时,只需要将目前排列在队列首位的 t_score_2 弹出队列,并且将其数据结果集游标指向的值返回至客户端,并下移游标,继续加入队列排队,以此类推。 当一个结果集中已经没有数据了,则无需再次加入队列。</description>
</item>
<item>
<title>影子库压测</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/usage/shadow-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/usage/shadow-rule/</guid>
<description>存储单元操作 REGISTER STORAGE UNIT ds_0 ( HOST=&amp;#34;127.0.0.1&amp;#34;, PORT=3306, DB=&amp;#34;ds_0&amp;#34;, USER=&amp;#34;root&amp;#34;, PASSWORD=&amp;#34;root&amp;#34; ),ds_1 ( HOST=&amp;#34;127.0.0.1&amp;#34;, PORT=3306, DB=&amp;#34;ds_1&amp;#34;, USER=&amp;#34;root&amp;#34;, PASSWORD=&amp;#34;root&amp;#34; ),ds_2 ( HOST=&amp;#34;127.0.0.1&amp;#34;, PORT=3306, DB=&amp;#34;ds_2&amp;#34;, USER=&amp;#34;root&amp;#34;, PASSWORD=&amp;#34;root&amp;#34; ); 规则操作 创建影子库压测规则 CREATE SHADOW RULE group_0( SOURCE=ds_0, SHADOW=ds_1, t_order(TYPE(NAME=&amp;#34;SQL_HINT&amp;#34;),TYPE(NAME=&amp;#34;REGEX_MATCH&amp;#34;, PROPERTIES(&amp;#34;operation&amp;#34;=&amp;#34;insert&amp;#34;,&amp;#34;column&amp;#34;=&amp;#34;user_id&amp;#34;, &amp;#34;regex&amp;#34;=&amp;#39;[1]&amp;#39;))), t_order_item(TYPE(NAME=&amp;#34;SQL_HINT&amp;#34;))); 修改影子库压测规则 ALTER SHADOW RULE group_0( SOURCE=ds_0, SHADOW=ds_2, t_order_item(TYPE(NAME=&amp;#34;SQL_HINT&amp;#34;))); 删除影子库压测规则 DROP SHADOW RULE group_0; 移除数据源 UNREGISTER STORAGE UNIT ds_0,ds_1,ds_2; 删除分布式数据库 DROP DATABASE foo_db; </description>
</item>
<item>
<title>数据脱敏</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/mask/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/mask/</guid>
<description>背景信息 数据脱敏 Java API 规则配置允许用户直接通过编写 Java 代码的方式,完成 ShardingSphereDataSource 对象的创建,Java API 的配置方式非常灵活,不需要依赖额外的 jar 包 就能够集成各种类型的业务系统。
参数解释 配置入口 类名称:org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration
可配置属性:
名称 数据类型 说明 默认值 tables (+) Collection&amp;lt;MaskTableRuleConfiguration&amp;gt; 脱敏表规则配置 maskAlgorithms (+) Map&amp;lt;String, AlgorithmConfiguration&amp;gt; 脱敏算法名称和配置 脱敏表规则配置 类名称:org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration
可配置属性:
名称 数据类型 说明 name String 表名称 columns (+) Collection&amp;lt;MaskColumnRuleConfiguration&amp;gt; 脱敏列规则配置列表 脱敏列规则配置 类名称:org.</description>
</item>
<item>
<title>数据脱敏</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/mask/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/mask/</guid>
<description>背景信息 数据脱敏 YAML 配置方式良好的可读性,通过 YAML 格式,能够快速地理解脱敏规则之间的依赖关系,ShardingSphere 会根据 YAML 配置,自动完成 ShardingSphereDataSource 对象的创建,减少用户不必要的编码工作。
参数解释 rules: - !MASK tables: &amp;lt;table_name&amp;gt; (+): # 脱敏表名称 columns: &amp;lt;column_name&amp;gt; (+): # 脱敏列名称 maskAlgorithm: # 脱敏算法 # 脱敏算法配置 maskAlgorithms: &amp;lt;mask_algorithm_name&amp;gt; (+): # 脱敏算法名称 type: # 脱敏算法类型 props: # 脱敏算法属性配置 # ... 算法类型的详情,请参见内置脱敏算法列表。
操作步骤 在 YAML 文件中配置数据脱敏规则,包含数据源、脱敏规则、全局属性等配置项; 调用 YamlShardingSphereDataSourceFactory 对象的 createDataSource 方法,根据 YAML 文件中的配置信息创建 ShardingSphereDataSource。 配置示例 数据脱敏 YAML 配置如下:
dataSources: unique_ds: dataSourceClassName: com.zaxxer.hikari.HikariDataSource driverClassName: com.mysql.jdbc.Driver jdbcUrl: jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&amp;amp;useSSL=false&amp;amp;useUnicode=true&amp;amp;characterEncoding=UTF-8 username: root password: rules: - !</description>
</item>
<item>
<title>Bitronix 事务</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/transaction/bitronix/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/transaction/bitronix/</guid>
<description>背景信息 Apache ShardingSphere 提供 XA 事务,集成了 Bitronix 的实现。
前提条件 引入 Maven 依赖
&amp;lt;properties&amp;gt; &amp;lt;btm.version&amp;gt;2.1.3&amp;lt;/btm.version&amp;gt; &amp;lt;/properties&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.apache.shardingsphere&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;shardingsphere-jdbc-core&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${shardingsphere.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; &amp;lt;!-- 使用 XA 事务时,需要引入此模块 --&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.apache.shardingsphere&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;shardingsphere-transaction-xa-core&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${shardingsphere.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.apache.shardingsphere&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;shardingsphere-transaction-xa-bitronix&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${shardingsphere.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.codehaus.btm&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;btm&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${btm.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; 操作步骤 配置 XA 事务类型 配置 Bitronix 配置示例 配置 XA 事务类型 Yaml:
transaction: defaultType: XA providerType: Bitronix 配置 Bitronix (可省略) 详情请参见 Bitronix 官方文档 。</description>
</item>
<item>
<title>DROP DEFAULT SHADOW ALGORITHM</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/drop-default-shadow-algorithm/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/drop-default-shadow-algorithm/</guid>
<description>描述 DROP DEFAULT SHADOW ALGORITHM 语法用于为指定逻辑库删除默认影子库压测算法。
语法定义 语法 铁路图 DropDefaultShadowAlgorithm ::= &amp;#39;DROP&amp;#39; &amp;#39;DEFAULT&amp;#39; &amp;#39;SHADOW&amp;#39; &amp;#39;ALGORITHM&amp;#39; ifExists? (&amp;#39;FROM&amp;#39; databaseName)? ifExists ::= &amp;#39;IF&amp;#39; &amp;#39;EXISTS&amp;#39; databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected; ifExists 子句用于避免 Default shadow algorithm not exists 错误。 示例 为指定数据库删除默认影子库压测算法 DROP DEFAULT SHADOW ALGORITHM FROM shadow_db; 为当前数据库删除默认影子库压测算法 DROP DEFAULT SHADOW ALGORITHM; 使用 ifExists 子句删除默认影子库压测算法 DROP DEFAULT SHADOW ALGORITHM IF EXISTS; 保留字 DROP、DEFAULT、SHADOW、ALGORITHM、FROM</description>
</item>
<item>
<title>DROP DEFAULT SHARDING STRATEGY</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/drop-default-sharding-strategy/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/drop-default-sharding-strategy/</guid>
<description>描述 DROP DEFAULT SHARDING STRATEGY 语法用于删除指定逻辑库的默认分片策略。
语法定义 语法 铁路图 DropDefaultShardingStrategy ::= &amp;#39;DROP&amp;#39; &amp;#39;DEFAULT&amp;#39; &amp;#39;SHARDING&amp;#39; (&amp;#39;TABLE&amp;#39; | &amp;#39;DATABASE&amp;#39;) &amp;#39;STRATEGY&amp;#39; ifExists? (&amp;#39;FROM&amp;#39; databaseName)? ifExists ::= &amp;#39;IF&amp;#39; &amp;#39;EXISTS&amp;#39; databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected; ifExists 子句用于避免 Default sharding strategy not exists 错误。 示例 为指定逻辑库删除默认表分片策略 DROP DEFAULT SHARDING TABLE STRATEGY FROM sharding_db; 为当前逻辑库删除默认库分片策略 DROP DEFAULT SHARDING DATABASE STRATEGY; 使用 ifExists 子句删除默认表分片策略 DROP DEFAULT SHARDING TABLE STRATEGY IF EXISTS; 使用 ifExists 子句删除默认库分片策略 DROP DEFAULT SHARDING DATABASE STRATEGY IF EXISTS; 保留字 DROP、DEFAULT、SHARDING、TABLE、DATABASE、STRATEGY、FROM</description>
</item>
<item>
<title>MIGRATE TABLE INTO</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/migrate-table-into/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/migrate-table-into/</guid>
<description>描述 MIGRATE TABLE INTO 语法用于将表从源端迁移到目标端。
语法 语法 铁路图 MigrateTableInto ::= &amp;#39;MIGRATE&amp;#39; &amp;#39;TABLE&amp;#39; migrationSource &amp;#39;.&amp;#39; tableName &amp;#39;INTO&amp;#39; (databaseName &amp;#39;.&amp;#39;)? tableName migrationSource ::= identifier databaseName ::= identifier tableName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 示例 将表从源端迁移到当前逻辑库 MIGRATE TABLE ds_0.t_order INTO t_order; 将表从源端迁移到指定逻辑库 MIGRATE TABLE ds_0.t_order INTO sharding_db.t_order; 保留字 MIGRATE、TABLE、INTO
相关链接 保留字 </description>
</item>
<item>
<title>SET DIST VARIABLE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/set-dist-vairable/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/set-dist-vairable/</guid>
<description>描述 SET DIST VARIABLE 语法用于设置系统变量。
语法 语法 铁路图 SetDistVariable ::= &amp;#39;SET&amp;#39; &amp;#39;DIST&amp;#39; &amp;#39;VARIABLE&amp;#39; (proxyPropertyName &amp;#39;=&amp;#39; proxyPropertyValue | &amp;#39;agent_plugins_enabled&amp;#39; &amp;#39;=&amp;#39; agentPluginsEnabled) proxyPropertyName ::= identifier proxyPropertyValue ::= literal agentPluginsEnabled ::= boolean 补充说明 proxy_property_name 为 PROXY 的属性配置,需使用下划线命名
agent_plugins_enabled 为 agent 插件的启用状态,默认值 FALSE
system_log_level 为 系统日志等级,仅影响 PROXY 的日志打印,默认值 INFO
示例 设置 Proxy 属性配置 SET DIST VARIABLE sql_show = true; 设置 agent 插件启用状态 SET DIST VARIABLE agent_plugins_enabled = TRUE; 保留字 SET、DIST、VARIABLE</description>
</item>
<item>
<title>SHOW TRAFFIC RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/show-traffic-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/show-traffic-rule/</guid>
<description>描述 SHOW TRAFFIC RULE 语法用于查询指定的双路由规则。
语法 语法 铁路图 ShowTrafficRule ::= &amp;#39;SHOW&amp;#39; &amp;#39;TRAFFIC&amp;#39; (&amp;#39;RULES&amp;#39; | &amp;#39;RULE&amp;#39; ruleName)? ruleName ::= identifier 补充说明 未指定 ruleName 时,默认查询所有双路由规则 返回值说明 列 说明 name 双路由规则名称 labels 计算节点标签 algorithm_type 双路由算法类型 algorithm_props 双路由算法参数 load_balancer_type 负载均衡器类型 load_balancer_props 负载均衡器参数 示例 查询指定双路由规则 SHOW TRAFFIC RULE sql_match_traffic; mysql&amp;gt; SHOW TRAFFIC RULE sql_match_traffic; +-------------------+--------+----------------+--------------------------------------------------------------------------------+--------------------+---------------------+ | name | labels | algorithm_type | algorithm_props | load_balancer_type | load_balancer_props | +-------------------+--------+----------------+--------------------------------------------------------------------------------+--------------------+---------------------+ | sql_match_traffic | OLTP | SQL_MATCH | sql=SELECT * FROM t_order WHERE order_id = 1; UPDATE t_order SET order_id = 5; | RANDOM | | +-------------------+--------+----------------+--------------------------------------------------------------------------------+--------------------+---------------------+ 1 row in set (0.</description>
</item>
<item>
<title>SHOW UNUSED SHARDING KEY GENERATORS</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-unused-sharding-key-generators/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-unused-sharding-key-generators/</guid>
<description>描述 SHOW UNUSED SHARDING KEY GENERATORS 语法用于查询指定逻辑库中未被使用的分布式主键生成器。
语法 语法 铁路图 ShowUnusedShardingKeyGenerators::= &amp;#39;SHOW&amp;#39; &amp;#39;UNUSED&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;KEY&amp;#39; &amp;#39;GENERATOR&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 name 分布式主键生成器名称 type 分布式主键生成器类型 props 分布式主键生成器参数 示例 查询指定逻辑库中未被使用的分布式主键生成器 SHOW UNUSED SHARDING KEY GENERATORS FROM sharding_db; mysql&amp;gt; SHOW UNUSED SHARDING KEY GENERATORS FROM sharding_db; +-------------------------+-----------+-------+ | name | type | props | +-------------------------+-----------+-------+ | snowflake_key_generator | snowflake | | +-------------------------+-----------+-------+ 1 row in set (0.</description>
</item>
<item>
<title>UNLABEL COMPUTE NODE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/circuit-breaker/unlabel-compute-node/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/circuit-breaker/unlabel-compute-node/</guid>
<description>描述 UNLABEL COMPUTE NODE 语法用于为 PROXY 实例去除指定标签。
语法 语法 铁路图 UnlabelComputeNode ::= &amp;#39;UNLABEL&amp;#39; &amp;#39;COMPUTE&amp;#39; &amp;#39;NODE&amp;#39; instance_id &amp;#39;WITH&amp;#39; labelName instance_id ::= string labelName ::= identifier 补充说明 instance_id 需要通过 SHOW COMPUTE NODES 语法查询获得 示例 为 PROXY 实例去除指定标签 UNLABEL COMPUTE NODE &amp;#34;0699e636-ade9-4681-b37a-65240c584bb3&amp;#34; WITH label_1; 保留字 UNLABEL、COMPUTE、NODE、WITH
相关链接 保留字 SHOW COMPUTE NODES </description>
</item>
<item>
<title>不支持项</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/unsupported/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/unsupported/</guid>
<description>DataSource 接口 不支持 timeout 相关操作。 Connection 接口 不支持存储过程,函数,游标的操作; 不支持执行 native SQL; 不支持 savepoint 相关操作; 不支持 Schema/Catalog 的操作; 不支持自定义类型映射。 Statement 和 PreparedStatement 接口 不支持返回多结果集的语句(即存储过程,非 SELECT 多条数据); 不支持国际化字符的操作。 ResultSet 接口 不支持对于结果集指针位置判断; 不支持通过非 next 方法改变结果指针位置; 不支持修改结果集内容; 不支持获取国际化字符; 不支持获取 Array。 JDBC 4.1 不支持 JDBC 4.1 接口新功能。 查询所有未支持方法,请阅读 org.apache.shardingsphere.driver.jdbc.unsupported 包。</description>
</item>
<item>
<title>代理端</title>
<link>https://shardingsphere.apache.org/document/current/cn/dev-manual/proxy/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/proxy/</guid>
<description>DatabaseProtocolFrontendEngine 全限定类名 org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine
定义 用于 ShardingSphere-Proxy 解析与适配访问数据库的协议
已知实现 配置标识 详细说明 全限定类名 MySQL MySQL 协议实现 org.apache.shardingsphere.proxy.frontend.mysql.MySQLFrontendEngine PostgreSQL PostgreSQL 协议实现 org.apache.shardingsphere.proxy.frontend.postgresql.PostgreSQLFrontendEngine openGauss openGauss 协议实现 org.apache.shardingsphere.proxy.frontend.opengauss.OpenGaussFrontendEngine AuthorityProvide 全限定类名 org.apache.shardingsphere.authority.spi.AuthorityProvider
定义 用户权限加载逻辑
已知实现 配置标识 详细说明 全限定类名 ALL_PERMITTED 默认授予所有权限(不鉴权) org.apache.shardingsphere.authority.provider.simple.AllPermittedPrivilegesProvider DATABASE_PERMITTED 通过属性 user-database-mappings 配置的权限 org.apache.shardingsphere.authority.provider.database.DatabasePermittedPrivilegesProvider </description>
</item>
<item>
<title>影子库</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/shadow/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/shadow/</guid>
<description>背景信息 如果您只想使用 Java API 方式配置使用 ShardingSphere 影子库功能请参考以下配置。
参数解释 配置入口 类名称:org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration
可配置属性:
名称 数据类型 说明 dataSources Map&amp;lt;String, ShadowDataSourceConfiguration&amp;gt; 影子数据源映射名称和配置 tables Map&amp;lt;String, ShadowTableConfiguration&amp;gt; 影子表名称和配置 shadowAlgorithms Map&amp;lt;String, AlgorithmConfiguration&amp;gt; 影子算法名称和配置 defaultShadowAlgorithmName String 默认影子算法名称 影子数据源配置 类名称:org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration
可配置属性:
名称 数据类型 说明 productionDataSourceName String 生产数据源名称 shadowDataSourceName String 影子数据源名称 影子表配置 类名称:org.</description>
</item>
<item>
<title>影子库</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/shadow/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/shadow/</guid>
<description>背景信息 如果您想在 ShardingSphere-Proxy 中使用 ShardingSphere 影子库功能请参考以下配置。
参数解释 rules: - !SHADOW dataSources: shadowDataSource: productionDataSourceName: # 生产数据源名称 shadowDataSourceName: # 影子数据源名称 tables: &amp;lt;table_name&amp;gt;: dataSourceNames: # 影子表关联影子数据源名称列表 - &amp;lt;shadow_data_source&amp;gt; shadowAlgorithmNames: # 影子表关联影子算法名称列表 - &amp;lt;shadow_algorithm_name&amp;gt; defaultShadowAlgorithmName: # 默认影子算法名称(选配项) shadowAlgorithms: &amp;lt;shadow_algorithm_name&amp;gt; (+): # 影子算法名称 type: # 影子算法类型 props: # 影子算法属性配置 详情请参见内置影子算法列表
操作步骤 在 YAML 文件中配置影子库规则,包含数据源、影子库规则、全局属性等配置项; 调用 YamlShardingSphereDataSourceFactory 对象的 createDataSource 方法,根据 YAML 文件中的配置信息创建 ShardingSphereDataSource。 配置示例 dataSources: ds: url: jdbc:mysql://127.0.0.1:3306/ds?serverTimezone=UTC&amp;amp;useSSL=false username: root password: connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 minPoolSize: 1 shadow_ds: url: jdbc:mysql://127.</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>ALTER TRAFFIC RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/alter-traffic-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/global-rule/alter-traffic-rule/</guid>
<description>描述 ALTER TRAFFIC RULE 语法用于修改双路由规则。
语法定义 语法 铁路图 AlterTrafficRule ::= &amp;#39;ALTER&amp;#39; &amp;#39;TRAFFIC&amp;#39; &amp;#39;RULE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;LABELS&amp;#39; &amp;#39;(&amp;#39; lableName &amp;#39;)&amp;#39; &amp;#39;,&amp;#39; trafficAlgorithmDefinition &amp;#39;,&amp;#39; loadBalancerDefinition &amp;#39;)&amp;#39; lableName ::= identifier trafficAlgorithmDefinition ::= &amp;#39;TRAFFIC_ALGORITHM&amp;#39; &amp;#39;(&amp;#39; &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; trafficAlgorithmTypeName (&amp;#39;,&amp;#39; propertiesDefinition)? &amp;#39;)&amp;#39; &amp;#39;)&amp;#39; loadBalancerDefinition ::= &amp;#39;LOAD_BALANCER&amp;#39; &amp;#39;(&amp;#39; &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; loadBalancerName (&amp;#39;,&amp;#39; propertiesDefinition)? &amp;#39;)&amp;#39; &amp;#39;)&amp;#39; propertiesDefinition ::= &amp;#39;PROPERTIES&amp;#39; &amp;#39;(&amp;#39; key &amp;#39;=&amp;#39; value (&amp;#39;,&amp;#39; key &amp;#39;=&amp;#39; value)* &amp;#39;)&amp;#39; trafficAlgorithmTypeName ::= string loadBalancerTypeName ::= string key ::= string value ::= literal 补充说明 TRAFFIC_ALGORITHM 支持 SQL_MATCH 与 SQL_HINT 两种类型</description>
</item>
<item>
<title>DROP SHADOW ALGORITHM</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/drop-shadow-algorithm/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/shadow/drop-shadow-algorithm/</guid>
<description>描述 DROP SHADOW ALGORITHM 语法用于为指定逻辑库删除影子库压测算法。
语法定义 语法 铁路图 DropShadowAlgorithm ::= &amp;#39;DROP&amp;#39; &amp;#39;SHADOW&amp;#39; &amp;#39;ALGORITHM&amp;#39; ifExists? shadowAlgorithmName (&amp;#39;,&amp;#39; shadowAlgorithmName)* (&amp;#39;FROM&amp;#39; databaseName)? ifExists ::= &amp;#39;IF&amp;#39; &amp;#39;EXISTS&amp;#39; shadowAlgorithmName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected; ifExists 子句用于避免 shadow algorithm not exists 错误。 示例 为指定数据库删除多个影子库压测算法 DROP SHADOW ALGORITHM shadow_rule_t_order_sql_hint_0, shadow_rule_t_order_item_sql_hint_0 FROM shadow_db; 为当前数据库删除单个影子库压测算法 DROP SHADOW ALGORITHM shadow_rule_t_order_sql_hint_0; 使用 ifExists 子句删除影子库压测算法 DROP SHADOW ALGORITHM IF EXISTS shadow_rule_t_order_sql_hint_0; 保留字 DROP、SHADOW、ALGORITHM、FROM</description>
</item>
<item>
<title>Seata 事务</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/transaction/seata/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/transaction/seata/</guid>
<description>背景信息 Apache ShardingSphere 提供 BASE 事务,集成了 Seata 的实现。
操作步骤 启动 Seata Server 创建日志表 添加 Seata 配置 配置示例 启动 Seata Server 按照 seata-work-shop 中的步骤,下载并启动 Seata 服务器。
创建 undo_log 表 在每一个分片数据库实例中执创建 undo_log 表(以 MySQL 为例)。
CREATE TABLE IF NOT EXISTS `undo_log` ( `id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT &amp;#39;increment id&amp;#39;, `branch_id` BIGINT(20) NOT NULL COMMENT &amp;#39;branch transaction id&amp;#39;, `xid` VARCHAR(100) NOT NULL COMMENT &amp;#39;global transaction id&amp;#39;, `context` VARCHAR(128) NOT NULL COMMENT &amp;#39;undo_log context,such as serialization&amp;#39;, `rollback_info` LONGBLOB NOT NULL COMMENT &amp;#39;rollback info&amp;#39;, `log_status` INT(11) NOT NULL COMMENT &amp;#39;0:normal status,1:defense status&amp;#39;, `log_created` DATETIME NOT NULL COMMENT &amp;#39;create datetime&amp;#39;, `log_modified` DATETIME NOT NULL COMMENT &amp;#39;modify datetime&amp;#39;, PRIMARY KEY (`id`), UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`) ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8 COMMENT =&amp;#39;AT transaction mode undo table&amp;#39;; 修改配置 在 classpath 中增加 seata.</description>
</item>
<item>
<title>SHOW DIST VARIABLE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-dist-variable/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-dist-variable/</guid>
<description>描述 SHOW DIST VARIABLE 语法用于查询 PROXY 系统变量配置。
语法 语法 铁路图 ShowDistVariable ::= &amp;#39;SHOW&amp;#39; &amp;#39;DIST&amp;#39; (&amp;#39;VARIABLES&amp;#39; (&amp;#39;LIKE&amp;#39; likePattern)?| &amp;#39;VARIABLE&amp;#39; &amp;#39;WHERE&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; variableName) likePattern ::= string variableName ::= identifier 返回值说明 列 说明 variable_name 系统变量名称 variable_value 系统变量值 补充说明 未指定 vairableName 时,默认查询所有 PROXY 系统变量配置 示例 查询所有 PROXY 系统变量配置 SHOW DIST VARIABLES; mysql&amp;gt; SHOW DIST VARIABLES; +---------------------------------------+-----------------+ | variable_name | variable_value | +---------------------------------------+-----------------+ | agent_plugins_enabled | true | | cached_connections | 0 | | cdc_server_port | 33071 | | check_table_metadata_enabled | false | | kernel_executor_size | 0 | | max_connections_size_per_query | 1 | | proxy_backend_query_fetch_size | -1 | | proxy_default_port | 3307 | | proxy_frontend_database_protocol_type | | | proxy_frontend_executor_size | 0 | | proxy_frontend_flush_threshold | 128 | | proxy_frontend_max_connections | 0 | | proxy_frontend_ssl_cipher | | | proxy_frontend_ssl_enabled | false | | proxy_frontend_ssl_version | TLSv1.</description>
</item>
<item>
<title>SHOW MIGRATION LIST</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/show-migration-list/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/show-migration-list/</guid>
<description>描述 SHOW MIGRATION LIST 语法用于查询数据迁移作业列表。
语法 语法 铁路图 ShowMigrationList ::= &amp;#39;SHOW&amp;#39; &amp;#39;MIGRATION&amp;#39; &amp;#39;LIST&amp;#39; 返回值说明 列 说明 id 数据迁移作业ID tables 迁移表 job_item_count 数据迁移作业分片数量 active 数据迁移作业状态 create_time 数据迁移作业创建时间 stop_time 数据迁移作业停止时间 示例 查询数据迁移作业列表 SHOW MIGRATION LIST; mysql&amp;gt; SHOW MIGRATION LIST; +---------------------------------------+---------+----------------+--------+---------------------+---------------------+ | id | tables | job_item_count | active | create_time | stop_time | +---------------------------------------+---------+----------------+--------+---------------------+---------------------+ | j01013a38b0184e07c864627b5bb05da09ee0 | t_order | 1 | false | 2022-10-31 18:18:24 | 2022-10-31 18:18:31 | +---------------------------------------+---------+----------------+--------+---------------------+---------------------+ 1 row in set (0.</description>
</item>
<item>
<title>SHOW SHARDING AUDITORS</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-auditors/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-auditors/</guid>
<description>描述 SHOW SHARDING AUDITORS 语法用于查询指定逻辑库中的分片审计器。
语法 语法 铁路图 ShowShardingAuditors::= &amp;#39;SHOW&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;AUDITORS&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 name 分片审计器名称 type 分片审计算法类型 props 分片审计算法参数 示例 查询指定逻辑库中的分片审计器 SHOW SHARDING AUDITORS FROM sharding_db; mysql&amp;gt; SHOW SHARDING AUDITORS FROM sharding_db; +-------------------------------+-------------------------+-------+ | name | type | props | +-------------------------------+-------------------------+-------+ | sharding_key_required_auditor | dml_sharding_conditions | {} | +-------------------------------+-------------------------+-------+ 1 row in set (0.</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>SQL 解析</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/sql-parser/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/sql-parser/</guid>
<description>背景信息 SQL 是使用者与数据库交流的标准语言。 SQL 解析引擎负责将 SQL 字符串解析为抽象语法树,供 Apache ShardingSphere 理解并实现其增量功能。 目前支持 MySQL, PostgreSQL, SQLServer, Oracle, openGauss 以及符合 SQL92 规范的 SQL 方言。 由于 SQL 语法的复杂性,目前仍然存在少量不支持的 SQL。 通过 Java API 形式使用 SQL 解析,可以方便得集成进入各种系统,灵活定制用户需求。
参数解释 类名称:org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration
可配置属性:
名称 数据类型 说明 sqlCommentParseEnabled (?) boolean 是否解析 SQL 注释 parseTreeCache (?) CacheOption 解析语法树本地缓存配置 sqlStatementCache (?) CacheOption SQL 语句本地缓存配置 本地缓存配置 类名称:org.apache.shardingsphere.sql.parser.api.CacheOption
可配置属性:
名称 数据类型 说明 默认值 initialCapacity int 本地缓存初始容量 语法树本地缓存默认值 128,SQL 语句缓存默认值 2000 maximumSize long 本地缓存最大容量 语法树本地缓存默认值 1024,SQL 语句缓存默认值 65535 操作步骤 设置本地缓存配置 设置解析配置 使用解析引擎解析 SQL 配置示例 CacheOption cacheOption = new CacheOption(128, 1024L); SQLParserEngine parserEngine = new SQLParserEngine(&amp;#34;MySQL&amp;#34;, cacheOption); ParseASTNode parseASTNode = parserEngine.</description>
</item>
<item>
<title>SQL 解析</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/sql-parser/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/sql-parser/</guid>
<description>背景信息 SQL 解析 YAML 配置方式具有可读性高,使用简单的特点。通过 YAML 文件的方式,用户可以将代码与配置分离,并且根据需要方便地修改配置文件。
参数解释 sqlParser: sqlCommentParseEnabled: # 是否解析 SQL 注释 sqlStatementCache: # SQL 语句本地缓存配置项 initialCapacity: # 本地缓存初始容量 maximumSize: # 本地缓存最大容量 parseTreeCache: # 解析树本地缓存配置项 initialCapacity: # 本地缓存初始容量 maximumSize: # 本地缓存最大容量 操作步骤 设置本地缓存配置 设置解析配置 使用解析引擎解析 SQL 配置示例 sqlParser: sqlCommentParseEnabled: true sqlStatementCache: initialCapacity: 2000 maximumSize: 65535 parseTreeCache: initialCapacity: 128 maximumSize: 1024 相关参考 JAVA API:SQL 解析 </description>
</item>
<item>
<title>数据分片</title>
<link>https://shardingsphere.apache.org/document/current/cn/dev-manual/sharding/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/sharding/</guid>
<description>ShardingAlgorithm 全限定类名 org.apache.shardingsphere.sharding.spi.ShardingAlgorithm
定义 分片算法
已知实现 配置标识 自动分片算法 详细说明 全限定类名 MOD Y 基于取模的分片算法 org.apache.shardingsphere.sharding.algorithm.sharding.mod.ModShardingAlgorithm HASH_MOD Y 基于哈希取模的分片算法 org.apache.shardingsphere.sharding.algorithm.sharding.mod.HashModShardingAlgorithm BOUNDARY_RANGE Y 基于分片边界的范围分片算法 org.apache.shardingsphere.sharding.algorithm.sharding.range.BoundaryBasedRangeShardingAlgorithm VOLUME_RANGE Y 基于分片容量的范围分片算法 org.apache.shardingsphere.sharding.algorithm.sharding.range.VolumeBasedRangeShardingAlgorithm AUTO_INTERVAL Y 基于可变时间范围的分片算法 org.apache.shardingsphere.sharding.algorithm.sharding.datetime.AutoIntervalShardingAlgorithm INTERVAL N 基于固定时间范围的分片算法 org.apache.shardingsphere.sharding.algorithm.sharding.datetime.IntervalShardingAlgorithm CLASS_BASED N 基于自定义类的分片算法 org.apache.shardingsphere.sharding.algorithm.sharding.classbased.ClassBasedShardingAlgorithm INLINE N 基于行表达式的分片算法 org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm COMPLEX_INLINE N 基于行表达式的复合分片算法 org.apache.shardingsphere.sharding.algorithm.sharding.complex.ComplexInlineShardingAlgorithm HINT_INLINE N 基于行表达式的 Hint 分片算法 org.</description>
</item>
<item>
<title>REFRESH TABLE METADATA</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/refresh-table-metadata/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/refresh-table-metadata/</guid>
<description>描述 REFRESH TABLE METADATA 语法用于刷新表元数据。
语法 语法 铁路图 RefreshTableMetadata ::= &amp;#39;REFRESH&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;METADATA&amp;#39; (tableName | tableName &amp;#39;FROM&amp;#39; &amp;#39;STORAGE&amp;#39; &amp;#39;UNIT&amp;#39; storageUnitName (&amp;#39;SCHEMA&amp;#39; schemaName)?)? tableName ::= identifier storageUnitName ::= identifier schemaName ::= identifier 补充说明 未指定 tableName 和 storageUnitName 时,默认刷新所有表的元数据;
刷新元数据需要使用 DATABASE 如果未使用 DATABASE 则会提示 No database selected;
如果 SCHEMA 中不存在表,则会删除该 SCHEMA。
示例 刷新指定存储单元中指定 SCHEMA 中指定表的元数据 REFRESH TABLE METADATA t_order FROM STORAGE UNIT ds_1 SCHEMA db_schema; 刷新指定存储单元中指定 SCHEMA 中所有表的元数据 REFRESH TABLE METADATA FROM STORAGE UNIT ds_1 SCHEMA db_schema; 刷新指定存储单元中指定表的元数据 REFRESH TABLE METADATA t_order FROM STORAGE UNIT ds_1; 刷新指定表的元数据 REFRESH TABLE METADATA t_order; 刷新所有表的元数据 REFRESH TABLE METADATA; 保留字 REFRESH、TABLE、METADATA、FROM、STORAGE、UNIT</description>
</item>
<item>
<title>SHOW MIGRATION STATUS</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/show-migration-status/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/show-migration-status/</guid>
<description>描述 SHOW MIGRATION STATUS 语法用于查询指定数据迁移作业的详细情况。
语法 语法 铁路图 ShowMigrationStatus ::= &amp;#39;SHOW&amp;#39; &amp;#39;MIGRATION&amp;#39; &amp;#39;STATUS&amp;#39; migrationJobId migrationJobId ::= string 补充说明 migrationJobId 需要通过 SHOW MIGRATION LIST 语法查询获得 返回值说明 列 说明 item 数据迁移作业分片编号 data source 数据迁移源 status 数据迁移作业状态 processed_records_count 处理数据行数 inventory_finished_percentage 数据迁移作业完成度 incremental_idle_seconds 增量闲置时间 error_message 错误信息提示 示例 查询指定数据迁移作业的详细情况 SHOW MIGRATION STATUS &amp;#39;j010180026753ef0e25d3932d94d1673ba551&amp;#39;; mysql&amp;gt; SHOW MIGRATION STATUS &amp;#39;j010180026753ef0e25d3932d94d1673ba551&amp;#39;; +------+-------------+--------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+ | item | data_source | status | active | processed_records_count | inventory_finished_percentage | incremental_idle_seconds | error_message | +------+-------------+--------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+ | 0 | ds_1 | EXECUTE_INCREMENTAL_TASK | true | 6 | 100 | 25 | | +------+-------------+--------------------------+--------+-------------------------+-------------------------------+--------------------------+---------------+ 1 row in set (0.</description>
</item>
<item>
<title>SHOW UNUSED SHARDING AUDITORS</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-unused-sharding-auditors/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-unused-sharding-auditors/</guid>
<description>描述 SHOW UNUSED SHARDING AUDITORS 语法用于查询指定逻辑库中未被使用的分片审计器。
语法 语法 铁路图 ShowUnusedShardingAuditors::= &amp;#39;SHOW&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;AUDITOR&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 name 分片审计器名称 type 分片审计算法类型 props 分片审计算法参数 示例 查询指定逻辑库中未被使用的分片审计器 SHOW UNUSED SHARDING AUDITORS FROM sharding_db; mysql&amp;gt; SHOW UNUSED SHARDING AUDITORS FROM sharding_db; +-------------------------------+-------------------------+-------+ | name | type | props | +-------------------------------+-------------------------+-------+ | sharding_key_required_auditor | dml_sharding_conditions | {} | +-------------------------------+-------------------------+-------+ 1 row in set (0.</description>
</item>
<item>
<title>SQL 翻译</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/sql-translator/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/sql-translator/</guid>
<description>配置入口 类名称:org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration
可配置属性:
名称 数据类型 说明 type String SQL 翻译器类型 useOriginalSQLWhenTranslatingFailed (?) boolean SQL 翻译失败是否使用原始 SQL 继续执行 </description>
</item>
<item>
<title>SQL 翻译</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/sql-translator/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/sql-translator/</guid>
<description>配置项说明 sqlTranslator: type: # SQL 翻译器类型 useOriginalSQLWhenTranslatingFailed: # SQL 翻译失败是否使用原始 SQL 继续执行 </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/dev-manual/readwrite-splitting/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/readwrite-splitting/</guid>
<description>ReadQueryLoadBalanceAlgorithm 全限定类名 org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm
定义 读库负载均衡算法
已知实现 配置标识 详细说明 全限定类名 ROUND_ROBIN 基于轮询的读库负载均衡算法 org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance.RoundRobinReadQueryLoadBalanceAlgorithm RANDOM 基于随机的读库负载均衡算法 org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance.RandomReadQueryLoadBalanceAlgorithm WEIGHT 基于权重的读库负载均衡算法 org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance.WeightReadQueryLoadBalanceAlgorithm </description>
</item>
<item>
<title>REFRESH DATABASE METADATA FROM GOVERNANCE CENTER</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/refresh-database-metadata/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/refresh-database-metadata/</guid>
<description>描述 REFRESH DATABASE METADATA FROM GOVERNANCE CENTER 语法用于从治理中心拉取最新配置,刷新本地逻辑库元数据。
语法 语法 铁路图 RefreshDatabaseMetadataFromGovernanceCenter ::= &amp;#39;REFRESH&amp;#39; &amp;#39;DATABASE&amp;#39; &amp;#39;METADATA&amp;#39; databaseName? &amp;#39;FROM&amp;#39; &amp;#39;GOVERNANCE&amp;#39; &amp;#39;CENTER&amp;#39; databaseName ::= identifier 补充说明 未指定 databaseName 时,默认刷新所有逻辑库的元数据
刷新元数据需要使用 DATABASE 如果未使用 DATABASE 则会提示 No database selected
示例 刷新指定逻辑库的元数据 REFRESH DATABASE METADATA sharding_db FROM GOVERNANCE CENTER; 刷新所有逻辑库的元数据 REFRESH DATABASE METADATA FROM GOVERNANCE CENTER; 保留字 REFRESH、DATABASE、METADATA、FROM、GOVERNANCE、CENTER</description>
</item>
<item>
<title>SHOW MIGRATION CHECK ALGORITHM</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/show-migration-check-algorithm/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/show-migration-check-algorithm/</guid>
<description>描述 SHOW MIGRATION CHECK ALGORITHM 语法用于查询数据迁移一致性校验算法。
语法 语法 铁路图 ShowMigrationCheckAlgorithm ::= &amp;#39;SHOW&amp;#39; &amp;#39;MIGRATION&amp;#39; &amp;#39;CHECK&amp;#39; &amp;#39;ALGORITHMS&amp;#39; 返回值说明 列 说明 type 一致性校验算法类型 supported_database_types 支持数据库类型 description 说明 示例 查询数据迁移一致性校验算法 SHOW MIGRATION CHECK ALGORITHMS; mysql&amp;gt; SHOW MIGRATION CHECK ALGORITHMS; +-------------+--------------------------------------------------------------+----------------------------+ | type | supported_database_types | description | +-------------+--------------------------------------------------------------+----------------------------+ | CRC32_MATCH | MySQL | Match CRC32 of records.</description>
</item>
<item>
<title>SHOW SHARDING TABLE NODES</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-table-nodes/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-table-nodes/</guid>
<description>描述 SHOW SHARDING TABLE NODES 语法用于查询指定逻辑库中的指定分片表的节点分布。
语法 语法 铁路图 ShowShardingTableNode::= &amp;#39;SHOW&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;NODES&amp;#39; tableName? (&amp;#39;FROM&amp;#39; databaseName)? tableName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 name 分片规则名称 nodes 分片节点 示例 查询指定逻辑库中指定分片表的节点分布 SHOW SHARDING TABLE NODES t_order_item FROM sharding_db; mysql&amp;gt; SHOW SHARDING TABLE NODES t_order_item FROM sharding_db; +--------------+------------------------------------------------------------------------------------------------------------+ | name | nodes | +--------------+------------------------------------------------------------------------------------------------------------+ | t_order_item | resource_0.</description>
</item>
<item>
<title>分布式事务</title>
<link>https://shardingsphere.apache.org/document/current/cn/dev-manual/transaction/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/transaction/</guid>
<description>ShardingSphereTransactionManager 全限定类名 org.apache.shardingsphere.transaction.spi.ShardingSphereTransactionManager
定义 分布式事务管理器
已知实现 配置标识 详细说明 全限定类名 XA 基于 XA 的分布式事务管理器 org.apache.shardingsphere.transaction.xa.XAShardingSphereTransactionManager BASE 基于 Seata 的分布式事务管理器 org.apache.shardingsphere.transaction.base.seata.at.SeataATShardingSphereTransactionManager XATransactionManagerProvider 全限定类名 org.apache.shardingsphere.transaction.xa.spi.XATransactionManagerProvider
定义 XA 分布式事务管理器
已知实现 配置标识 详细说明 全限定类名 Atomikos 基于 Atomikos 的 XA 分布式事务管理器 org.apache.shardingsphere.transaction.xa.atomikos.manager.AtomikosTransactionManagerProvider | Narayana 基于 Narayana 的 XA 分布式事务管理器 org.apache.shardingsphere.transaction.xa.narayana.manager.NarayanaXATransactionManagerProvider | Bitronix 基于 Bitronix 的 XA 分布式事务管理器 org.</description>
</item>
<item>
<title>混合规则</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/mix/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/java-api/rules/mix/</guid>
<description>背景信息 ShardingSphere 涵盖了很多功能,例如,分库分片、读写分离、数据加密等。这些功能用户可以单独进行使用,也可以配合一起使用,下面是基于 JAVA API 的配置示例。
配置示例 // 分片配置 private ShardingRuleConfiguration createShardingRuleConfiguration() { ShardingRuleConfiguration result = new ShardingRuleConfiguration(); result.getTables().add(getOrderTableRuleConfiguration()); result.setDefaultDatabaseShardingStrategy(new StandardShardingStrategyConfiguration(&amp;#34;user_id&amp;#34;, &amp;#34;inline&amp;#34;)); result.setDefaultTableShardingStrategy(new StandardShardingStrategyConfiguration(&amp;#34;order_id&amp;#34;, &amp;#34;standard_test_tbl&amp;#34;)); Properties props = new Properties(); props.setProperty(&amp;#34;algorithm-expression&amp;#34;, &amp;#34;demo_ds_${user_id % 2}&amp;#34;); result.getShardingAlgorithms().put(&amp;#34;inline&amp;#34;, new AlgorithmConfiguration(&amp;#34;INLINE&amp;#34;, props)); result.getShardingAlgorithms().put(&amp;#34;standard_test_tbl&amp;#34;, new AlgorithmConfiguration(&amp;#34;STANDARD_TEST_TBL&amp;#34;, new Properties())); result.getKeyGenerators().put(&amp;#34;snowflake&amp;#34;, new AlgorithmConfiguration(&amp;#34;SNOWFLAKE&amp;#34;, new Properties())); return result; } private ShardingTableRuleConfiguration getOrderTableRuleConfiguration() { ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration(&amp;#34;t_order&amp;#34;, &amp;#34;demo_ds_${0..1}.t_order_${[0, 1]}&amp;#34;); result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration(&amp;#34;order_id&amp;#34;, &amp;#34;snowflake&amp;#34;)); return result; } // 读写分离配置 private static ReadwriteSplittingRuleConfiguration createReadwriteSplittingConfiguration() { ReadwriteSplittingDataSourceRuleConfiguration dataSourceConfiguration1 = new ReadwriteSplittingDataSourceRuleConfiguration(&amp;#34;replica_ds_0&amp;#34;, Arrays.</description>
</item>
<item>
<title>混合规则</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/mix/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/mix/</guid>
<description>背景信息 ShardingSphere 涵盖了很多功能,例如,分库分片、读写分离、数据加密等。这些功能用户可以单独进行使用,也可以配合一起使用,下面是基于 YAML 的参数解释和配置示例。
参数解释 rules: - !SHARDING tables: &amp;lt;logic_table_name&amp;gt;: # 逻辑表名称: actualDataNodes: # 由逻辑数据源名 + 表名组成(参考 Inline 语法规则) tableStrategy: # 分表策略,同分库策略 standard: shardingColumn: # 分片列名称 shardingAlgorithmName: # 分片算法名称 keyGenerateStrategy: column: # 自增列名称,缺省表示不使用自增主键生成器 keyGeneratorName: # 分布式序列算法名称 defaultDatabaseStrategy: standard: shardingColumn: # 分片列名称 shardingAlgorithmName: # 分片算法名称 shardingAlgorithms: &amp;lt;sharding_algorithm_name&amp;gt;: # 分片算法名称 type: INLINE props: algorithm-expression: # INLINE 表达式 t_order_inline: type: INLINE props: algorithm-expression: # INLINE 表达式 keyGenerators: &amp;lt;key_generate_algorithm_name&amp;gt; (+): # 分布式序列算法名称 type: # 分布式序列算法类型 props: # 分布式序列算法属性配置 - !</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>
<item>
<title>CHECK MIGRATION BY</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/check-migration/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/check-migration/</guid>
<description>描述 CHECK MIGRATION BY 语法用于校验数据迁移作业中的数据一致性。
语法 语法 铁路图 ShowMigrationList ::= &amp;#39;CHECK&amp;#39; &amp;#39;MIGRATION&amp;#39; migrationJobId &amp;#39;BY&amp;#39; &amp;#39;TYPE&amp;#39; &amp;#39;(&amp;#39; &amp;#39;NAME&amp;#39; &amp;#39;=&amp;#39; migrationCheckAlgorithmType &amp;#39;)&amp;#39; migrationJobId ::= string migrationCheckAlgorithmType ::= string 补充说明 migrationJobId 需要通过 SHOW MIGRATION LIST 语法查询获得
migrationCheckAlgorithmType 需要通过 SHOW MIGRATION CHECK ALGORITHMS 语法查询获得
示例 校验数据迁移作业中数据一致性 CHECK MIGRATION &amp;#39;j01016e501b498ed1bdb2c373a2e85e2529a6&amp;#39; BY TYPE (NAME=&amp;#39;CRC32_MATCH&amp;#39;); 保留字 CHECK、MIGRATION、BY、TYPE
相关链接 保留字 SHOW MIGRATION LIST SHOW MIGRATION CHECK ALGORITHMS </description>
</item>
<item>
<title>DROP SHARDING KEY GENERATOR</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/drop-sharding-key-generator/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/drop-sharding-key-generator/</guid>
<description>描述 DROP SHARDING KEY GENERATOR 语法用于删除指定逻辑库的指定分片主键生成器。
语法定义 语法 铁路图 DropShardingKeyGenerator ::= &amp;#39;DROP&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;KEY&amp;#39; &amp;#39;GENERATOR&amp;#39; ifExists? keyGeneratorName (keyGeneratorName)* (&amp;#39;FROM&amp;#39; databaseName)? ifExists ::= &amp;#39;IF&amp;#39; &amp;#39;EXISTS&amp;#39; keyGeneratorName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected; ifExists 子句用于避免 Sharding key generator not exists 错误。 示例 删除指定逻辑库的指定分片主键生成器 DROP SHARDING KEY GENERATOR t_order_snowflake FROM sharding_db; 删除当前逻辑库的指定分片主键生成器 DROP SHARDING KEY GENERATOR t_order_snowflake; 使用 ifExists 子句删除分片主键生成器 DROP SHARDING KEY GENERATOR IF EXISTS t_order_snowflake; 保留字 DROP、SHARDING、KEY、GENERATOR、FROM</description>
</item>
<item>
<title>SHOW SHARDING TABLE RULES USED ALGORITHM</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-table-rules-used-algorithm/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-table-rules-used-algorithm/</guid>
<description>描述 SHOW SHARDING TABLE RULES USED ALGORITHM 语法用于查询指定逻辑库中使用指定分片算法的分片规则。
语法 语法 铁路图 ShowShardingTableRulesUsedAlgorithm::= &amp;#39;SHOW&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;RULES&amp;#39; &amp;#39;USED&amp;#39; &amp;#39;ALGORITHM&amp;#39; algorithmName (&amp;#39;FROM&amp;#39; databaseName)? algorithmName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 type 分片规则类型 name 分片规则名称 示例 查询指定逻辑库中使用指定分片算法的分片规则 SHOW SHARDING TABLE RULES USED ALGORITHM table_inline FROM sharding_db; mysql&amp;gt; SHOW SHARDING TABLE RULES USED ALGORITHM table_inline FROM sharding_db; +-------+--------------+ | type | name | +-------+--------------+ | table | t_order_item | +-------+--------------+ 1 row in set (0.</description>
</item>
<item>
<title>SHOW TABLE METADATA</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-table-metadata/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-table-metadata/</guid>
<description>描述 SHOW TABLE METADATA 语法用于查询表的元数据。
语法 语法 铁路图 ShowTableMetadata ::= &amp;#39;SHOW&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;METADATA&amp;#39; tableName (&amp;#39;,&amp;#39; tableName)* (&amp;#39;FROM&amp;#39; databaseName)? tableName ::= identifier databaseName ::= identifier 返回值说明 列 说明 schema_name 逻辑库名称 table_name 表名称 type 元数据类型 name 元数据名称 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 示例 查询指定逻辑库中多个表的元数据 SHOW TABLE METADATA t_order, t_order_1 FROM sharding_db; mysql&amp;gt; SHOW TABLE METADATA t_order, t_order_1 FROM sharding_db; +-------------------+------------+--------+----------+ | schema_name | table_name | type | name | +-------------------+------------+--------+----------+ | sharding_db | t_order_1 | COLUMN | order_id | | sharding_db | t_order_1 | COLUMN | user_id | | sharding_db | t_order_1 | COLUMN | status | | sharding_db | t_order_1 | INDEX | PRIMARY | | sharding_db | t_order | COLUMN | order_id | | sharding_db | t_order | COLUMN | user_id | | sharding_db | t_order | COLUMN | status | | sharding_db | t_order | INDEX | PRIMARY | +-------------------+------------+--------+----------+ 8 rows in set (0.</description>
</item>
<item>
<title>SQL 审计</title>
<link>https://shardingsphere.apache.org/document/current/cn/dev-manual/sql-audit/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/sql-audit/</guid>
<description>SQLAuditor 全限定类名 org.apache.shardingsphere.infra.executor.audit.SQLAuditor
定义 SQL 审计定义接口
已知实现 配置标识 详细说明 全限定类名 Sharding 分片 SQL 审计器 org.apache.shardingsphere.sharding.auditor.ShardingSQLAuditor </description>
</item>
<item>
<title>数据分片路由缓存</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding-cache/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/rules/sharding-cache/</guid>
<description>背景信息 该项功能为实验性功能,需要与数据分片功能同时使用。 数据分片路由缓存会将逻辑 SQL、分片键实际参数值、路由结果放入缓存中,以空间换时间,减少路由逻辑对 CPU 的使用。
建议仅在满足以下条件的情况下启用:
纯 OLTP 场景 ShardingSphere 进程所在机器 CPU 已达到瓶颈 CPU 开销主要在于 ShardingSphere 路由逻辑 所有 SQL 已经最优且每次 SQL 执行都能命中单一分片 在不满足以上条件的情况下使用,可能对 SQL 的执行延时不会有明显改善,同时会增加内存的压力。
参数解释 rules: - !SHARDING tables: shardingAlgorithms: # ... shardingCache: allowedMaxSqlLength: 512 # 允许缓存的 SQL 长度限制 routeCache: initialCapacity: 65536 # 缓存初始容量 maximumSize: 262144 # 缓存最大容量 softValues: true # 是否软引用缓存值 相关参考 核心特性:数据分片 </description>
</item>
<item>
<title>DROP SHARDING ALGORITHM</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/drop-sharding-algorithm/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/drop-sharding-algorithm/</guid>
<description>描述 DROP SHARDING ALGORITHM 语法用于删除指定逻辑库的指定分片算法。
语法定义 语法 铁路图 DropShardingAlgorithm ::= &amp;#39;DROP&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;ALGORITHM&amp;#39; shardingAlgorithmName ifExists? (&amp;#39;FROM&amp;#39; databaseName)? ifExists ::= &amp;#39;IF&amp;#39; &amp;#39;EXISTS&amp;#39; shardingAlgorithmName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected; ifExists 子句用于避免 Sharding algorithm not exists 错误。 示例 删除指定逻辑库的指定分片算法 DROP SHARDING ALGORITHM t_order_hash_mod FROM sharding_db; 删除当前逻辑库的指定分片算法 DROP SHARDING ALGORITHM t_order_hash_mod; 使用 ifExists 子句删除分片算法 DROP SHARDING ALGORITHM IF EXISTS t_order_hash_mod; 保留字 DROP、SHARDING、ALGORITHM、FROM</description>
</item>
<item>
<title>EXPORT DATABASE CONFIGURATION</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/export-database-configuration/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/export-database-configuration/</guid>
<description>描述 EXPORT DATABASE CONFIGURATION 语法用于将 database 中的存储单元和规则配置导出为 YAML 格式。
语法 语法 铁路图 ExportDatabaseConfiguration ::= &amp;#39;EXPORT&amp;#39; &amp;#39;DATABASE&amp;#39; &amp;#39;CONFIGURATION&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? (&amp;#39;TO&amp;#39; &amp;#39;FILE&amp;#39; filePath)? databaseName ::= identifier filePath ::= string 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。
未指定 filePath 时,会将存储单元和规则配置导出至屏幕。
示例 导出指定逻辑库的存储单元和规则配置到指定路径 EXPORT DATABASE CONFIGURATION FROM sharding_db TO FILE &amp;#34;/xxx/config_sharding_db.yaml&amp;#34;; 导出指定逻辑库的存储单元和规则配置到屏幕 EXPORT DATABASE CONFIGURATION FROM sharding_db; mysql&amp;gt; EXPORT DATABASE CONFIGURATION FROM sharding_db; +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | result | +-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | databaseName: sharding_db dataSources: ds_1: password: 123456 url: jdbc:mysql://127.</description>
</item>
<item>
<title>SHOW MIGRATION CHECK STATUS</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/show-migration-check-status/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/show-migration-check-status/</guid>
<description>描述 SHOW MIGRATION CHECK STATUS 语法用于查询指定数据迁移作业的数据校验情况。
语法 语法 铁路图 ShowMigrationCheckStatus ::= &amp;#39;SHOW&amp;#39; &amp;#39;MIGRATION&amp;#39; &amp;#39;CHECK&amp;#39; &amp;#39;STATUS&amp;#39; migrationJobId migrationJobId ::= string 补充说明 migrationJobId 需要通过 SHOW MIGRATION LIST 语法查询获得 返回值说明 列 说明 tables 校验表 result 校验结果 finished_percentage 校验完成度 remaining_seconds 剩余时间 check_begin_time 校验开始时间 check_end_time 校验结束时间 error_message 错误信息提示 示例 查询指定数据迁移作业的数据校验情况 SHOW MIGRATION CHECK STATUS &amp;#39;j010180026753ef0e25d3932d94d1673ba551&amp;#39;; mysql&amp;gt; SHOW MIGRATION CHECK STATUS &amp;#39;j010180026753ef0e25d3932d94d1673ba551&amp;#39;; +---------+--------+---------------------+-------------------+-------------------------+-------------------------+------------------+---------------+ | tables | result | finished_percentage | remaining_seconds | check_begin_time | check_end_time | duration_seconds | error_message | +---------+--------+---------------------+-------------------+-------------------------+-------------------------+------------------+---------------+ | t_order | true | 100 | 0 | 2022-11-01 17:57:39.</description>
</item>
<item>
<title>SHOW SHARDING TABLE RULES USED KEY GENERATOR</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-table-rules-used-key-generator/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-table-rules-used-key-generator/</guid>
<description>描述 SHOW SHARDING TABLE RULES USED KEY GENERATOR 语法用于查询指定逻辑库中使用指定分片主键生成器的分片规则。
语法 语法 铁路图 ShowShardingTableRulesUsedKeyGenerator::= &amp;#39;SHOW&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;RULES&amp;#39; &amp;#39;USED&amp;#39; &amp;#39;KEY&amp;#39; &amp;#39;GENERATOR&amp;#39; keyGeneratorName (&amp;#39;FROM&amp;#39; databaseName)? keyGeneratorName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 type 分片规则类型 name 分片规则名称 示例 查询指定逻辑库中使用指定分片主键生成器的分片规则 SHOW SHARDING TABLE RULES USED KEY GENERATOR snowflake_key_generator FROM sharding_db; mysql&amp;gt; SHOW SHARDING TABLE RULES USED KEY GENERATOR snowflake_key_generator FROM sharding_db; +-------+--------------+ | type | name | +-------+--------------+ | table | t_order_item | +-------+--------------+ 1 row in set (0.</description>
</item>
<item>
<title>数据加密</title>
<link>https://shardingsphere.apache.org/document/current/cn/dev-manual/encrypt/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/encrypt/</guid>
<description>EncryptAlgorithm 全限定类名 org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm
定义 数据加密算法
已知实现 配置标识 详细说明 全限定类名 AES 基于 AES 的数据加密算法 org.apache.shardingsphere.encrypt.algorithm.encrypt.AESEncryptAlgorithm RC4 基于 RC4 的数据加密算法 org.apache.shardingsphere.encrypt.algorithm.encrypt.RC4EncryptAlgorithm SM3 基于 SM3 的数据加密算法 org.apache.shardingsphere.encrypt.sm.algorithm.SM3EncryptAlgorithm SM4 基于 SM4 的数据加密算法 org.apache.shardingsphere.encrypt.sm.algorithm.SM4EncryptAlgorithm CHAR_DIGEST_LIKE 用于模糊查询的数据加密算法 org.apache.shardingsphere.encrypt.algorithm.like.CharDigestLikeEncryptAlgorithm MD5 基于 MD5 的辅助查询加密算法 org.apache.shardingsphere.encrypt.algorithm.encrypt.MD5EncryptAlgorithm </description>
</item>
<item>
<title>CREATE SHARDING TABLE REFERENCE RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-reference-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-reference-rule/</guid>
<description>描述 CREATE SHARDING TABLE REFERENCE RULE 语法用于为分片表创建关联规则。
语法定义 语法 铁路图 CreateShardingTableReferenceRule ::= &amp;#39;CREATE&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;REFERENCE&amp;#39; &amp;#39;RULE&amp;#39; ifNotExists? referenceRelationshipDefinition (&amp;#39;,&amp;#39; referenceRelationshipDefinition)* ifNotExists ::= &amp;#39;IF&amp;#39; &amp;#39;NOT&amp;#39; &amp;#39;EXISTS&amp;#39; referenceRelationshipDefinition ::= ruleName &amp;#39;(&amp;#39; tableName (&amp;#39;,&amp;#39; tableName)* &amp;#39;)&amp;#39; tableName ::= identifier 补充说明 只能为分片表创建关联关系; 一张分片表只能具有一个关联关系; 关联的分片表应分布在相同的存储单元,并且分片个数相同。例如 ds_${0..1}.t_order_${0..1} 与 ds_${0..1}.t_order_item_${0..1}; 关联的分片表应使用一致的分片算法。例如 t_order_${order_id % 2} 与 t_order_item_${order_item_id % 2}; ifNotExists 子句用于避免 Duplicate sharding table reference rule 错误。 示例 1.</description>
</item>
<item>
<title>IMPORT DATABASE CONFIGURATION</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/import-database-configuration/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/import-database-configuration/</guid>
<description>描述 IMPORT DATABASE CONFIGURATION 语法用于将 YAML 中的配置导入到指定逻辑库中。
语法 语法 铁路图 ExportDatabaseConfiguration ::= &amp;#39;IMPORT&amp;#39; &amp;#39;DATABASE&amp;#39; &amp;#39;CONFIGURATION&amp;#39; &amp;#39;FROM&amp;#39; &amp;#39;FILE&amp;#39; filePath (&amp;#39;TO&amp;#39; databaseName)? databaseName ::= identifier filePath ::= string 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE 如果也未使用 DATABASE 则会提示 No database selected。
IMPORT DATABASE CONFIGURATION 语法仅支持对空逻辑库进行导入操作。
示例 将 YAML 中的配置导入到指定逻辑库中 IMPORT DATABASE CONFIGURATION FROM FILE &amp;#34;/xxx/config_sharding_db.yaml&amp;#34; TO sharding_db; 将 YAML 中的配置导入到当前逻辑库中 IMPORT DATABASE CONFIGURATION FROM FILE &amp;#34;/xxx/config_sharding_db.</description>
</item>
<item>
<title>SHOW SHARDING TABLE RULES USED AUDITOR</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-table-rules-used-auditor/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-table-rules-used-auditor/</guid>
<description>描述 SHOW SHARDING TABLE RULES USED AUDITOR 语法用于查询指定逻辑库中使用指定分片审计器的分片规则。
语法 语法 铁路图 ShowShardingTableRulesUsedAuditor::= &amp;#39;SHOW&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;RULES&amp;#39; &amp;#39;USED&amp;#39; &amp;#39;AUDITOR&amp;#39; AuditortorName (&amp;#39;FROM&amp;#39; databaseName)? AuditortorName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 type 分片规则类型 name 分片规则名称 示例 查询指定逻辑库中使用指定分片审计器的分片规则 SHOW SHARDING TABLE RULES USED AUDITOR sharding_key_required_auditor FROM sharding_db; mysql&amp;gt; SHOW SHARDING TABLE RULES USED AUDITOR sharding_key_required_auditor FROM sharding_db; +-------+---------+ | type | name | +-------+---------+ | table | t_order | +-------+---------+ 1 row in set (0.</description>
</item>
<item>
<title>START MIGRATION CHECK</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/start-migration-check/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/start-migration-check/</guid>
<description>描述 START MIGRATION CHECK 语法用于开始指定数据迁移作业的数据校验。
语法 语法 铁路图 StartMigrationCheck ::= &amp;#39;START&amp;#39; &amp;#39;MIGRATION&amp;#39; &amp;#39;CHECK&amp;#39; migrationJobId migrationJobId ::= string 补充说明 migrationJobId 需要通过 SHOW MIGRATION LIST 语法查询获得 示例 开始指定数据迁移作业的数据校验 START MIGRATION CHECK &amp;#39;j010180026753ef0e25d3932d94d1673ba551&amp;#39;; 保留字 START、MIGRATION、CHECK
相关链接 保留字 SHOW MIGRATION LIST </description>
</item>
<item>
<title>数据脱敏</title>
<link>https://shardingsphere.apache.org/document/current/cn/dev-manual/mask/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/mask/</guid>
<description>MaskAlgorithm 全限定类名 org.apache.shardingsphere.mask.spi.MaskAlgorithm
定义 数据脱敏算法
已知实现 配置标识 详细说明 全限定类名 MD5 基于 MD5 的数据脱敏算法 org.apache.shardingsphere.mask.algorithm.hash.MD5MaskAlgorithm KEEP_FIRST_N_LAST_M 保留前 n 后 m 数据脱敏算法 org.apache.shardingsphere.mask.algorithm.cover.KeepFirstNLastMMaskAlgorithm KEEP_FROM_X_TO_Y 保留自 x 至 y 数据脱敏算法 org.apache.shardingsphere.mask.algorithm.cover.KeepFromXToYMaskAlgorithm MASK_FIRST_N_LAST_M 遮盖前 n 后 m 数据脱敏算法 org.apache.shardingsphere.mask.algorithm.cover.MaskFirstNLastMMaskAlgorithm MASK_FROM_X_TO_Y 遮盖自 x 至 y 数据脱敏算法 org.apache.shardingsphere.mask.algorithm.cover.MaskFromXToYMaskAlgorithm MASK_BEFORE_SPECIAL_CHARS 特殊字符前遮盖数据脱敏算法 org.apache.shardingsphere.mask.algorithm.cover.MaskBeforeSpecialCharsAlgorithm MASK_AFTER_SPECIAL_CHARS 特殊字符后遮盖数据脱敏算法 org.apache.shardingsphere.mask.algorithm.cover.MaskAfterSpecialCharsAlgorithm PERSONAL_IDENTITY_NUMBER_RANDOM_REPLACE 身份证号随机替换数据脱敏算法 org.</description>
</item>
<item>
<title>ALTER SHARDING TABLE REFERENCE RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/alter-sharding-table-reference-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/alter-sharding-table-reference-rule/</guid>
<description>描述 ALTER SHARDING TABLE REFERENCE RULE 语法用于修改分片表关联关系。
语法定义 语法 铁路图 AlterShardingTableReferenceRule ::= &amp;#39;ALTER&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;REFERENCE&amp;#39; &amp;#39;RULE&amp;#39; referenceRelationshipDefinition (&amp;#39;,&amp;#39; referenceRelationshipDefinition)* referenceRelationshipDefinition ::= ruleName &amp;#39;(&amp;#39; tableName (&amp;#39;,&amp;#39; tableName)* &amp;#39;)&amp;#39; tableName ::= identifier 补充说明 一张分片表只能具有一个关联关系; 关联的分片表应分布在相同的存储单元,并且分片个数相同。例如 ds_${0..1}.t_order_${0..1} 与 ds_${0..1}.t_order_item_${0..1}; 关联的分片表应使用一致的分片算法。例如 t_order_${order_id % 2} 与 t_order_item_${order_item_id % 2}; 示例 1.修改关联关系 ALTER SHARDING TABLE REFERENCE RULE ref_0 (t_order,t_order_item); 2.修改多个关联关系 ALTER SHARDING TABLE REFERENCE RULE ref_0 (t_order,t_order_item), ref_1 (t_product,t_product_item); 保留字 ALTER、SHARDING、TABLE、REFERENCE、RULE</description>
</item>
<item>
<title>SHOW RULES USED STORAGE UNIT</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-rules-used-storage-unit/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/show-rules-used-storage-unit/</guid>
<description>描述 SHOW RULES USED STORAGE UNIT 语法用于查询指定逻辑库中使用指定存储单元的规则。
语法 语法 铁路图 ShowRulesUsedStorageUnit ::= &amp;#39;SHOW&amp;#39; &amp;#39;RULES&amp;#39; &amp;#39;USED&amp;#39; &amp;#39;STORAGE&amp;#39; &amp;#39;UNIT&amp;#39; storageUnitName (&amp;#39;FROM&amp;#39; databaseName)? storageUnitName ::= identifier databaseName ::= identifier 返回值说明 列 说明 type 规则类型 name 规则名称 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 示例 查询指定逻辑库中使用指定存储单元的规则 SHOW RULES USED STORAGE UNIT ds_1 FROM sharding_db; mysql&amp;gt; SHOW RULES USED STORAGE UNIT ds_1 FROM sharding_db; +---------------------+------------+ | type | name | +---------------------+------------+ | readwrite_splitting | ms_group_0 | | readwrite_splitting | ms_group_0 | +---------------------+------------+ 2 rows in set (0.</description>
</item>
<item>
<title>SHOW SHARDING TABLE REFERENCE RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-table-reference-rules/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-sharding-table-reference-rules/</guid>
<description>描述 SHOW SHARDING BINDING TABLE RULE 语法用于查询指定逻辑库中指定分片表关联规则。
语法 语法 铁路图 ShowShardingBindingTableRules::= &amp;#39;SHOW&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;REFERENCE&amp;#39; (&amp;#39;RULE&amp;#39; ruleName | &amp;#39;RULES&amp;#39;) (&amp;#39;FROM&amp;#39; databaseName)? ruleName ::= identifier databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 name 分片表关联规则名称 sharding_table_reference 分片表关联关系 示例 查询指定逻辑库中的分片表关联规则 SHOW SHARDING TABLE REFERENCE RULES FROM sharding_db; mysql&amp;gt; SHOW SHARDING TABLE REFERENCE RULES FROM sharding_db; +-------+--------------------------+ | name | sharding_table_reference | +-------+--------------------------+ | ref_0 | t_a,t_b | | ref_1 | t_c,t_d | +-------+--------------------------+ 2 rows in set (0.</description>
</item>
<item>
<title>STOP MIGRATION CHECK</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/stop-migration-check/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/stop-migration-check/</guid>
<description>描述 STOP MIGRATION CHECK 语法用于停止指定数据迁移作业的数据校验。
语法 语法 铁路图 StopMigrationCheck ::= &amp;#39;STOP&amp;#39; &amp;#39;MIGRATION&amp;#39; &amp;#39;CHECK&amp;#39; migrationJobId migrationJobId ::= string 补充说明 migrationJobId 需要通过 SHOW MIGRATION LIST 语法查询获得 示例 停止指定数据迁移作业的数据校验 STOP MIGRATION CHECK &amp;#39;j010180026753ef0e25d3932d94d1673ba551&amp;#39;; 保留字 STOP、MIGRATION、CHECK
相关链接 保留字 SHOW MIGRATION LIST </description>
</item>
<item>
<title>影子库</title>
<link>https://shardingsphere.apache.org/document/current/cn/dev-manual/shadow/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/shadow/</guid>
<description>ShadowAlgorithm 全限定类名 org.apache.shardingsphere.shadow.spi.ShadowAlgorithm
定义 影子库提供的影子算法
已知实现 配置表示 详细说明 完全限定类名 VALUE_MATCH 基于字段值匹配影子算法 org.apache.shardingsphere.shadow.algorithm.shadow.column.ColumnValueMatchedShadowAlgorithm REGEX_MATCH 基于字段值正则匹配影子算法 org.apache.shardingsphere.shadow.algorithm.shadow.column.ColumnRegexMatchedShadowAlgorithm SQL_HINT 基于 SQL Hint 的影子算法 org.apache.shardingsphere.shadow.algorithm.shadow.hint.SQLHintShadowAlgorithm </description>
</item>
<item>
<title>DROP SHARDING TABLE REFERENCE RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/drop-sharding-table-reference-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/drop-sharding-table-reference-rule/</guid>
<description>描述 DROP SHARDING TABLE REFERENCE RULE 语法用删除指定的关联规则。
语法定义 语法 铁路图 DropShardingTableReferenceRule ::= &amp;#39;DROP&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;REFERENCE&amp;#39; &amp;#39;RULE&amp;#39; ifExists? shardingReferenceRuleName (&amp;#39;,&amp;#39; shardingReferenceRuleName)* ifExists ::= &amp;#39;IF&amp;#39; &amp;#39;EXISTS&amp;#39; shardingReferenceRuleName ::= identifier 补充说明 ifExists 子句用于避免 Sharding reference rule not exists 错误。 示例 删除单个关联规则 DROP SHARDING TABLE REFERENCE RULE ref_0; 删除多个关联规则 DROP SHARDING TABLE REFERENCE RULE ref_0, ref_1; 使用 ifExists 子句删除关联规则 DROP SHARDING TABLE REFERENCE RULE IF EXISTS ref_0; 保留字 DROP、SHARDING、TABLE、REFERENCE、RULE</description>
</item>
<item>
<title>SHOW BROADCAST TABLE RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-broadcast-table-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/show-broadcast-table-rule/</guid>
<description>描述 SHOW BROADCAST TABLE RULES 语法用于查询指定数据库中具有广播规则的表。
语法定义 语法 铁路图 ShowBroadcastTableRule ::= &amp;#39;SHOW&amp;#39; &amp;#39;BROADCAST&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;RULES&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE; 如未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 broadcast_table 广播表名称 示例 查询指定数据库中具有广播规则的表 SHOW BROADCAST TABLE RULES FROM sharding_db; mysql&amp;gt; SHOW BROADCAST TABLE RULES FROM sharding_db; +-----------------+ | broadcast_table | +-----------------+ | t_a | | t_b | | t_c | +-----------------+ 3 rows in set (0.</description>
</item>
<item>
<title>START MIGRATION</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/start-migration/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/start-migration/</guid>
<description>描述 START MIGRATION 语法用于开始指定的数据迁移作业。
语法 语法 铁路图 StartMigration ::= &amp;#39;START&amp;#39; &amp;#39;MIGRATION&amp;#39; migrationJobId migrationJobId ::= string 补充说明 migrationJobId 需要通过 SHOW MIGRATION LIST 语法查询获得 示例 停止指定的数据迁移作业 START MIGRATION &amp;#39;j010180026753ef0e25d3932d94d1673ba551&amp;#39;; 保留字 START、MIGRATION
相关链接 保留字 SHOW MIGRATION LIST </description>
</item>
<item>
<title>可观察性</title>
<link>https://shardingsphere.apache.org/document/current/cn/dev-manual/agent/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/dev-manual/agent/</guid>
<description>PluginLifecycleService 全限定类名 org.apache.shardingsphere.agent.spi.PluginLifecycleService
定义 插件生命周期管理接口
已知实现 配置标识 详细说明 全限定类名 File File 插件生命周期管理类 org.apache.shardingsphere.agent.plugin.logging.file.FileLoggingPluginLifecycleService Prometheus Prometheus 插件生命周期管理类 org.apache.shardingsphere.agent.plugin.metrics.prometheus.PrometheusPluginLifecycleService OpenTelemetry OpenTelemetry 插件生命周期管理类 org.apache.shardingsphere.agent.plugin.tracing.opentelemetry.OpenTelemetryTracingPluginLifecycleService </description>
</item>
<item>
<title>COUNT SHARDING RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/count-sharding-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rql/rule-query/sharding/count-sharding-rule/</guid>
<description>描述 COUNT SHARDING RULE 语法用于查询指定逻辑库中的分片规则数量。
语法 语法 铁路图 CountShardingRule::= &amp;#39;COUNT&amp;#39; &amp;#39;SHARDING&amp;#39; &amp;#39;RULE&amp;#39; (&amp;#39;FROM&amp;#39; databaseName)? databaseName ::= identifier 补充说明 未指定 databaseName 时,默认是当前使用的 DATABASE。 如果也未使用 DATABASE 则会提示 No database selected。 返回值说明 列 说明 rule_name 规则类型 database 规则所属逻辑库 count 规则数量 示例 查询指定逻辑库中的分片规则数量 COUNT SHARDING RULE FROM sharding_db; mysql&amp;gt; COUNT SHARDING RULE FROM sharding_db; +--------------------------+----------------+-------+ | rule_name | database | count | +--------------------------+----------------+-------+ | sharding_table | sharding_db | 2 | | sharding_table_reference | sharding_db | 2 | | broadcast_table | sharding_db | 0 | +--------------------------+----------------+-------+ 3 rows in set (0.</description>
</item>
<item>
<title>CREATE BROADCAST TABLE RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/create-broadcast-table-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/create-broadcast-table-rule/</guid>
<description>描述 CREATE BROADCAST TABLE RULE 语法用于为需要广播的表(广播表)创建广播规则。
语法定义 语法 铁路图 CreateBroadcastTableRule ::= &amp;#39;CREATE&amp;#39; &amp;#39;BROADCAST&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;RULE&amp;#39; ifNotExists? tableName (&amp;#39;,&amp;#39; tableName)* ifNotExists ::= &amp;#39;IF&amp;#39; &amp;#39;NOT&amp;#39; &amp;#39;EXISTS&amp;#39; tableName ::= identifier 补充说明 tableName 可使用已经存在的表或者将要创建的表; ifNotExists 子句用于避免 Duplicate Broadcast rule 错误。 示例 创建广播规则 -- 将 t_province, t_city 添加到广播规则中 CREATE BROADCAST TABLE RULE t_province, t_city; 使用 ifNotExists 子句创建广播规则 CREATE BROADCAST TABLE RULE IF NOT EXISTS t_province, t_city; 保留字 CREATE、BROADCAST、TABLE、RULE</description>
</item>
<item>
<title>STOP MIGRATION</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/stop-migration/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/stop-migration/</guid>
<description>描述 STOP MIGRATION 语法用于停止指定的数据迁移作业。
语法 语法 铁路图 StopMigration ::= &amp;#39;STOP&amp;#39; &amp;#39;MIGRATION&amp;#39; migrationJobId migrationJobId ::= string 补充说明 migrationJobId 需要通过 SHOW MIGRATION LIST 语法查询获得 示例 停止指定的数据迁移作业 STOP MIGRATION &amp;#39;j010180026753ef0e25d3932d94d1673ba551&amp;#39;; 保留字 STOP、MIGRATION
相关链接 保留字 SHOW MIGRATION LIST </description>
</item>
<item>
<title>COMMIT MIGRATION</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/commit-migration/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/commit-migration/</guid>
<description>描述 COMMIT MIGRATION 语法用于完成指定的数据迁移作业。
语法 语法 铁路图 CommitMigration ::= &amp;#39;COMMIT&amp;#39; &amp;#39;MIGRATION&amp;#39; migrationJobId migrationJobId ::= string 补充说明 migrationJobId 需要通过 SHOW MIGRATION LIST 语法查询获得 示例 完成指定的数据迁移作业 COMMIT MIGRATION &amp;#39;j010180026753ef0e25d3932d94d1673ba551&amp;#39;; 保留字 COMMIT、MIGRATION
相关链接 保留字 SHOW MIGRATION LIST </description>
</item>
<item>
<title>DROP BROADCAST TABLE RULE</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/drop-broadcast-table-rule/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/drop-broadcast-table-rule/</guid>
<description>描述 DROP BROADCAST TABLE RULE 语法用于为指定的广播表删除广播规则。
语法定义 语法 铁路图 DropBroadcastTableRule ::= &amp;#39;DROP&amp;#39; &amp;#39;BROADCAST&amp;#39; &amp;#39;TABLE&amp;#39; &amp;#39;RULE&amp;#39; ifExists? tableName (&amp;#39;,&amp;#39; tableName)* ifExists ::= &amp;#39;IF&amp;#39; &amp;#39;EXISTS&amp;#39; tableName ::= identifier 补充说明 tableName 可使用已经存在的广播规则的表; ifExists 子句用于避免 Broadcast rule not exists 错误。 示例 为指定广播表删除广播规则 DROP BROADCAST TABLE RULE t_province, t_city; 使用 ifExists 子句为广播表删除广播规则 DROP BROADCAST TABLE RULE IF EXISTS t_province, t_city; 保留字 DROP、BROADCAST、TABLE、RULE</description>
</item>
<item>
<title>ROLLBACK MIGRATION</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/rollback-migration/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/ral/migration/rollback-migration/</guid>
<description>描述 ROLLBACK MIGRATION 语法用于撤销指定的数据迁移作业。
语法 语法 铁路图 RollbackMigration ::= &amp;#39;ROLLBACK&amp;#39; &amp;#39;MIGRATION&amp;#39; migrationJobId migrationJobId ::= string 补充说明 migrationJobId 需要通过 SHOW MIGRATION LIST 语法查询获得
该语句执行后会清理目标端
示例 撤销指定的数据迁移作业 ROLLBACK MIGRATION &amp;#39;j010180026753ef0e25d3932d94d1673ba551&amp;#39;; 保留字 ROLLBACK、MIGRATION
相关链接 保留字 SHOW MIGRATION LIST </description>
</item>
</channel>
</rss>