CN114138746A - Database monitoring method, device, equipment and storage medium - Google Patents

Database monitoring method, device, equipment and storage medium Download PDF

Info

Publication number
CN114138746A
CN114138746A CN202111446675.5A CN202111446675A CN114138746A CN 114138746 A CN114138746 A CN 114138746A CN 202111446675 A CN202111446675 A CN 202111446675A CN 114138746 A CN114138746 A CN 114138746A
Authority
CN
China
Prior art keywords
data
monitoring
initial
database
data structure
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111446675.5A
Other languages
Chinese (zh)
Inventor
刘钱
丁静
宋大伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Purple Flame Network Technology Co ltd
Original Assignee
Suzhou Purple Flame Network Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Purple Flame Network Technology Co ltd filed Critical Suzhou Purple Flame Network Technology Co ltd
Priority to CN202111446675.5A priority Critical patent/CN114138746A/en
Publication of CN114138746A publication Critical patent/CN114138746A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a database monitoring method, a database monitoring device, database monitoring equipment and a storage medium. The method comprises the following steps: generating initial record data according to an initial data structure of a target database; under the condition that the target database is determined to execute the data structure updating operation, generating sub-record data according to the data structure updating operation; and under the condition that the target database executes the data access operation, determining the current data structure of the target database according to the initial record data and the sub-record data, and monitoring the data access operation according to the current data structure. The embodiment of the invention can improve the metadata synchronization efficiency, save resources occupied by database monitoring and ensure the real-time property, the correctness and the effectiveness of the database monitoring.

Description

