DB Discovery

Syntax

  1. CREATE DB_DISCOVERY RULE ruleDefinition [, ruleDefinition] ...
  2. ALTER DB_DISCOVERY RULE ruleDefinition [, ruleDefinition] ...
  3. DROP DB_DISCOVERY RULE ruleName [, ruleName] ...
  4. DROP DB_DISCOVERY TYPE discoveryTypeName [, discoveryTypeName] ...
  5. DROP DB_DISCOVERY HEARTBEAT discoveryHeartbeatName [, discoveryHeartbeatName] ...
  6. ruleDefinition:
  7. ruleName (storageUnits, typeDefinition, heartbeatDefinition)
  8. storageUnits:
  9. STORAGE_UNITS(storageUnitName [, storageUnitName] ...)
  10. typeDefinition:
  11. TYPE(NAME=typeName [, PROPERTIES([properties] )] )
  12. heartbeatDefinition
  13. HEARTBEAT (PROPERTIES (properties))
  14. properties:
  15. property [, property] ...
  16. property:
  17. key=value

Parameters Explained

nameDateTypeDescription
discoveryTypeNameIDENTIFIERDatabase discovery type name
ruleNameIDENTIFIERRule name
discoveryHeartbeatNameIDENTIFIERDetect heartbeat name
typeNameSTRINGDatabase discovery type, such as: MySQL.MGR
storageUnitNameIDENTIFIERStorage unit name

Notes

  • discoveryType specifies the database discovery service type, ShardingSphere has built-in support for MySQL.MGR
  • Duplicate ruleName will not be created
  • The discoveryType and discoveryHeartbeat being used cannot be deleted
  • Names with - must use " " when changing

Example

When creating a discoveryRule, create both discoveryType and discoveryHeartbeat

  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. );
  6. ALTER DB_DISCOVERY RULE db_discovery_group_0 (
  7. STORAGE_UNITS(ds_0, ds_1, ds_2),
  8. TYPE(NAME='MySQL.MGR',PROPERTIES('group-name'='246e9612-aaf1')),
  9. HEARTBEAT(PROPERTIES('keep-alive-cron'='0/5 * * * * ?'))
  10. );
  11. DROP DB_DISCOVERY RULE db_discovery_group_0;
  12. DROP DB_DISCOVERY TYPE db_discovery_group_0_mgr;
  13. DROP DB_DISCOVERY HEARTBEAT db_discovery_group_0_heartbeat;