CREATE DB_DISCOVERY RULE

描述

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

语法定义

语法 铁路图

  1. CreateDatabaseDiscoveryRule ::=
  2. 'CREATE' 'DB_DISCOVERY' 'RULE' ifNotExists? databaseDiscoveryDefinition (',' databaseDiscoveryDefinition)*
  3. ifNotExists ::=
  4. 'IF' 'NOT' 'EXISTS'
  5. databaseDiscoveryDefinition ::=
  6. ruleName '(' 'STORAGE_UNITS' '(' storageUnitName (',' storageUnitName)* ')' ',' 'TYPE' '(' 'NAME' '=' typeName (',' propertiesDefinition)? ')' ',' 'HEARTBEAT' '(' propertiesDefinition ')' ')'
  7. propertiesDefinition ::=
  8. 'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'
  9. ruleName ::=
  10. identifier
  11. storageUnitName ::=
  12. identifier
  13. typeName ::=
  14. identifier
  15. discoveryHeartbeatName ::=
  16. identifier
  17. key ::=
  18. string
  19. value ::=
  20. literal

补充说明

  • discoveryType 指定数据库发现服务类型,ShardingSphere 内置支持 MySQL.MGR
  • 重复的 ruleName 将无法被创建;
  • ifNotExists 子句用于避免出现 Duplicate db_discovery rule 错误。

示例

  • 创建数据库发现规则
  1. CREATE DB_DISCOVERY RULE db_discovery_group_0 (
  2. STORAGE_UNITS(ds_0, ds_1, ds_2),
  3. TYPE(NAME='MySQL.MGR',PROPERTIES('group-name'='92504d5b-6dec')),
  4. HEARTBEAT(PROPERTIES('keep-alive-cron'='0/5 * * * * ?'))
  5. );
  • 使用 ifNotExists 子句创建数据库发现规则
  1. CREATE DB_DISCOVERY RULE IF NOT EXISTS db_discovery_group_0 (
  2. STORAGE_UNITS(ds_0, ds_1, ds_2),
  3. TYPE(NAME='MySQL.MGR',PROPERTIES('group-name'='92504d5b-6dec')),
  4. HEARTBEAT(PROPERTIES('keep-alive-cron'='0/5 * * * * ?'))
  5. );

保留字

CREATEDB_DISCOVERYRULESTORAGE_UNITSTYPENAMEPROPERTIESHEARTBEAT

相关链接