流量治理 #
语法 | 描述 | 类型 |
---|---|---|
CREATE TRAFFIC RULE sql_match_traffic (LABELS(xxx),TRAFFIC_ALGORITHM(TYPE(NAME=xxx,PROPERTIES(“key” = “value”))), LOAD_BALANCER(TYPE(NAME=xxx,PROPERTIES(“key"=“value”)))) | 创建双路由规则 | RDL |
ALTER TRAFFIC RULE sql_match_traffic (LABELS(xxx),TRAFFIC_ALGORITHM(TYPE(NAME=xxx,PROPERTIES(“key” = “value”))),LOAD_BALANCER(TYPE(NAME=xxx,PROPERTIES(“key”=“value”)))) | 修改双路由规则 | RDL |
DROP TRAFFIC RULE ruleName [, ruleName] | 删除双路由规则 | RDL |
SHOW TRAFFIC RULES | 查询双路由规则 | RQL |
1. 创建双路由规则 #
CREATE TRAFFIC RULE sql_match_traffic (LABELS(xxx),TRAFFIC_ALGORITHM(TYPE(NAME=xxx,PROPERTIES(“key” = “value”))), LOAD_BALANCER(TYPE(NAME=xxx,PROPERTIES(“key"="value”))))
参数说明
TRAFFIC_ALGORITHM
支持 SQL_MATCH
与 SQL_HINT
两种类型 LOAD_BALANCER
支持 RANDOM
与 ROUND_ROBIN
两种类型。
示例
CREATE TRAFFIC RULE sql_match_traffic (LABELS(OLTP),TRAFFIC_ALGORITHM(TYPE(NAME=SQL_MATCH,PROPERTIES(“sql” = “SELECT * FROM t_order WHERE order_id = ?; UPDATE t_order SET order_id = ?;"))),LOAD_BALANCER(TYPE(NAME=RANDOM)))
2. 修改双路由规则 #
ALTER TRAFFIC RULE sql_match_traffic (LABELS(xxx),TRAFFIC_ALGORITHM(TYPE(NAME=xxx,PROPERTIES(“key” = “value”))),LOAD_BALANCER(TYPE(NAME=xxx,PROPERTIES(“key"="value”))))
参数说明
TRAFFIC_ALGORITHM
支持 SQL_MATCH
与 SQL_HINT
两种类型 LOAD_BALANCER
支持 RANDOM
与 ROUND_ROBIN
两种类型。
示例
ALTER TRAFFIC RULE sql_match_traffic (LABELS(OLTP),TRAFFIC_ALGORITHM(TYPE(NAME=SQL_MATCH,PROPERTIES(“sql” = “SELECT * FROM t_order WHERE order_id = ?; UPDATE t_order SET order_id = ?;"))), LOAD_BALANCER(TYPE(NAME=RANDOM)))
3. 删除双路由规则 #
DROP TRAFFIC RULE ruleName [, ruleName]
示例
DROP TRAFFIC RULE sql_match_traffic
4. 查询双路由规则 #
SHOW TRAFFIC RULES;
示例
查询指定双路由规则或所有双路由规则
SHOW TRAFFIC RULES;