DB Discovery #
High availability is the basic requirement for modern systems. As the cornerstone of the system, the database is essential for high availability.
In this section, this capability refers to SphereEx-DBPlusEngine’s solution for discovering the availability of storage nodes.
In a distributed database system with storage-compute splitting, the high availability solution of the storage node and compute node are different. The stateful storage nodes need to pay attention to data consistency, health detection, primary node election, etc.
The stateless compute nodes need to detect the changes of storage nodes, they also need to set up an independent load balancer and have the ability of service discovery and request distribution.
Overview #
SphereEx-DBPlusEngine provides compute nodes and builds a cluster with storage nodes. It does not provide the high availability capability of the database itself. However, you can use the database’s own high availability, database discovery, and dynamic awareness capabilities to help users integrate databases’ high availability solutions such as primary/replica switchover, fault discovery, and traffic governance.
Therefore, the high availability solution uses the database’s own capability to make storage nodes highly available and automatically identify their changes. It is the primary/replica traffic control feature in the distributed scenario that provides a more advanced high-availability read/write splitting solution.
SphereEx-DBPlusEngine needs to detect high availability solutions of diversified storage nodes automatically, and can also integrate the read/write splitting dynamically.
Applicable Scenarios #
- High Availability Type
DBPlusEngine does not provide a high-availability database solution, it reuses 3rd party high availability solutions and auto-detect switch of primary and replica databases.
Specifically, DBPlusEngine provides the ability for database discovery, detecting the primary and replica databases automatically, and updating the connection of compute nodes to the databases.
- Dynamic Read/write Splitting
When high availability and read/write splitting are used together, it is unnecessary to configure specific primary and replica databases for read/write splitting.
When high availability and read/write splitting are used together, it supports detecting the delay time of the replica database during semi-synchronous replication and asynchronous replication. It dynamically routes the replica database with low delay to provide read traffic.
Highly available data sources will update the primary and replica databases of read/write splitting dynamically, route the query and update SQL correctly.
High availability also provides that all replica databases are down, and the read traffic is automatically routed to the main database, to ensure the availability of the business system.
Database Support #
SphereEx-DBPlusEngine supports high availability discovery for six database architectures. The supported database type reference Database discovery algorithm
Requirements #
- SphereEx-DBPlusEngine and Zookeeper should be properly installed and deployed.
- Database single primary clusters should be properly installed and deployed.
Terms of Use #
Supported
- The Spherex-DbplusEngine and Zookeeper have been installed and deployed, and services are running properly.
- The single master database cluster has been installed and deployed, and services are running properly.
Unsupported
- Multi-primary cluster mode.
- Cascading cluster mode.
- Primary-primary cluster mode.
Notice #
- Duplicate
ruleName
will not be created. discoveryType
anddiscoveryHeartbeat
cannot be deleted while in use.should be used while changing names with
-
.- When
discoveryRule
is removed, itsdiscoveryType
anddiscoveryHeartbeat
are not removed.
How it works #
The database discovery capability includes pre-check, primary database dynamic discovery, replica database discovery, and heartbeat discovery synchronization.
Pre-check #
During database discovery configuration, SphereEx-DBPlusEngine will check the environment. The configuration is complete only after all the items are checked. The following uses the MGR cluster as an example to illustrate the checking items.
- Check whether the MGR plug-in is installed. The following command should output the information about the plug-in naming
group_replication
.
SELECT * FROM information_schema.PLUGINS WHERE PLUGIN_NAME='group_replication';
- Check the number of members in the MGR group. The MGR group requires at least 3 nodes. The following command should output the number greater than or equal to 3.
SELECT count(*) FROM performance_schema.replication_group_members;
- Check whether
group_replication_group_name
in the MGR cluster corresponds to the same group name in the configuration.
- Check whether
-- group_name is the identifier of the MGR group.
-- One MGR cluster corresponds to the same group_name.
SELECT * FROM performance_schema.global_variables WHERE VARIABLE_NAME='group_replication_group_name';
- Check whether the current MGR is set to single primary mode. To achieve this, the value of
group_replication_single_primary_mode
must be ON.
SELECT * FROM performance_schema.global_variables WHERE VARIABLE_NAME='group_replication_single_primary_mode';
- Query all node addresses, ports, and member states in the MGR group cluster, to verify whether our configured data source is correct.
SELECT MEMBER_HOST, MEMBER_PORT, MEMBER_STATE FROM performance_schema.replication_group_members;
Primary Database Dynamic Discovery #
SphereEx-DBPlusEngine gets the primary database’s URL using the following SQL command:
SELECT MEMBER_HOST, MEMBER_PORT FROM performance_schema.replication_group_members WHERE MEMBER_ID = "
SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME = 'group_replication_primary_member'
Then compare the output with the URLs of the data sources we configured one by one. The hit data source is the primary database.
It will be updated to the registry center and distributed to other compute nodes in the cluster.
Replica Database Dynamic Discovery #
SphereEx-DBPlusEngine divides the replica databases’ status into enabled and disabled.
This status is synchronized to SphereEx-DBPlusEngine in real time to ensure that read traffic is routed correctly.
- Get all nodes in the MGR group.
SELECT MEMBER_HOST, MEMBER_PORT, MEMBER_STATE FROM performance_schema.replication_group_members;
- Disable replica databases.
The replica database is disabled based on the data source we configured and all nodes in the MGR group.
SphereEx-DBPlusEngine checks whether the data sources we configured can obtain Connection properly one by one, and verifies whether the data source URL contains the nodes in the MGR group. SphereEx-DBPlusEngine will disable data sources by being driven by events and synchronize the registry center if the Connection cannot be obtained properly or validation fails.
- Enable replica databases.
Restore the disabled replica database. After rejoining the MGR group, SphereEx-DBPlusEngine checks whether the recovered data source is used in our configuration. If so, SphereEx-DBPlusEngine will restore the data source to an enabled state.
Heartbeat Discovery Synchronization #
In order to ensure the real-time synchronization of the primary and replica database status, heartbeat discovery synchronization is introduced into the high availability module. When initializing the module, the above process is delivered to the scheduling framework as a Job. That realizes the separation of function development and job scheduling.
The heartbeat cycle can be flexibly configured based on our business features.
Instructions #
- Prepare environments and deploy SphereEx-DBPlusEngine clusters and database clusters.
- Create logical libraries and register storage (database) resources.
- Create rules for discovering databases, including storage node information, database discovery types, and heartbeat mechanisms.
- Create the dynamic read/write splitting rule.
- Confirm the configuration of the database discovery rule.
Examples #
Take a 3-node MGR scenario based on the read-write splitting as an example, to show the configuration of database discovery rules as follows:
- Create a database named
ha
in the MGR primary node.
mysql -utest -h192.168.56.104 -P3306 -p
SELECT * FROM performance_schema.replication_group_members;
-- Connect primary database
DROP SCHEMA IF EXISTS ha;
CREATE SCHEMA IF NOT EXISTS ha;
- Create a logical library named
testdb
in Proxy.
mysql -uroot -p -P3307 -h127.0.0.1
mysql> CREATE DATABASE testdb;
Query OK, 0 rows affected (0.05 sec)
mysql> USE testdb;
Database changed
- Register each MGR node into the Proxy.
mysql> REGISTER STORAGE UNIT ds_0 (
URL="jdbc:mysql://192.168.xx.103:3306/ha?serverTimezone=UTC&useSSL=false",
USER="test",
PASSWORD="Test@123"
), ds_1 (
URL="jdbc:mysql://192.168.xx.104:3306/ha?serverTimezone=UTC&useSSL=false",
USER="test",
PASSWORD="Test@123"
), ds_2 (
URL="jdbc:mysql://192.168.xx.105:3306/ha?serverTimezone=UTC&useSSL=false",
USER="test",
PASSWORD="Test@123"
);
View the currently registered data source.
mysql> SHOW STORAGE UNITS;
+------+-------+----------------+------+------+---------------------------------+---------------------------+---------------------------+---------------+---------------+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| name | type | host | port | db | connection_timeout_milliseconds | idle_timeout_milliseconds | max_lifetime_milliseconds | max_pool_size | min_pool_size | read_only | other_attributes |
+------+-------+----------------+------+------+---------------------------------+---------------------------+---------------------------+---------------+---------------+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ds_2 | MySQL | 192.168.xx.105 | 3306 | ha | 30000 | 60000 | 2100000 | 50 | 1 | false | {"dataSourceProperties":{"cacheServerConfiguration":"true","elideSetAutoCommits":"true","useServerPrepStmts":"true","cachePrepStmts":"true","rewriteBatchedStatements":"true","cacheResultSetMetadata":"false","useLocalSessionState":"true","maintainTimeStats":"false","prepStmtCacheSize":"8192","tinyInt1isBit":"false","prepStmtCacheSqlLimit":"2048","netTimeoutForStreamingResults":"0","zeroDateTimeBehavior":"round"},"healthCheckProperties":{},"initializationFailTimeout":1,"validationTimeout":5000,"keepaliveTime":0,"leakDetectionThreshold":0,"registerMbeans":false,"allowPoolSuspension":false,"autoCommit":true,"isolateInternalQueries":false} |
| ds_1 | MySQL | 192.168.xx.104 | 3306 | ha | 30000 | 60000 | 2100000 | 50 | 1 | false | {"dataSourceProperties":{"cacheServerConfiguration":"true","elideSetAutoCommits":"true","useServerPrepStmts":"true","cachePrepStmts":"true","rewriteBatchedStatements":"true","cacheResultSetMetadata":"false","useLocalSessionState":"true","maintainTimeStats":"false","prepStmtCacheSize":"8192","tinyInt1isBit":"false","prepStmtCacheSqlLimit":"2048","netTimeoutForStreamingResults":"0","zeroDateTimeBehavior":"round"},"healthCheckProperties":{},"initializationFailTimeout":1,"validationTimeout":5000,"keepaliveTime":0,"leakDetectionThreshold":0,"registerMbeans":false,"allowPoolSuspension":false,"autoCommit":true,"isolateInternalQueries":false} |
| ds_0 | MySQL | 192.168.xx.103 | 3306 | ha | 30000 | 60000 | 2100000 | 50 | 1 | false | {"dataSourceProperties":{"cacheServerConfiguration":"true","elideSetAutoCommits":"true","useServerPrepStmts":"true","cachePrepStmts":"true","rewriteBatchedStatements":"true","cacheResultSetMetadata":"false","useLocalSessionState":"true","maintainTimeStats":"false","prepStmtCacheSize":"8192","tinyInt1isBit":"false","prepStmtCacheSqlLimit":"2048","netTimeoutForStreamingResults":"0","zeroDateTimeBehavior":"round"},"healthCheckProperties":{},"initializationFailTimeout":1,"validationTimeout":5000,"keepaliveTime":0,"leakDetectionThreshold":0,"registerMbeans":false,"allowPoolSuspension":false,"autoCommit":true,"isolateInternalQueries":false} |
+------+-------+----------------+------+------+---------------------------------+---------------------------+---------------------------+---------------+---------------+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)
- Create a database discovery rule.
When creating a database discovery rule, we need to configure the data source, database discovery type, and heartbeat mechanism.
For different MGR, you also need to input the group-name. The specific value can be confirmed through my.cnf.
The heartbeat interval for database discovery should be set based on business requirements. The configuration mode is the same as the crontab format, and the minimum unit is second.
In the following example, the database node is detected every 5 seconds.
mysql> CREATE DB_DISCOVERY RULE primary_replica_ds (
STORAGE_UNITS(ds_0, ds_1, ds_2),
TYPE(NAME='MySQL.MGR',PROPERTIES('group-name'='b309fcc3-93e8-11ec-b5bd-080027c850b1')),
HEARTBEAT(PROPERTIES('keep-alive-cron'='0/5 * * * * ?'))
);
Query OK, 0 rows affected (0.28 sec)
After the database discovery rule is created, you can run the SHOW
statement to confirm.
mysql> SHOW DB_DISCOVERY RULES;
+--------------------+-------------------+--------------------------+--------------------------------------------------------------------------------------------------------------+-------------------------------------+
| group_name | data_source_names | primary_data_source_name | discovery_type | discovery_heartbeat |
+--------------------+-------------------+--------------------------+--------------------------------------------------------------------------------------------------------------+-------------------------------------+
| primary_replica_ds | ds_0,ds_1,ds_2 | ds_0 | {name=primary_replica_ds_mysql_mgr, type=MySQL.MGR, props={group-name=b309fcc3-93e8-11ec-b5bd-080027c850b1}} | {name=primary_replica_ds_heartbeat} |
+--------------------+-------------------+--------------------------+--------------------------------------------------------------------------------------------------------------+-------------------------------------+
1 row in set (0.06 sec)
mysql> SHOW DB_DISCOVERY HEARTBEATS;
+------------------------------+---------------------------------+
| name | props |
+------------------------------+---------------------------------+
| primary_replica_ds_heartbeat | {keep-alive-cron=0/5 * * * * ?} |
+------------------------------+---------------------------------+
1 row in set (0.01 sec)
The previous output shows the specific configuration of the database discovery rule. The rule configuration is complete.
- Create a dynamic read/write splitting rule.
In the scenario where dynamic read/write splitting is required, you can perform this step to create the rules. Write the name of the just configured rule to the dynamic read/write splitting configuration. According to the previous step, we need to input primary_replica_ds
.
mysql> CREATE READWRITE_SPLITTING RULE dynamic_readwrite_ds (
AUTO_AWARE_RESOURCE=primary_replica_ds
);
Query OK, 0 rows affected (0.08 sec)
Next, confirm the read/write splitting rule.
mysql> SHOW READWRITE_SPLITTING RULES;
+----------------------+-----------------------------+---------------------------------+-------------------------+-------------------------+--------------------+---------------------+
| name | auto_aware_data_source_name | write_data_source_query_enabled | write_storage_unit_name | read_storage_unit_names | load_balancer_type | load_balancer_props |
+----------------------+-----------------------------+---------------------------------+-------------------------+-------------------------+--------------------+---------------------+
| dynamic_readwrite_ds | primary_replica_ds | NULL | ds_0 | ds_1,ds_2 | | |
+----------------------+-----------------------------+---------------------------------+-------------------------+-------------------------+--------------------+---------------------+
1 row in set (0.04 sec)
According to the output, ds_0
is the write node, and both ds_1
and ds_2
are the read nodes. The database discovery rule and dynamic read/write splitting rule configuration are complete.
Syntax #
CREATE DB_DISCOVERY RULE ruleDefinition [, ruleDefinition] ...
ALTER DB_DISCOVERY RULE ruleDefinition [, ruleDefinition] ...
DROP DB_DISCOVERY RULE ruleName [, ruleName] ...
CREATE DB_DISCOVERY TYPE databaseDiscoveryTypeDefinition [, databaseDiscoveryTypeDefinition] ...
ALTER DB_DISCOVERY TYPE databaseDiscoveryTypeDefinition [, databaseDiscoveryTypeDefinition] ...
DROP DB_DISCOVERY TYPE discoveryTypeName [, discoveryTypeName] ...
CREATE DB_DISCOVERY HEARTBEAT databaseDiscoveryHeartbaetDefinition [, databaseDiscoveryHeartbaetDefinition] ...
ALTER DB_DISCOVERY HEARTBEAT databaseDiscoveryHeartbaetDefinition [, databaseDiscoveryHeartbaetDefinition] ...
DROP DB_DISCOVERY HEARTBEAT discoveryHeartbeatName [, discoveryHeartbeatName] ...
ruleDefinition:
(databaseDiscoveryRuleDefinition | databaseDiscoveryRuleConstruction)
databaseDiscoveryRuleDefinition
ruleName (resources, typeDefinition, heartbeatDefinition)
databaseDiscoveryRuleConstruction
ruleName (resources, TYPE = discoveryTypeName, HEARTBEAT = discoveryHeartbeatName)
databaseDiscoveryTypeDefinition
discoveryTypeName (typeDefinition)
databaseDiscoveryHeartbaetDefinition
discoveryHeartbeatName (PROPERTIES (properties))
resources:
RESOURCES(resourceName [, resourceName] ...)
typeDefinition:
TYPE(NAME=typeName [, PROPERTIES([properties] )] )
heartbeatDefinition
HEARTBEAT (PROPERTIES (properties))
properties:
property [, property] ...
property:
key=value
Properties description::
Name | Data Type | Descryption |
---|---|---|
discoveryTypeName | IDENTIFIER | Database discovery data type |
ruleName | IDENTIFIER | Database discovery rule name |
discoveryHeartbeatName | IDENTIFIER | Heartbeat discovery name |
typeName | STRING | Names of database discovery data types, like MySQL.MGR、 MySQL.NORMAL_REPLICATION、 openGauss.NORMAL_REPLICATION、 SphereEx:GaussDB_for_MySQL.NORMAL_REPLICATION、 SphereEx:PostgreSQL.NORMAL_REPLICATION |
storageUnitName | IDENTIFIER |
Create #
CreateDatabaseDiscoveryRule ::=
'CREATE' 'DB_DISCOVERY' 'RULE' ifNotExists? databaseDiscoveryDefinition (',' databaseDiscoveryDefinition)*
ifNotExists ::=
'IF' 'NOT' 'EXISTS'
databaseDiscoveryDefinition ::=
ruleName '(' 'STORAGE_UNITS' '(' storageUnitName (',' storageUnitName)* ')' ',' 'TYPE' '(' 'NAME' '=' typeName (',' propertiesDefinition)? ')' ',' 'HEARTBEAT' '(' propertiesDefinition ')' ')'
propertiesDefinition ::=
'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'
ruleName ::=
identifier
storageUnitName ::=
identifier
typeName ::=
identifier
discoveryHeartbeatName ::=
identifier
key ::=
string
value ::=
literal
Supplement:
discoveryType
specifies the database discovery service type.- Duplicate
ruleName
will not be created. ifNotExists
clause is used to avoidDuplicate db_discovery rule
error.
Example:
- Create a database discovery rule
discoveryType
and discoveryHeartbeat
are created at the same time when discoveryRule
is created.
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 * * * * ?'))
);
- Create a database discovery rule with
ifNotExists
clause
CREATE DB_DISCOVERY RULE IF NOT EXISTS 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 * * * * ?'))
);
Reserved words:
CREATE
, DB_DISCOVERY
, RULE
, STORAGE_UNITS
, TYPE
, NAME
, PROPERTIES
, HEARTBEAT
Query #
SHOW DB_DISCOVERY RULES #
The SHOW DB_DISCOVERY RULES syntax
is used to query database discovery rules for a specified database.
ShowDatabaseDiscoveryRule::=
'SHOW' 'DB_DISCOVERY' 'RULES' ('FROM' databaseName)?
databaseName ::=
identifier
Supplement:
- When
databaseName
is not specified, the default is the currently usedDATABASE
. IfDATABASE
is not used,No database selected
will be prompted.
Return value 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 |
Example:
- Query database discovery rules for a specified database.
mysql> SHOW DB_DISCOVERY RULES FROM discovery_db;
+------------+-------------------+--------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
| group_name | data_source_names | primary_data_source_name | discovery_type | discovery_heartbeat |
+------------+-------------------+--------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
| group_0 | ds_0,ds_1,ds_2 | ds_0 | {name=group_0_MySQL.MGR, type=MySQL.MGR, props={group-name=558edd3c-02ec-11ea-9bb3-080027e39bd2}} | {name=group_0_heartbeat, props={keep-alive-cron=0/5 * * * * ?}} |
+------------+-------------------+--------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
1 row in set (0.01 sec)
- Query database discovery rules for the current database.
mysql> SHOW DB_DISCOVERY RULES;
+------------+-------------------+--------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
| group_name | data_source_names | primary_data_source_name | discovery_type | discovery_heartbeat |
+------------+-------------------+--------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
| group_0 | ds_0,ds_1,ds_2 | ds_0 | {name=group_0_MySQL.MGR, type=MySQL.MGR, props={group-name=558edd3c-02ec-11ea-9bb3-080027e39bd2}} | {name=group_0_heartbeat, props={keep-alive-cron=0/5 * * * * ?}} |
+------------+-------------------+--------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
1 row in set (0.03 sec)
Reserved words:
SHOW
, DB_DISCOVERY
, RULES
, FROM
SHOW DB_DISCOVERY TYPES #
The SHOW DB_DISCOVERY TYPES
syntax is used to query database discovery types for a specified database.
ShowDatabaseDiscoveryType::=
'SHOW' 'DB_DISCOVERY' 'TYPES' ('FROM' databaseName)?
databaseName ::=
identifier
Supplement:
- When
databaseName
is not specified, the default is the currently usedDATABASE
. IfDATABASE
is not used,No database selected
will be prompted.
Return value description:
Column | Description |
---|---|
name | Database discovery type name |
type | Database discovery type category |
props | Database discovery type properties |
Example:
- Query database discovery types for a specified database.
mysql> SHOW DB_DISCOVERY TYPES FROM discovery_db;
+-------------------+-----------+---------------------------------------------------+
| name | type | props |
+-------------------+-----------+---------------------------------------------------+
| group_0_MySQL.MGR | MySQL.MGR | {group-name=667edd3c-02ec-11ea-9bb3-080027e39bd2} |
+-------------------+-----------+---------------------------------------------------+
1 row in set (0.01 sec)
- Query database discovery types for the current database.
mysql> SHOW DB_DISCOVERY TYPES;
+-------------------+-----------+---------------------------------------------------+
| name | type | props |
+-------------------+-----------+---------------------------------------------------+
| group_0_MySQL.MGR | MySQL.MGR | {group-name=667edd3c-02ec-11ea-9bb3-080027e39bd2} |
+-------------------+-----------+---------------------------------------------------+
1 row in set (0.00 sec)
Reserved words:
SHOW
, DB_DISCOVERY
, TYPES
, FROM
SHOW DB_DISCOVERY HEARTBEATS #
The SHOW DB_DISCOVERY HEARTBEATS
syntax is used to query database discovery heartbeats for a specified database.
ShowDatabaseDiscoveryHeartbeats::=
'SHOW' 'DB_DISCOVERY' 'HEARTBEATS' ('FROM' databaseName)?
databaseName ::=
identifier
Supplement:
- When databaseName is not specified, the default is the currently used DATABASE. If DATABASE is not used, No database selected will be prompted.
Return value description:
Column | Description |
---|---|
name | Database discovery heartbeat name |
props | Database discovery heartbeat properties |
Example:
- Query database discovery heartbeats for a specified database.
mysql> SHOW DB_DISCOVERY HEARTBEATS FROM discovery_db;
+-------------------+---------------------------------+
| name | props |
+-------------------+---------------------------------+
| group_0_heartbeat | {keep-alive-cron=0/5 * * * * ?} |
+-------------------+---------------------------------+
1 row in set (0.00 sec)
- Query database discovery heartbeats for a current database.
mysql> SHOW DB_DISCOVERY HEARTBEATS;
+-------------------+---------------------------------+
| name | props |
+-------------------+---------------------------------+
| group_0_heartbeat | {keep-alive-cron=0/5 * * * * ?} |
+-------------------+---------------------------------+
1 row in set (0.00 sec)
Reserved words:
SHOW
, DB_DISCOVERY
, HEARTBEATS
, FROM
COUNT DB_DISCOVERY RULE #
The COUNT DB_DISCOVERY RULE
syntax is used to query the number of database discovery rules for a specified database.
CountDBDiscoveryRule::=
'COUNT' 'DB_DISCOVERY' 'RULE' ('FROM' databaseName)?
databaseName ::=
identifier
Supplement:
- When
databaseName
is not specified, the default is the currently used DATABASE. If DATABASE is not used,No database selected
will be prompted.
Return value Description:
Column | Description |
---|---|
rule_name | rule type |
database | the database to which the rule belongs |
count | the number of the rule |
Example:
- Query the number of database discovery rules for a specified database.
mysql> COUNT DB_DISCOVERY RULE FROM discovery_db;
+--------------+-----------------+-------+
| rule_name | database | count |
+--------------+-----------------+-------+
| db_discovery | discovery_db | 1 |
+--------------+-----------------+-------+
1 row in set (0.00 sec)
- Query the number of database discovery rules for a current database.
mysql> COUNT DB_DISCOVERY RULE;
+--------------+-----------------+-------+
| rule_name | database | count |
+--------------+-----------------+-------+
| db_discovery | discovery_db | 1 |
+--------------+-----------------+-------+
1 row in set (0.00 sec)
Reserved word:
COUNT
, DB_DISCOVERY
, RULE
, FROM
Alter #
AlterDatabaseDiscoveryRule ::=
'ALTER' 'DB_DISCOVERY' 'RULE' databaseDiscoveryDefinition (',' databaseDiscoveryDefinition)*
databaseDiscoveryDefinition ::=
ruleName '(' 'STORAGE_UNITS' '(' storageUnitName (',' storageUnitName)* ')' ',' 'TYPE' '(' 'NAME' '=' typeName (',' propertiesDefinition)? ')' ',' 'HEARTBEAT' '(' propertiesDefinition ')' ')'
propertiesDefinition ::=
'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'
ruleName ::=
identifier
storageUnitName ::=
identifier
typeName ::=
identifier
discoveryHeartbeatName ::=
identifier
key ::=
string
value ::=
literal
Supplement:
discoveryType
specifies the database discovery service type.
Example:
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 * * * * ?'))
);
Reserved word:
ALTER
, DB_DISCOVERY
, RULE
, STORAGE_UNITS
, TYPE
, NAME
, PROPERTIES
, HEARTBEAT
Drop #
- Drop database discovery rule
DROP DB_DISCOVERY RULE db_discovery_group_0;
- Drop database discovery type
DROP DB_DISCOVERY TYPE db_discovery_group_0_mgr;
- Drop database discovery heartbeat
DROP DB_DISCOVERY HEARTBEAT db_discovery_group_0_heartbeat;