Logo
Database Discovery

Database Discovery #

SyntaxDescriptionType
CREATE DB_DISCOVERY RULE ruleDefinition [, ruleDefinition] …Create database discovery ruleRDL
ALTER DB_DISCOVERY RULE ruleDefinition [, ruleDefinition] …Modify database discovery ruleRDL
DROP DB_DISCOVERY RULE ruleName [, ruleName] …Delete database discovery ruleRDL
DROP DB_DISCOVERY TYPE discoveryTypeName [, discoveryTypeName] …Delete database discovery typeRDL
DROP DB_DISCOVERY HEARTBEAT discoveryHeartbeatName [, discoveryHeartbeatName] …Delete database discovery listening heartbeat algorithmRDL
SHOW DB_DISCOVERY RULES [FROM databaseName]View database discovery ruleRQL
SHOW DB_DISCOVERY TYPES [FROM databaseName]View database discovery typeRQL
SHOW DB_DISCOVERY HEARTBEATS [FROM databaseName]View database discovery listening heartbeat algorithmRQL
COUNT DB_DISCOVERY RULECount the number of database discovery rules, this syntax will be deprecated in subsequent versionsRQL

1. Create Database Discovery Rule #

CREATE DB_DISCOVERY RULE ruleDefinition [, ruleDefinition] ...

ruleDefinition:
    ruleName (storageUnits, typeDefinition, heartbeatDefinition)

storageUnits:
    STORAGE_UNITS(storageUnitName [, storageUnitName] ...)

typeDefinition:
    TYPE(NAME=typeName [, PROPERTIES([properties] )] )

heartbeatDefinition
    HEARTBEAT (PROPERTIES (properties)) 

properties:
    property [, property] ...

property:
    key=value 

Parameter Description

NameData typeDescription
discoveryTypeNameIDENTIFIERDatabase discovery type name
ruleNameIDENTIFIERRule name
discoveryHeartbeatNameIDENTIFIERListening heartbeat name
typeNameSTRINGDatabase discovery type, such as: MySQL.MGR
storageUnitNameIDENTIFIERData source name
  • discoveryType specifies the database discovery service type, DBPlusEngine has built-in support for MySQL.NORMAL_REPLICATION、MySQL.MGR、openGauss.NORMAL_REPLICATION、SphereEx:GaussDB_for_MySQL.NORMAL_REPLICATION、SphereEx:PostgreSQL.NORMAL_REPLICATION, details refers to built-in db-discovery algorithm;
  • Duplicate ruleName will not be created
  • The discoveryType and discoveryHeartbeat being used cannot be deleted
  • Names with - need to use " " when changing
  • When removing the discoveryRule, the discoveryType and discoveryHeartbeat used by the discoveryRule will not be removed

Example

When creating a discoveryRule, create both discoveryType and discoveryHeartbeat

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

2. Modify Database Discovery Rule #

ALTER DB_DISCOVERY RULE ruleDefinition [, ruleDefinition] ...

ruleDefinition:
    ruleName (storageUnits, typeDefinition, heartbeatDefinition)

storageUnits:
    STORAGE_UNITS(storageUnitName [, storageUnitName] ...)

typeDefinition:
    TYPE(NAME=typeName [, PROPERTIES([properties] )] )

heartbeatDefinition
    HEARTBEAT (PROPERTIES (properties)) 

properties:
    property [, property] ...

property:
    key=value 

Parameter Description

NameData typeDescription
discoveryTypeNameIDENTIFIERDatabase discovery type name
ruleNameIDENTIFIERRule name
discoveryHeartbeatNameIDENTIFIERListening heartbeat name
typeNameSTRINGDatabase discovery type, such as: MySQL.MGR
storageUnitNameIDENTIFIERData source name
  • discoveryType specifies the database discovery service type, DBPlusEngine has built-in support for MySQL.NORMAL_REPLICATION、MySQL.MGR、openGauss.NORMAL_REPLICATION、SphereEx:GaussDB_for_MySQL.NORMAL_REPLICATION、SphereEx:PostgreSQL.NORMAL_REPLICATION, details refers to built-in db-discovery algorithm;
  • The discoveryType and discoveryHeartbeat being used cannot be deleted
  • Names with - need to use " " when changing
  • When removing the discoveryRule, the discoveryType and discoveryHeartbeat used by the discoveryRule will not be removed