Database monitoring method, device, equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a database monitoring method, a database monitoring device, database monitoring equipment and a storage medium.
Background
During the operation of the database, it is usually necessary to monitor and record the data operations occurring therein, so as to check and recover the data in the database, etc. if necessary.
In the prior art, a monitoring program can monitor and record data in a database, and generate and record metadata according to a data structure in the database. When a data structure change occurs in a monitored database, the metadata synchronization method provided in the prior art mainly includes two methods, i.e., manual registration, and detecting the data structure change and updating metadata at a fixed period.
However, in the above method provided by the prior art, the update of the metadata by the monitor program cannot be completely synchronized with the update of the database data structure, and in the process of updating the metadata, the time consumed by the monitor program and the running memory easily cause the update of the metadata to be untimely or the update to fail, and the metadata in the monitor program cannot correctly record the data structure in the database, which may cause the abnormal monitoring of the subsequent data operation.
Disclosure of Invention
Embodiments of the present invention provide a database monitoring method, apparatus, device, and storage medium, so as to improve metadata synchronization efficiency, save resources occupied by database monitoring, and ensure real-time performance, correctness, and validity of database monitoring.
In a first aspect, an embodiment of the present invention provides a database monitoring method, including:
generating initial record data according to an initial data structure of a target database;
under the condition that the target database is determined to execute the data structure updating operation, generating sub-record data according to the data structure updating operation;
and under the condition that the target database executes the data access operation, determining the current data structure of the target database according to the initial record data and the sub-record data, and monitoring the data access operation according to the current data structure.
In a second aspect, an embodiment of the present invention further provides a database monitoring apparatus, including:
the initial record generation module is used for generating initial record data according to an initial data structure of the target database;
the sub-record generation module is used for generating sub-record data according to the data structure updating operation under the condition that the target database is determined to execute the data structure updating operation;
and the data access monitoring module is used for determining the current data structure of the target database according to the initial record data and the sub-record data and monitoring the data access operation according to the current data structure under the condition that the target database executes the data access operation.
In a third aspect, an embodiment of the present invention further provides a computer device, where the computer device includes:
one or more processors;
storage means for storing one or more programs;
when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the database monitoring method provided by any embodiment of the invention.
In a fourth aspect, an embodiment of the present invention further provides a computer storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the database monitoring method provided in any embodiment of the present invention.
The embodiment of the invention generates the initial record data according to the initial data structure of the monitored target database, and generates the sub-record data according to the data structure updating operation under the condition of determining that the target database executes the data structure updating operation, so that the current data structure of the target database can be determined according to the initial record data and the sub-record data under the condition of determining that the target database executes the data access operation, the data access operation is monitored according to the current data structure, the data structure updating of the target database is synchronously recorded under the condition of not repeatedly updating the initial record data, the technical problems of untimely updating of metadata and larger memory consumption in the prior art are avoided, the metadata synchronization efficiency is improved, the resources occupied by database monitoring are saved, and the real-time performance of database monitoring are guaranteed, Correctness and validity.
Drawings
Fig. 1 is a flowchart of a database monitoring method according to an embodiment of the present invention.
Fig. 2 is a flowchart of a database monitoring method according to a second embodiment of the present invention.
Fig. 3 is a flowchart of a database monitoring method according to a third embodiment of the present invention.
Fig. 4 is a schematic structural diagram of a database monitoring apparatus according to a fourth embodiment of the present invention.
Fig. 5 is a schematic structural diagram of a computer device according to a fifth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention.
It should be further noted that, for the convenience of description, only some but not all of the relevant aspects of the present invention are shown in the drawings. Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently or simultaneously. In addition, the order of the operations may be re-arranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figure. The processes may correspond to methods, functions, procedures, subroutines, and the like.
Example one
Fig. 1 is a flowchart of a database monitoring method according to an embodiment of the present invention, where the present embodiment is applicable to a case where data operations in a database are monitored in real time, and the method may be executed by a database monitoring apparatus according to an embodiment of the present invention, where the apparatus may be implemented by software and/or hardware, and may be generally integrated in a computer device. Accordingly, as shown in fig. 1, the method comprises the following operations:
and S110, generating initial record data according to the initial data structure of the target database.
Wherein the target database may be a monitored database. The initial data structure may be the data structure of the target database at the beginning of monitoring of the target database. The initial record data may be data that records an initial data structure of the target database, i.e., metadata corresponding to the initial data structure of the target database. Specifically, the data structure of the database may include at least one of a library structure, a table structure, a view, a tree, and a database index, and may also be a data structure that may be included in any other database, which is not limited herein.
Accordingly, the database monitoring method provided by the embodiment of the present invention may be executed by a database monitoring program, and the database monitoring program may include any database monitoring program and/or any program having a database monitoring function. When the database monitoring program starts to run, the target database may be monitored, and at this time, the initial data structure of the target database may be monitored, for example, the detailed information of the database and the table of the target database read after the database monitoring program starts to run may be read, so that the initial record data may be generated according to the initial data structure of the target database. Alternatively, the initial record data may be generated according to the initial data structure of the target database by any implementable method, for example, a method for recording metadata by a database monitor, which is not limited herein.
And S120, generating sub-record data according to the data structure updating operation under the condition that the target database is determined to execute the data structure updating operation.
Wherein the data structure update operation may be an operation that changes the data structure of the target database. The sub-record data may be data of a data structure update operation in the record target database.
Correspondingly, the database monitoring program can monitor any data operation of the target database in the running process. The data operation in the target database may then include a data structure update operation, such as making a change to its table structure, etc. In the case that the target database is monitored to execute the data structure updating operation, it can be determined that the data structure in the target database is changed, and the data structure updating operation executed by the target database can be recorded in the sub-record data so as to record the condition of each data structure change of the target database.
The generation of the sub-record data according to the data structure updating operation means that the sub-record data can be generated only according to the data structure updating operation without acquiring the data structure before or after the data structure updating operation is performed on the target database, that is, the data structure of the sub-record data recorded in the sub-record data is changed only by the target database through the data structure updating operation without recording the specific data structure before and after the change. Therefore, in the process of generating the sub-record data, the data structure of the target database does not need to be acquired, or any data for recording the data structure of the target database, such as the initial record data and the generated sub-record data, is not needed, so that the generation efficiency of the sub-record data can be improved, and the running memory resource consumed by generating the sub-record data can be saved.
S130, under the condition that the target database executes the data access operation, determining the current data structure of the target database according to the initial record data and the sub-record data, and monitoring the data access operation according to the current data structure.
Wherein the data access operation may be an operation that changes data stored in the target database. The current data structure may be the data structure of the target database at the current time.
Accordingly, the data operation in the target database may include a data access operation, which may be, for example, a read operation or a write operation on data. In the case that the target database is monitored to execute the data access operation, it may be determined that data in the target database changes, and the database monitoring program needs to determine data that needs to be changed according to a data structure of the target database, so as to record a change condition of the data, so as to monitor the data access operation.
Therefore, in the process of monitoring the data access operation of the target database, in order to determine the data to be changed and record the correct data change situation, the current data structure needs to be determined. Specifically, the initial data structure of the target database obtained when the database monitor starts to run may be determined according to the initial recorded data, and the data structure update operation performed by the target database at the time when the database monitor starts to run to the present time may be determined according to the sub-recorded data, so as to determine the change condition of the initial data structure. And according to the determined initial data structure and the change condition thereof, obtaining the current data structure of the target database, and monitoring the data access operation according to the current data structure.
For example, if data needs to be written in column1 in table1 when the target database executes a data access operation, it needs to be determined that the new column1 in table1 writes needed data in new column1 after the deletion operation is completed if column1 in the initial data structure of the target database is deleted by a data structure update operation executed according to the target database; therefore, in order to record the data writing operation, the database monitoring program also needs to determine the table and the column to which the data writing is directed according to the recorded data structure, so as to correctly monitor and record the data writing operation.
The embodiment of the invention provides a database monitoring method, which generates initial record data according to an initial data structure of a monitored target database, generates sub-record data according to data structure updating operation under the condition of determining that the target database executes data structure updating operation, can determine the current data structure of the target database according to the initial record data and the sub-record data under the condition of determining that the target database executes data access operation, monitors the data access operation according to the current data structure, realizes synchronous recording of data structure updating of the target database under the condition of not repeatedly updating the initial record data, avoids the technical problems of untimely updating of metadata and larger consumption of memory in the prior art, improves the synchronization efficiency of the metadata, saves resources occupied by database monitoring, the real-time performance, the correctness and the effectiveness of database monitoring are guaranteed.
Example two
Fig. 2 is a flowchart of a database monitoring method according to a second embodiment of the present invention. The embodiment of the present invention is embodied on the basis of the above-described embodiment, and in the embodiment of the present invention, a specific optional implementation manner for generating the initial record data according to the initial data structure of the target database is provided.
As shown in fig. 2, the method of the embodiment of the present invention specifically includes:
and S210, generating initial record data according to the initial data structure of the target database.
In an optional embodiment of the present invention, after the generating initial record data according to the initial data structure of the target database, the method may further include: and loading the initial record data into a monitoring operation memory space.
The monitoring operation memory space may be a memory space in which the database monitoring program operates.
Correspondingly, after the initial record data is generated, the initial record data can be loaded into the monitoring operation memory space, and the database monitoring program can directly load the initial record data through the monitoring operation memory space in the subsequent operation process, so that the initial data structure of the target database is determined, the efficiency of the database monitoring program is further improved, and the real-time performance of monitoring the target database is optimized.
In an optional embodiment of the present invention, S210 may specifically include:
s211, a target structure record table of the target structure type is created in the monitoring initial starting process.
The monitoring initial starting process may be a process in which the database monitoring program is initialized at the beginning of the starting operation. The target structure type may be a data structure type of a target database that needs to be monitored. The target structure record table may be a data table that records a data structure of a target structure type of the target database.
Correspondingly, when the database monitoring program starts, the initial starting process of monitoring needs to be entered first, and the initialization configuration of the database monitoring program is completed in the process. Then a target structure record table of target structure types may be created during the initial startup of the monitoring. Specifically, the target structure type may be determined according to a data structure type to be monitored in the target database, for example, the target structure type may include a database, a database object, a data table, and a data column, and the corresponding target structure record table may include a data table for respectively recording the data structures.
S212, obtaining the initial data structure of the target structure type in the target database.
Correspondingly, after the target structure record table of the target structure type is created, the database monitoring program can start monitoring the target database, so that the real-time data structure of the target database is obtained when the operation is started, namely the initial data structure. Specifically, the database monitoring program may monitor a library, a table, a view, and other arbitrary data objects of the target database when the database monitoring program starts to run, so as to determine a real-time data structure of the target database according to the monitored data objects, where the real-time data structure includes a data structure of a target structure type, that is, the real-time data structure may be determined as an initial data structure.
S213, storing the initial data structure into the target structure record table, and generating the initial record data.
Correspondingly, the target structure record table created by the database monitoring program in the monitoring initial starting process may correspond to the target structure type, and similarly, the initial data structure also includes a data structure of the target structure type. Therefore, according to the target structure types of the initial record data of the respective parts, the initial record data of the parts are respectively stored into the target structure record tables corresponding to the same target structure types, and the target structure record table in which the initial data structure is stored is determined as the initial record data, so that the initial record data stores the initial data structure of the target structure type.
And S220, under the condition that the target database is determined to execute the data structure updating operation, generating sub-record data according to the data structure updating operation.
In an optional embodiment of the present invention, the generating the sub-record data according to the data structure updating operation may include: acquiring an updating operation statement of the data structure updating operation; and storing the update operation statement into a target update field of the target structure record table to generate the sub-record data.
Wherein the update operation statement may be an instruction statement that changes a data structure in the target database. The target update field may be a field in the target structure record table for recording an update operation statement.
Correspondingly, when a program or a user associated with the target database needs to make any form of change on the data structure of the target database, a corresponding update operation statement can be sent to the target database. The target database can execute corresponding data structure updating operation according to the received updating operation statement, so that the data structure of the target database can be updated according to the requirements of the associated program or the user. Therefore, in order to record the data structure change condition of the target database, the update operation statement received by the target database each time can be acquired, and the update operation statement is stored in the target update field of the target structure record table to generate the sub-record data, and then the update operation statement corresponding to the data structure update operation performed by the target database each time can be stored in the sub-record data, so as to record the change condition of the data structure of the target database.
In an optional embodiment of the present invention, after the generating the sub-record data according to the data structure updating operation, the method may further include: and establishing an associated loading relation between the sub-record data and the initial record data.
The associated loading relationship may be used to describe a sequential relationship in which a data structure update operation recorded in the sub-record data changes an initial data structure recorded in the initial record data.
Correspondingly, the sub-record data is generated according to the data structure updating operation, and the data structure of the target database recorded in the sub-record data is changed from the initial data structure through each data structure updating operation. After the database monitor program starts to run, the first data structure updating operation is performed based on the initial data structure, and each data structure updating operation of the second time and the later is performed based on the data structure after the previous data structure updating operation. Therefore, each time the target database executes the data structure change formed by the data structure updating operation, the changes made to the initial data structure are overlapped according to the execution sequence, and the sequential relationship formed by the changes made to the initial data structure by each data structure updating operation can be described by establishing the associated loading relationship between the sub-record data and the initial record data.
And S230, under the condition that the target database executes the data access operation, determining the current data structure of the target database according to the initial record data and the sub-record data, and monitoring the data access operation according to the current data structure.
In an optional embodiment of the present invention, the determining the current data structure of the target database according to the initial record data and the sub-record data may include: loading the initial record data; and sequentially acquiring and loading all the sub-record data according to the associated loading relation of the initial record data.
Accordingly, in the case where it is determined that the target database performs the data access operation, the initial record data may be loaded first to determine the initial data structure of the target database from the record of the initial record data. Further, the sequential relationship of the change of the data structure updating operation recorded in each sub-record data to the initial data structure recorded in the initial record data can be determined according to the description of the associated loading relationship of the initial record data, and all the sub-record data can be sequentially acquired and loaded, so that each data structure updating operation and the execution sequence of changing the data structure of the target database based on the initial data structure can be determined until all the sub-record data are loaded, and the current data structure after the execution of all the data structure updating operations is determined.
The embodiment of the invention provides a database monitoring method, which generates initial record data according to an initial data structure of a monitored target database, generates sub-record data according to data structure updating operation under the condition of determining that the target database executes data structure updating operation, can determine the current data structure of the target database according to the initial record data and the sub-record data under the condition of determining that the target database executes data access operation, monitors the data access operation according to the current data structure, realizes synchronous recording of data structure updating of the target database under the condition of not repeatedly updating the initial record data, avoids the technical problems of untimely updating of metadata and larger consumption of memory in the prior art, improves the synchronization efficiency of the metadata, saves resources occupied by database monitoring, the real-time performance, the correctness and the effectiveness of database monitoring are guaranteed; furthermore, the initial record data and all the sub-record data are automatically and sequentially loaded according to the association loading relationship by establishing the association loading relationship between the initial record data and the sub-record data, so that the current data structure of the target database is determined, and the efficiency and the accuracy of monitoring the data structure of the target database are further improved.
EXAMPLE III
Fig. 3 is a flowchart of a database monitoring method according to a third embodiment of the present invention. The embodiment of the present invention is embodied on the basis of the above embodiment, and in the embodiment of the present invention, update time data for acquiring the sub-record data is further provided; and executing an implementation mode of monitoring restart operation under the condition that the interval between the updated time data and the current time is larger than a preset interval threshold value.
As shown in fig. 3, the method of the embodiment of the present invention specifically includes:
and S310, generating initial record data according to the initial data structure of the target database.
And S320, generating sub-record data according to the data structure updating operation under the condition that the target database is determined to execute the data structure updating operation.
S330, under the condition that the target database executes the data access operation, determining the current data structure of the target database according to the initial record data and the sub-record data, and monitoring the data access operation according to the current data structure.
And S340, acquiring the updating time data of the sub-record data.
Wherein the update time data may be a time of the last generation of the sub-record data.
Accordingly, the time of the most recent generation of the sub-record data can be acquired as the update time data of the sub-record data according to the generation time of each sub-record data by recording the generation time of each sub-record data.
And S350, executing monitoring restart operation under the condition that the interval between the updated time data and the current time is larger than a preset interval threshold value.
The preset interval threshold may be any preset time length, and optionally, may be a preset time length according to an empirical value of a maximum time that may be an interval between two consecutive data structure update operations performed for the same data structure requirement. The monitoring restart operation may be an operation to restart the database monitoring program.
Accordingly, in order to satisfy the same requirement of the program or user associated with the target database for the data structure of the target database, the data structure of the target database often needs to be changed once or more, and the target database may correspondingly perform one or more data structure updating operations within a relatively centralized period of time. In contrast, when any requirement is satisfied, it is necessary to wait for the next data structure requirement of the associated program or the user to appear before the next data structure updating operation may be correspondingly performed.
Therefore, the preset interval threshold value can be determined according to the requirement on the performance of the database monitoring program or according to the empirical value of the maximum time interval between two continuous data structure updating operations corresponding to the same requirement. Further, the interval between the update time data and the current time can be obtained by obtaining the update time data of the sub-record data and comparing the update time data with the current time. If the interval is greater than the preset interval threshold, the interval between the time when the target database executes the data structure updating operation next time and the time when the target database executes the data structure updating operation last time is greater than the preset interval threshold, which may indicate that the current data structure of the target database is less likely to be updated temporarily.
Further, a monitor restart operation may be performed for the above case. After the monitoring restart operation is executed, the database monitoring program can enter the state of starting to run again, the data structure of the target database can be obtained again, and the current data structure can be used as the restarted initial data structure to correspondingly generate new initial record data. Because the current data structure is less likely to be updated temporarily, under the condition that no further update occurs, the restarted database monitoring program can directly determine the real-time data structure of the target database according to the regenerated initial record data within a long period of time, a large amount of sub-record data does not need to be generated and repeatedly loaded on the initial record data and the sub-record data, and the memory resource consumed by the operation of the database monitoring program is saved.
Optionally, the obtaining of the update time data of the sub-record data may include: and acquiring the updating time data of the sub-record data at the preset detection time.
The preset detection time may be any time preset as required to obtain the update time data of the sub-record data.
Correspondingly, in the running process of the database monitoring program, the update time data of the sub-record data can be acquired at the preset detection time, so that whether the database monitoring program needs to execute the monitoring restart operation or not is periodically detected. Further optionally, the preset detection time may be determined according to a preset detection time period, that is, in the process of running the database monitoring program, the update time data of the sub-record data may be acquired every other detection time period, so as to determine whether the database monitoring program needs to perform the monitoring restart operation according to the current time and the update time data.
Optionally, under the condition that the target database does not perform any data structure updating operation, if the update time data of the acquired sub-record data is null, it is determined that the monitoring restart operation does not need to be performed; or, before the update time data of the sub-record data is acquired, determining whether the sub-record data having the associated loading relation with the initial record data exists, if so, continuing to acquire the update time data of the sub-record data; executing a monitoring restart operation under the condition that the interval between the updated time data and the current time is larger than a preset interval threshold value; and if not, determining that the monitoring restart operation does not need to be executed.
In an optional embodiment of the present invention, the performing the monitoring restart operation may include: acquiring identification data of a current monitoring process; sending an auxiliary restarting request to an auxiliary restarting program according to the current monitoring process identification data so that the auxiliary restarting program carries out monitoring starting operation under the condition of determining monitoring shutdown; and deleting the initial recorded data and the sub-recorded data, and executing a monitoring shutdown operation so that the auxiliary restart program determines the monitoring shutdown condition according to the monitoring shutdown operation.
The current monitoring process identification data may be data uniquely representing the currently running database monitoring program. The secondary reboot program may be a program for initiating a database monitor. The auxiliary restart request may be used to request the auxiliary restart program to perform a monitoring startup operation in the event that the monitoring shutdown is determined. The monitor off condition may be a condition in which the database monitor is in an off state. The monitoring start operation may be an operation to start a database monitoring program. The monitor shutdown operation may be an operation in which the database monitor enters a shutdown state.
Correspondingly, when the database monitoring program executes the monitoring restart operation to restart the database monitoring program, the database monitoring program can acquire the identification data of the current monitoring process according to the current running process of the database monitoring program, and send an auxiliary restart request to the auxiliary restart program according to the identification data of the current monitoring process. The auxiliary restart program can know that the database monitoring program represented by the current monitoring process identification data needs to be restarted according to the received auxiliary restart request, and then the database monitoring program can be started under the condition of determining that the monitoring is closed.
Further, before the monitoring shutdown operation is executed, the database monitoring program may delete the initial record data and the sub-record data, so that the database monitoring program may regenerate new initial record data after being restarted, and generate new sub-record data according to the data structure update operation of the target database. After deleting the current initial recorded data and the sub-recorded data, the monitoring closing operation can be executed, so that the self enters a closing state. The auxiliary restart program may start the database monitor program according to the auxiliary restart request under the condition that the auxiliary restart program determines that the database monitor program enters the shutdown state.
In an optional embodiment of the present invention, before the performing the monitoring restart operation, the method may further include: generating position record data according to the current monitoring operation position; and storing the position record data so as to obtain the position record data after the execution of the monitoring restart operation is finished and perform monitoring initial start according to the position record data.
The current monitoring operation position may be a position where the database monitoring program operates at the current time. The location record data may be data that records the current monitored operating location of the database monitor. The monitoring initial start may be an initial start of a database monitoring program.
Correspondingly, before the database monitoring program executes the monitoring restart operation, position record data can be generated according to the current monitoring operation position of the database monitoring program, and the position record data can be stored. The stored position record data can be read, when the database monitoring program executes the monitoring restart operation and is started by the auxiliary restart program, the position record data can be read, and the monitoring initial start is carried out according to the position record data so as to continue to operate according to the operation position before the monitoring restart operation.
For example, the database monitoring method provided by the embodiment of the present invention may monitor the MySQL database through a binlog log program, where the binlog program may record SQL (Structured Query Language) statements that may or may not change data, and store the SQL statements in a binary form in a disk. In one specific example, tables locations, heartbeats, schemas, tables, databases, and columns are first dynamically created. Wherein the tables locations are used for recording the running position of the binlog log program, the tables heartbeat signals of the program, and the tables schemas, tables, databases and columns are respectively used for recording the data structures of the corresponding types. After the program is started, detailed information such as databases, tables and the like can be automatically synchronized to tables schema, datbases, tables and columns from the monitored MySQL database respectively to obtain metadata, and after the metadata is synchronized to the tables, the program can load the information to the memory. In the normal operation process of the program, the monitored MySQL database information can be created in the table schema, and the information such as the name of the current binlog log file and the current offset can be recorded. If the table in the monitored MySQL database is changed in structure, such as adding a field or changing the name of a field, the program will receive the DDL (Data Definition Language) statement, which may be "alter table", for example. After receiving the DDL statement, the program adds a new record, records the DDL statement to a deltas field in the schema table, and establishes an association relationship with a value in the schema table synchronized for the first time, specifically, the first record may be a parent record, and the records thereafter are all child records. When a new statement is transmitted, if the statement is a DML (Data management Language) statement, for example, "insert table values ()", and since the table structure has been changed, the program may reload the DDL statements in all records from the first record until the DDL statements are loaded as the latest changed metadata, thereby ensuring that the DDL statements are consistent with the online metadata.
Further, a timing task every 5 minutes may be set in the monitoring program, and every 5 minutes, it is checked whether the fields of the deltas in the schema table are empty, if not, it is determined whether the last recorded time and the current time are greater than 1 hour, and if so, the program may obtain a current PID (Process Identifier) value and notify another initiator to send a restart request. After the program sends a request, the tables schemas, tables, databases and columns can be all deleted, and after the table is successfully deleted, the program can report an error and launch (close), and the notified startup program can restart the launched monitoring program.
The embodiment of the invention provides a database monitoring method, which generates initial record data according to an initial data structure of a monitored target database, generates sub-record data according to data structure updating operation under the condition of determining that the target database executes data structure updating operation, can determine the current data structure of the target database according to the initial record data and the sub-record data under the condition of determining that the target database executes data access operation, monitors the data access operation according to the current data structure, realizes synchronous recording of data structure updating of the target database under the condition of not repeatedly updating the initial record data, avoids the technical problems of untimely updating of metadata and larger consumption of memory in the prior art, improves the synchronization efficiency of the metadata, saves resources occupied by database monitoring, the real-time performance, the correctness and the effectiveness of database monitoring are guaranteed; furthermore, the database monitoring program can be automatically restarted under the condition that the data structure of the target database is updated for a long time, so that the database monitoring program can obtain the initial record data of the target database again, a large amount of sub-record data still needs to be repeatedly loaded under the condition that the data structure is stable, the metadata updating efficiency is further improved, and the running memory resource consumed by database monitoring is saved.
Example four
Fig. 4 is a schematic structural diagram of a database monitoring apparatus according to a fourth embodiment of the present invention, as shown in fig. 4, the apparatus includes: an initial record generation module 410, a sub-record generation module 420, and a data access monitoring module 430.
The initial record generating module 410 is configured to generate initial record data according to an initial data structure of the target database.
And a sub-record generating module 420, configured to generate sub-record data according to the data structure updating operation when it is determined that the target database executes the data structure updating operation.
And a data access monitoring module 430, configured to determine, when it is determined that the target database executes a data access operation, a current data structure of the target database according to the initial record data and the sub-record data, and monitor the data access operation according to the current data structure.
In an optional implementation manner of the embodiment of the present invention, the initial record generating module 410 may be specifically configured to: creating a target structure record table of a target structure type in a monitoring initial starting process; acquiring the initial data structure of the target structure type in the target database; and storing the initial data structure into the target structure record table to generate the initial record data.
In an optional implementation manner of the embodiment of the present invention, the sub-record generating module 420 may be specifically configured to: acquiring an updating operation statement of the data structure updating operation; and storing the update operation statement into a target update field of the target structure record table to generate the sub-record data.
In an optional implementation manner of the embodiment of the present invention, the sub-record generating module 420 may be further configured to: after the sub-record data are generated according to the data structure updating operation, establishing an associated loading relation between the sub-record data and the initial record data; the data access monitoring module 430 may be specifically configured to: loading the initial record data; and sequentially acquiring and loading all the sub-record data according to the associated loading relation of the initial record data.
In an optional implementation manner of the embodiment of the present invention, the apparatus may further include: the monitoring restart module is used for acquiring the updating time data of the sub-record data; and executing a monitoring restart operation under the condition that the interval between the updated time data and the current time is larger than a preset interval threshold value.
In an optional implementation manner of the embodiment of the present invention, the monitoring restart module may be specifically configured to: acquiring identification data of a current monitoring process; sending an auxiliary restarting request to an auxiliary restarting program according to the current monitoring process identification data so that the auxiliary restarting program carries out monitoring starting operation under the condition of determining monitoring shutdown; and deleting the initial recorded data and the sub-recorded data, and executing a monitoring shutdown operation so that the auxiliary restart program determines the monitoring shutdown condition according to the monitoring shutdown operation.
In an optional implementation manner of the embodiment of the present invention, the monitoring restart module may be further configured to: generating position record data according to the current monitoring running position before the monitoring restarting operation is executed; and storing the position record data so as to obtain the position record data after the execution of the monitoring restart operation is finished and perform monitoring initial start according to the position record data.
The device can execute the database monitoring method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects for executing the method.
The embodiment of the invention provides a database monitoring device, which generates initial record data according to an initial data structure of a monitored target database, generates sub-record data according to data structure updating operation under the condition of determining that the target database executes data structure updating operation, can determine the current data structure of the target database according to the initial record data and the sub-record data under the condition of determining that the target database executes data access operation, monitors the data access operation according to the current data structure, realizes synchronous recording of data structure updating of the target database under the condition of not repeatedly updating the initial record data, avoids the technical problems of untimely updating of metadata and larger consumption of internal memory in the prior art, improves the synchronization efficiency of the metadata, saves resources occupied by database monitoring, the real-time performance, the correctness and the effectiveness of database monitoring are guaranteed.
EXAMPLE five
Fig. 5 is a schematic structural diagram of a computer device according to a fifth embodiment of the present invention. FIG. 5 illustrates a block diagram of an exemplary computer device 12 suitable for use in implementing embodiments of the present invention. The computer device 12 shown in FIG. 5 is only an example and should not bring any limitations to the functionality or scope of use of embodiments of the present invention.
As shown in FIG. 5, computer device 12 is in the form of a general purpose computing device. The components of computer device 12 may include, but are not limited to: one or more processors 16, a memory 28, and a bus 18 that connects the various system components (including the memory 28 and the processors 16).
Bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Computer device 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by computer device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)30 and/or cache memory 32. Computer device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, and commonly referred to as a "hard drive"). Although not shown in FIG. 5, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
Computer device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), with one or more devices that enable a user to interact with computer device 12, and/or with any devices (e.g., network card, modem, etc.) that enable computer device 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 22. Also, computer device 12 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with the other modules of computer device 12 via bus 18. It should be appreciated that although not shown in FIG. 5, other hardware and/or software modules may be used in conjunction with computer device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processor 16 executes various functional applications and data processing by running the program stored in the memory 28, so as to implement the database monitoring method provided by the embodiment of the present invention: generating initial record data according to an initial data structure of a target database; under the condition that the target database is determined to execute the data structure updating operation, generating sub-record data according to the data structure updating operation; and under the condition that the target database executes the data access operation, determining the current data structure of the target database according to the initial record data and the sub-record data, and monitoring the data access operation according to the current data structure.
EXAMPLE six
A sixth embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the method for monitoring a database provided in the sixth embodiment of the present invention is implemented: generating initial record data according to an initial data structure of a target database; under the condition that the target database is determined to execute the data structure updating operation, generating sub-record data according to the data structure updating operation; and under the condition that the target database executes the data access operation, determining the current data structure of the target database according to the initial record data and the sub-record data, and monitoring the data access operation according to the current data structure.
Any combination of one or more computer-readable media may be employed. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or computer device. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A database monitoring method, comprising:
generating initial record data according to an initial data structure of a target database;
under the condition that the target database is determined to execute the data structure updating operation, generating sub-record data according to the data structure updating operation;
and under the condition that the target database executes the data access operation, determining the current data structure of the target database according to the initial record data and the sub-record data, and monitoring the data access operation according to the current data structure.
2. The method of claim 1, wherein generating initial record data from the initial data structure of the target database comprises:
creating a target structure record table of a target structure type in a monitoring initial starting process;
acquiring the initial data structure of the target structure type in the target database;
and storing the initial data structure into the target structure record table to generate the initial record data.
3. The method of claim 2, wherein generating sub-record data according to the data structure update operation comprises:
acquiring an updating operation statement of the data structure updating operation;
and storing the update operation statement into a target update field of the target structure record table to generate the sub-record data.
4. The method of claim 1, further comprising, after the generating sub-record data according to the data structure update operation:
establishing an associated loading relation between the sub-record data and the initial record data;
determining a current data structure of the target database according to the initial record data and the sub-record data, including:
loading the initial record data;
and sequentially acquiring and loading all the sub-record data according to the associated loading relation of the initial record data.
5. The method of claim 1, further comprising:
acquiring updating time data of the sub-record data;
and executing a monitoring restart operation under the condition that the interval between the updated time data and the current time is larger than a preset interval threshold value.
6. The method of claim 5, wherein performing a monitored restart operation comprises:
acquiring identification data of a current monitoring process;
sending an auxiliary restarting request to an auxiliary restarting program according to the current monitoring process identification data so that the auxiliary restarting program carries out monitoring starting operation under the condition of determining monitoring shutdown;
and deleting the initial recorded data and the sub-recorded data, and executing a monitoring shutdown operation so that the auxiliary restart program determines the monitoring shutdown condition according to the monitoring shutdown operation.
7. The method of claim 5 or 6, further comprising, prior to said performing a monitored restart operation:
generating position record data according to the current monitoring operation position;
and storing the position record data so as to obtain the position record data after the execution of the monitoring restart operation is finished and perform monitoring initial start according to the position record data.
8. A database monitoring apparatus, comprising:
the initial record generation module is used for generating initial record data according to an initial data structure of the target database;
the sub-record generation module is used for generating sub-record data according to the data structure updating operation under the condition that the target database is determined to execute the data structure updating operation;
and the data access monitoring module is used for determining the current data structure of the target database according to the initial record data and the sub-record data and monitoring the data access operation according to the current data structure under the condition that the target database executes the data access operation.
9. A computer device, characterized in that the computer device comprises:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the database monitoring method of any of claims 1-7.
10. A computer storage medium on which a computer program is stored, which program, when being executed by a processor, is adapted to carry out a database monitoring method according to any one of claims 1-7.
CN202111446675.5A 2021-11-30 2021-11-30 Database monitoring method, device, equipment and storage medium Pending CN114138746A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111446675.5A CN114138746A (en) 2021-11-30 2021-11-30 Database monitoring method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111446675.5A CN114138746A (en) 2021-11-30 2021-11-30 Database monitoring method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114138746A true CN114138746A (en) 2022-03-04

