Database Discovery #
Syntax | Description | Type |
---|---|---|
CREATE DB_DISCOVERY RULE ruleDefinition [, ruleDefinition] … | Create database discovery rule | RDL |
ALTER DB_DISCOVERY RULE ruleDefinition [, ruleDefinition] … | Modify database discovery rule | RDL |
DROP DB_DISCOVERY RULE ruleName [, ruleName] … | Delete database discovery rule | RDL |
DROP DB_DISCOVERY TYPE discoveryTypeName [, discoveryTypeName] … | Delete database discovery type | RDL |
DROP DB_DISCOVERY HEARTBEAT discoveryHeartbeatName [, discoveryHeartbeatName] … | Delete database discovery listening heartbeat algorithm | RDL |
SHOW DB_DISCOVERY RULES [FROM databaseName] | View database discovery rule | RQL |
SHOW DB_DISCOVERY TYPES [FROM databaseName] | View database discovery type | RQL |
SHOW DB_DISCOVERY HEARTBEATS [FROM databaseName] | View database discovery listening heartbeat algorithm | RQL |
COUNT DB_DISCOVERY RULE | Count the number of database discovery rules, this syntax will be deprecated in subsequent versions | RQL |
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
Name | Data type | Description |
---|---|---|
discoveryTypeName | IDENTIFIER | Database discovery type name |
ruleName | IDENTIFIER | Rule name |
discoveryHeartbeatName | IDENTIFIER | Listening heartbeat name |
typeName | STRING | Database discovery type, such as: MySQL.MGR |
storageUnitName | IDENTIFIER | Data 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
anddiscoveryHeartbeat
being used cannot be deleted - Names with
-
need to use" "
when changing - When removing the
discoveryRule
, thediscoveryType
anddiscoveryHeartbeat
used by thediscoveryRule
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
Name | Data type | Description |
---|---|---|
discoveryTypeName | IDENTIFIER | Database discovery type name |
ruleName | IDENTIFIER | Rule name |
discoveryHeartbeatName | IDENTIFIER | Listening heartbeat name |
typeName | STRING | Database discovery type, such as: MySQL.MGR |
storageUnitName | IDENTIFIER | Data 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
anddiscoveryHeartbeat
being used cannot be deleted - Names with
-
need to use" "
when changing - When removing the
discoveryRule
, thediscoveryType
anddiscoveryHeartbeat
used by thediscoveryRule
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
Name | Data type | Description |
---|---|---|
ruleName | IDENTIFIER | Rule name |
- Removing a
discoveryRule
does not remove thediscoveryType
anddiscoveryHeartbeat
used by thediscoveryRule
.
Example
DROP DB_DISCOVERY RULE db_discovery_group_0;
4. Delete Database Discovery Type #
DROP DB_DISCOVERY TYPE discoveryTypeName [, discoveryTypeName] ...
Parameter Description
Name | Data type | Description |
---|---|---|
discoveryTypeName | IDENTIFIER | Database discovery type name |
typeName | STRING | Database discovery type, such as: MySQL.MGR |
- Removing a
discoveryRule
does not remove thediscoveryType
anddiscoveryHeartbeat
used by thediscoveryRule
.
Example
DROP DB_DISCOVERY TYPE db_discovery_group_0_mgr;
5. Delete Database Discovery Listening Heartbeat #
DROP DB_DISCOVERY HEARTBEAT discoveryHeartbeatName [, discoveryHeartbeatName] ...
Parameter Description
Name | Data type | Description |
---|---|---|
discoveryHeartbeatName | IDENTIFIER | Listening 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
Name | Data type | Description |
---|---|---|
databaseName | IDENTIFIER | Logical 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
Column | Description |
---|---|
group_name | Rule name |
data_source_names | Data source name list |
primary_data_source_name | Primary data source name |
discovery_type | Database discovery service type |
discovery_heartbeat | Database discovery service heartbeat |
7. View Database Discovery Type #
SHOW DB_DISCOVERY TYPES [FROM databaseName]
Parameter Description
Name | Data type | Description |
---|---|---|
databaseName | IDENTIFIER | Logical 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
Column | Description |
---|---|
name | Discovery type name |
type | Discovery type type |
props | Discovery type properties |
8. View Database Discovery Listening Heartbeat #
SHOW DB_DISCOVERY HEARTBEATS [FROM databaseName]
Parameter Description
Name | Data type | Description |
---|---|---|
databaseName | IDENTIFIER | Logical 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
Column | Description |
---|---|
name | Heartbeat name |
props | Heartbeat properties |