Example

When altering a discoveryRule, modify both discoveryType and discoveryHeartbeat

ALTER DB_DISCOVERY RULE db_discovery_group_0 (
STORAGE_UNITS(ds_0, ds_1, ds_2),
TYPE(NAME='MySQL.MGR',PROPERTIES('group-name'='246e9612-aaf1')),
HEARTBEAT(PROPERTIES('keep-alive-cron'='0/5 * * * * ?'))
);

3. Delete Database Discovery Rule #

DROP DB_DISCOVERY RULE ruleName [, ruleName] ...

Parameter Description

NameData typeDescription
ruleNameIDENTIFIERRule name
  • Removing a discoveryRule does not remove the discoveryType and discoveryHeartbeat used by the discoveryRule.

Example

DROP DB_DISCOVERY RULE db_discovery_group_0;

4. Delete Database Discovery Type #

DROP DB_DISCOVERY TYPE discoveryTypeName [, discoveryTypeName] ...

Parameter Description

NameData typeDescription
discoveryTypeNameIDENTIFIERDatabase discovery type name
typeNameSTRINGDatabase discovery type, such as: MySQL.MGR
  • Removing a discoveryRule does not remove the discoveryType and discoveryHeartbeat used by the discoveryRule.

Example

DROP DB_DISCOVERY TYPE db_discovery_group_0_mgr;

5. Delete Database Discovery Listening Heartbeat #

DROP DB_DISCOVERY HEARTBEAT discoveryHeartbeatName [, discoveryHeartbeatName] ...

Parameter Description

NameData typeDescription
discoveryHeartbeatNameIDENTIFIERListening heartbeat name

Example

DROP DB_DISCOVERY HEARTBEAT db_discovery_group_0_heartbeat;

6. View Database Discovery Rule #

SHOW DB_DISCOVERY RULES [FROM databaseName]

Parameter Description

NameData typeDescription
databaseNameIDENTIFIERLogical database name

Example

View database discovery rules

mysql> SHOW DB_DISCOVERY RULES;
+----------------------+-------------------+--------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
| group_name           | data_source_names | primary_data_source_name | discovery_type                                                                    | discovery_heartbeat                                                          |
+----------------------+-------------------+--------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
| db_discovery_group_0 | ds_0,ds_1,ds_2    |        ds_0              | {name=db_discovery_group_0_mgr, type=MySQL.MGR, props={group-name=92504d5b-6dec}} | {name=db_discovery_group_0_heartbeat, props={keep-alive-cron=0/5 * * * * ?}} |
+----------------------+-------------------+--------------------------+-----------------------------------------------------------------------------------+-----------------------------------------------------------------------------+
1 row in set (0.20 sec)

Output Description

ColumnDescription
group_nameRule name
data_source_namesData source name list
primary_data_source_namePrimary data source name
discovery_typeDatabase discovery service type
discovery_heartbeatDatabase discovery service heartbeat

7. View Database Discovery Type #

SHOW DB_DISCOVERY TYPES [FROM databaseName]

Parameter Description

NameData typeDescription
databaseNameIDENTIFIERLogical database name

Example

View all database discovery type for current logical database

mysql> SHOW DB_DISCOVERY TYPES;
+--------------------------+------------+----------------------------+
| name                     | type       | props                      |
+--------------------------+------------+----------------------------+
| db_discovery_group_0_mgr | MySQL.MGR  | {group-name=92504d5b-6dec} |
+--------------------------+------------+----------------------------+
1 row in set (0.01 sec)

Output Description

ColumnDescription
nameDiscovery type name
typeDiscovery type type
propsDiscovery type properties

8. View Database Discovery Listening Heartbeat #

SHOW DB_DISCOVERY HEARTBEATS [FROM databaseName]

Parameter Description

NameData typeDescription
databaseNameIDENTIFIERLogical database name

Example

View all database heartbeat for current logical database

mysql> SHOW DB_DISCOVERY HEARTBEATS;
+--------------------------------+---------------------------------+
| name                           | props                           |
+--------------------------------+---------------------------------+
| db_discovery_group_0_heartbeat | {keep-alive-cron=0/5 * * * * ?} |
+---------------------------------+---------------------------------+
1 row in set (0.01 sec)

Output Description

ColumnDescription
nameHeartbeat name
propsHeartbeat properties