Family

ID=80386219

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111446675.5A Pending CN114138746A (en) 2021-11-30 2021-11-30 Database monitoring method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114138746A (en)

Similar Documents

Publication Publication Date Title
US10437578B2 (en) Orchestration of software applications upgrade using automatic hang detection
CN107506451B (en) Abnormal information monitoring method and device for data interaction
US9886439B2 (en) Archival management of database logs
CN107515874B (en) Method and equipment for synchronizing incremental data in distributed non-relational database
CN109471851B (en) Data processing method, device, server and storage medium
US9652492B2 (en) Out-of-order execution of strictly-ordered transactional workloads
CN106874281B (en) Method and device for realizing database read-write separation
CN111078717A (en) Database and cache consistency synchronization method and device, computer equipment and storage medium
US9910733B2 (en) Transaction completion in a synchronous replication environment
CN113438275B (en) Data migration method and device, storage medium and data migration equipment
CN113868028A (en) Method for replaying log on data node, data node and system
CN112579307A (en) Physical lock resource allocation detection method and device and electronic equipment
KR20140047448A (en) Client and database server for resumable transaction and method thereof
CN112765126B (en) Database transaction management method, device, computer equipment and storage medium
CN118069745A (en) SQL SERVER increment acquisition method, storage medium and equipment based on transaction log
US9031969B2 (en) Guaranteed in-flight SQL insert operation support during an RAC database failover
CN112925796A (en) Write consistency control method, device, equipment and storage medium
US9015116B2 (en) Consistent replication of transactional updates
CN111444208B (en) Data updating method and related equipment
CN114138746A (en) Database monitoring method, device, equipment and storage medium
US8630976B2 (en) Fast search replication synchronization processes
CN112749156A (en) Data processing method, database management system and data processing equipment
CN117171266B (en) Data synchronization method, device, equipment and storage medium
CN113434509B (en) Increment index updating method and device, storage medium and electronic equipment
CN117390040B (en) Service request processing method, device and storage medium based on real-time wide table

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination