复古 护眼 海天 深邃 暗黑 默认

CREATE DB_DISCOVERY RULE

描述

CREATE DB_DISCOVERY RULE 语法用于创建数据库发现规则

语法定义

CreateDatabaseDiscoveryRule ::=
  'CREATE' 'DB_DISCOVERY' 'RULE' ( databaseDiscoveryDefinition | databaseDiscoveryConstruction ) ( ',' ( databaseDiscoveryDefinition | databaseDiscoveryConstruction ) )*

databaseDiscoveryDefinition ::=
    ruleName '(' 'RESOURCES' '(' resourceName ( ',' resourceName )* ')' ',' 'TYPE' '(' 'NAME' '=' typeName ( ',' 'PROPERTIES' 'key' '=' 'value' ( ',' 'key' '=' 'value' )* )? ',' 'HEARTBEAT' '(' 'key' '=' 'value' ( ',' 'key' '=' 'value' )* ')' ')' 
    
databaseDiscoveryConstruction ::=
    ruleName '(' 'RESOURCES' '(' resourceName ( ',' resourceName )* ')' ',' 'TYPE' '=' discoveryTypeName ',' 'HEARTBEAT' '=' discoveryHeartbeatName ')'
    
ruleName ::=
  identifier

resourceName ::=
  identifier

typeName ::=
  identifier

discoveryHeartbeatName ::=
  identifier

补充说明

  • discoveryType 指定数据库发现服务类型,ShardingSphere 内置支持 MySQL.MGR
  • 重复的 ruleName 将无法被创建;
  • 正在被使用的 discoveryTypediscoveryHeartbeat 无法被删除;
  • 带有 - 的命名在改动时需要使用 " "

示例

创建 discoveryRule 时同时创建 discoveryTypediscoveryHeartbeat

CREATE DB_DISCOVERY RULE db_discovery_group_0 (
    RESOURCES(ds_0, ds_1, ds_2),
    TYPE(NAME='MySQL.MGR',PROPERTIES('group-name'='92504d5b-6dec')),
    HEARTBEAT(PROPERTIES('keep-alive-cron'='0/5 * * * * ?'))
);

使用已有的 discoveryTypediscoveryHeartbeat 创建 discoveryRule

CREATE DB_DISCOVERY RULE db_discovery_group_1 (
    RESOURCES(ds_0, ds_1, ds_2),
    TYPE=db_discovery_group_1_mgr,
    HEARTBEAT=db_discovery_group_1_heartbeat
);

保留字

CREATEDB_DISCOVERYRULERESOURCESTYPENAMEPROPERTIESHEARTBEAT

相关链接