A database early warning method and system for an automated operation system
By obtaining and optimizing the execution time of the database structured statements, combining multimodal data analysis and time series model, and dynamically adjusting the threshold, the problem of inaccurate early warning in database performance monitoring is solved, and a more accurate and reliable early warning system is achieved.
Patent Information
- Application Number
- CN202411430615.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-14
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-10-14
AI Technical Summary
Existing database performance monitoring methods lack effective analysis of the relationship between execution time and resource consumption, making it difficult to achieve dynamic threshold adjustment, resulting in inaccurate early warning under complex workloads.
By obtaining the execution time of the structured statements of the preset and production database, using multimodal data analysis to optimize the weights, and dynamically adjusting the warning threshold based on the time series model, combining the execution time and resource consumption trends, accurate warning of the database is achieved.
It improves the accuracy and reliability of the early warning system, reduces false alarms and missed reports, and enhances the adaptability and responsiveness of database performance monitoring.
Smart Images

Figure CN118939520B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of automated operation systems, and in particular to a database early warning method and system for automated operation systems. Background Art
[0002] With the rapid development of information technology, the level of enterprise informatization is constantly improving. As an important part of modern enterprise information management system, the automated operation system plays a vital role in improving work efficiency and ensuring data security. Most traditional database performance monitoring methods rely on fixed thresholds to judge the health status of the database. Although this method is simple and easy to use, it often seems inadequate when faced with complex and changing workloads.
[0003] In recent years, with the advancement of big data and artificial intelligence technologies, multimodal data analysis methods have begun to be applied to the field of database performance monitoring. By comprehensively analyzing various types of data (such as execution time, resource consumption, etc.), the operating status of the database can be evaluated more accurately. Despite this, most solutions on the market still have some limitations, such as the lack of effective analysis of the relationship between execution time and resource consumption, making it difficult to achieve truly dynamic threshold adjustment. In addition, these methods often require a large amount of historical data support, and may not be able to make accurate warnings in a timely manner for newly deployed systems or scenarios where workloads change frequently. Summary of the invention
[0004] In view of the above existing problems, the present invention is proposed.
[0005] Therefore, the present invention provides a database early warning method and system for an automated operation system to solve the problem of inaccurate early warning caused by fluctuations in resource consumption of the database in the automated operation system.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0007] In a first aspect, an embodiment of the present invention provides a database early warning method for an automated operation system, which comprises:
[0008] Obtaining a preset structured statement executed by a preset database, and determining a first weight according to an execution time of the preset structured statement;
[0009] Obtaining a production structured statement executed by the automated operation database, and determining a second weight according to the execution time of the production structured statement;
[0010] Using multimodal data analysis, further optimizing the first weight and the second weight;
[0011] Dynamically adjust the preset thresholds of the early warning system by analyzing execution time and resource consumption trends;
[0012] When the difference between the first weight and the second weight exceeds a preset threshold, an early warning is issued to the production database;
[0013] Regularly evaluate the early warning system and adjust the warning thresholds based on the evaluation results.
[0014] As a preferred solution of the database early warning method of the automated operation system of the present invention, wherein: the production structured statement executed by the automated operation database is obtained, and the second weight is determined according to the execution time of the production structured statement. The specific steps are as follows:
[0015] Write preset structured SQL statements according to business needs and store the written SQL statements in the preset database;
[0016] Use the built-in EXPLAIN ANALYZE tool in PostgreSQL to test and record the actual execution time of each SQL statement. Define the first weight as the inverse expression of the execution time of the preset structured statement as follows:
[0017] ;
[0018] in, is the first weight of the SQL statement, The execution time of the preset structured statement.
[0019] As a preferred solution of the database early warning method of the automated operation system of the present invention, wherein: the production structured statement executed by the automated operation database is obtained, and the second weight is determined according to the execution time of the production structured statement. The specific steps are as follows:
[0020] Deploy database monitoring to continuously detect all activities of the automated operation system's database and record all production structured SQL statements;
[0021] Use the built-in EXPLAIN ANALYZE tool in PostgreSQL to collect the execution time of each SQL statement in the database of the automated job system during off-peak hours;
[0022] Calculate the average execution time of the collected SQL statements during off-peak hours, and define the second weight as the inverse expression of the production structured statement execution time as follows:
[0023] ;
[0024] in, is the second weight, The execution time of the production structured statement.
[0025] As a preferred solution of the database early warning method of the automated operation system of the present invention, wherein: the multimodal data analysis is used to further optimize the first weight and the second weight, and the specific steps are as follows:
[0026] The built-in EXPLAIN ANALYZE tool in PostgreSQL is used to collect additional indicators during SQL execution, including CPU usage, memory usage, and I / O operation times. I / O operations refer to disk read and write operations. Multimodal data analysis methods are used to comprehensively consider SQL execution time, CPU usage, memory usage, and I / O operation times, and the first and second weights are optimized. The expressions are as follows:
[0027] ;
[0028] in, is the optimization weight of the SQL statement. For the preset structured statement, , for the production structured statement , SQL statement execution time. For preset structured statements, , for the production structured statement , The CPU usage during SQL execution. , They are the highest and lowest CPU usage during QL execution, The memory usage during SQL execution. , They are the highest and lowest memory usage during SQL execution, The number of I / O operations during SQL execution. , The maximum and minimum number of I / O operations during SQL execution.
[0029] As a preferred solution of the database early warning method of the automated operation system of the present invention, wherein: the preset threshold of the early warning system is dynamically adjusted by analyzing the execution time and resource consumption trend, and the specific steps are as follows:
[0030] Establish a time series-based prediction model that comprehensively considers SQL statement execution time, CPU usage, memory usage, and I / O operation times, and predicts future execution time and resource consumption based on historical execution time and resource consumption trends;
[0031] Define a function that describes the trend of execution time and resource consumption , whose expression is:
[0032] ;
[0033] in, For at time point The execution time and resource consumption trends of For at time point SQL statement execution time, For at time point CPU usage, For at time point Memory usage, For at time point The number of I / O operations, , are the mean and standard deviation of CPU usage, , are the mean and standard deviation of memory usage, , are the mean and standard deviation of the number of I / O operations, respectively;
[0034] use Calculate future time points Resource usage forecast , and further calculate the warning threshold adjustment amount and new warning thresholds , the expression is as follows:
[0035] ;
[0036] ;
[0037] ;
[0038] in, is the coefficient used to smooth the trend of resource usage, is the time span of historical data, is the coefficient used to calculate the threshold adjustment amount, For at time point The resource usage forecast value, For at time point The warning threshold is the time interval, Represents the integral variable small changes in .
[0039] As a preferred solution of the database early warning method of the automated operation system of the present invention, when the difference between the first weight and the second weight exceeds a preset threshold, an early warning is issued to the production database. The specific steps are as follows:
[0040] The first weight calculated based on multimodal data analysis and the second weight , calculate the difference between the two , the dynamically adjusted warning threshold As a benchmark;
[0041] when When a warning message is received, it is considered that there are potential risks and abnormal behaviors, and the warning mechanism will be triggered, including sending a warning notification to the administrator, recording the warning in the abnormality log, starting the automatic backup process, and adjusting resource allocation to reduce the load;
[0042] When an alert is triggered, measures are taken to increase monitoring frequency, check hardware status, optimize database configuration parameters, review recent change logs, quickly locate the root cause, and make necessary repairs;
[0043] Record the triggering time of the warning event, abnormal details, measures taken and their effects, and feed them back to the operation and maintenance for further analysis;
[0044] when When the price is adjusted, it is considered that there is no potential risk or abnormal behavior and no adjustment is made.
[0045] As a preferred solution of the database early warning method of the automated operation system of the present invention, the early warning system is regularly evaluated, and the early warning threshold is adjusted according to the evaluation results. The specific steps are as follows:
[0046] One week is planned as one evaluation cycle. On the first day of the next cycle, all warning records in the previous cycle are collected, the number of false alarms and missed alarms is counted, and the warning accuracy of the warning system is calculated;
[0047] When the accuracy rate is lower than 80%, it means that the warning threshold is too high, and there are many missed alarms, so the warning threshold needs to be lowered. When the accuracy rate is higher than 95%, it means that the warning value is too low, and there are many false alarms, so the warning threshold needs to be increased.
[0048] Apply the adjusted warning threshold in the next cycle.
[0049] In a second aspect, the present invention provides a database early warning system for an automated operation system, comprising a preset database query module, a production database monitoring module, a multimodal data analysis module, a dynamic threshold adjustment module, an early warning trigger module and a system evaluation and optimization module;
[0050] The preset database query module is used to obtain a preset structured statement executed by the preset database, and determine a first weight according to the execution time of the preset structured statement;
[0051] The production database monitoring module is used to obtain the production structured statements executed by the automated operation database, and determine the second weight according to the execution time of the production structured statements;
[0052] The multimodal data analysis module is used to further optimize the first weight and the second weight by using multimodal data analysis;
[0053] The dynamic threshold adjustment module is used to dynamically adjust the preset threshold of the early warning system by analyzing the execution time and resource consumption trend;
[0054] The warning trigger module is used to issue a warning to the production database when the difference between the first weight and the second weight exceeds a preset threshold;
[0055] The system evaluation and optimization module is used to regularly evaluate the early warning system and adjust the early warning threshold according to the evaluation results.
[0056] In a third aspect, an embodiment of the present invention provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program is executed by the processor, any step of the database warning method of the automated operation system as described in the first aspect of the present invention is implemented.
[0057] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program is executed by a processor, any step of the database early warning method of the automated operation system as described in the first aspect of the present invention is implemented.
[0058] The beneficial effects of the present invention are as follows: by writing structured statements for a predefined task instruction set in a preset database and recording the execution time, the performance of the preset structured statements can be accurately measured, which helps to quickly identify inefficient query operations; by continuously monitoring the execution time of SQL statements in a production environment, the performance of SQL statements in the production environment can be monitored, potential problems can be discovered and responded to in a timely manner; by combining the execution time with the CPU usage, memory usage and the number of I / O operations, false alarms and missed alarms can be reduced, and the overall reliability of the early warning system can be improved; by utilizing a prediction model based on a time series, the adaptability and accuracy of the early warning system can be improved, and the false alarms or missed alarms caused by fixed thresholds can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0060] Figure 1 This is a flow chart of the database early warning method of the automated operation system in Example 1.
[0061] Figure 2 This is a module diagram of the database early warning system of the automated operation system in Example 1. DETAILED DESCRIPTION
[0062] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.
[0063] Example 1, reference Figure 1 and Figure 2 , which is the first embodiment of the present invention, and provides a database early warning method for an automated operation system, comprising the following steps:
[0064] S1. Obtain a preset structured statement executed by a preset database, and determine a first weight according to the execution time of the preset structured statement.
[0065] Furthermore, according to business needs, for a preset database, including a database storing a predefined task instruction set, query and update operations for each data;
[0066] Writing corresponding preset structured statements, including that the preset structured statements refer to predefined SQL statements for querying a preset database, and storing the written SQL statements in the preset database;
[0067] Preferably, the built-in EXPLAIN ANALYZE tool of PostgreSQL is used to test and record the actual execution time of each SQL statement. The EXPLAIN ANALYZE tool not only displays the execution plan, but also provides detailed running time statistics, including the time consumption of each operation. It collects data while actually executing the SQL statement, can provide data closest to the actual situation, supports multiple output formats, and can select JSON and text formats to output the results as needed to facilitate subsequent processing. The first weight is defined as the inverse expression of the execution time of the preset structured statement as follows:
[0068] ;
[0069] in, is the first weight of the SQL statement, The execution time of the preset structured statement.
[0070] S2. Obtain a production structured statement executed by the automated operation database, and determine a second weight according to the execution time of the production structured statement.
[0071] Going a step further, deploy database monitoring to continuously detect all activities in the database of the automated operation system and record all production structured statements, including SQL statements executed in the production environment;
[0072] To reduce the impact on the production environment, the built-in EXPLAIN ANALYZE tool in PostgreSQL is used to collect the execution time of each SQL statement in the database of the automated job system during off-peak hours.
[0073] Calculate the average execution time of the collected SQL statements during off-peak hours, and define the second weight as the inverse of the production structured statement execution time. The expression is as follows:
[0074] ;
[0075] in, is the second weight, The execution time of the production structured statement.
[0076] S3. Utilize multimodal data analysis to further optimize the first weight and the second weight.
[0077] Furthermore, the built-in EXPLAIN ANALYZE tool in PostgreSQL is used to collect additional metrics during SQL execution, including CPU usage, memory usage, number of I / O operations, and I / O operations, including disk read and write operations;
[0078] Preferably, a multimodal data analysis method is used, including multimodal data analysis refers to the process of collecting data from multiple different types of sensors or data sources and performing comprehensive analysis on the data, to comprehensively consider SQL execution time, CPU usage, memory usage, and number of I / O operations, and to more accurately calculate the first weight and the second weight, the expression is as follows:
[0079] ;
[0080] in, The optimization weight of the SQL statement. The optimization weight of the preset structured statement is , the optimization weight for production structured statements is , is the SQL statement execution time. For the preset structured statement, the execution time is , the execution time for the production structured statement is ;
[0081] The CPU usage during SQL execution. , They are the highest and lowest CPU usage during QL execution, The memory usage during SQL execution. , They are the highest and lowest memory usage during SQL execution, The number of I / O operations during SQL execution. , The maximum and minimum number of I / O operations during SQL execution;
[0082] Optimize weights The closer the value is to 0, the faster the SQL statement is executed and the less resource consumption is. The larger the value, the slower the SQL statement execution and the greater the resource consumption.
[0083] It should be noted that by considering not only the execution time of the SQL statement but also the CPU usage, memory usage and the number of I / O operations, a more comprehensive and accurate first weight and second weight are obtained, which can better evaluate the impact of the SQL statement on the performance of the automated operation system and provide a basis for subsequent optimization.
[0084] S4. Dynamically adjust the preset thresholds of the early warning system by analyzing the execution time and resource consumption trends.
[0085] Furthermore, a time series-based prediction model is established to comprehensively consider SQL statement execution time, CPU usage, memory usage, and I / O operation times, and to predict future execution time and resource consumption based on historical execution time and resource consumption trends;
[0086] Define a function that describes the trend of execution time and resource consumption , the expression is:
[0087] ;
[0088] in, For in time The execution time and resource consumption trends of For in time SQL statement execution time, For in time CPU usage, For in time Memory usage, For in time The number of I / O operations;
[0089] , are the mean and standard deviation of CPU usage, , are the mean and standard deviation of memory usage, , are the mean and standard deviation of the number of I / O operations, respectively;
[0090] use Calculate future time points Resource usage forecast , and further calculate the warning threshold adjustment amount and new warning thresholds , the expression is as follows:
[0091] ;
[0092] ;
[0093] ;
[0094] in, is the coefficient used to smooth the trend of resource usage, is the time span of historical data, is the coefficient used to calculate the threshold adjustment amount, For at time point Resource usage forecasts based on the current moment Resource usage and the past period of time The forecast value is calculated based on the resource usage trend within the time period. This forecast value is used to predict future time points. The resource usage of For at time point The warning threshold.
[0095] like ,So relatively Increase, indicating that the warning threshold needs to be increased to cope with higher resource consumption or longer execution time. ,So relatively Reduce, which means that the warning threshold can be lowered to reduce false alarms;
[0096] It should be noted that the threshold of the early warning system is dynamically adjusted based on the resource usage trend, so as to more effectively monitor and manage the performance of the automated operation system. The prediction model uses specific historical statistics and current resource usage, so it is more practical.
[0097] S5. When the difference between the first weight and the second weight exceeds a preset threshold, an early warning is issued to the production database.
[0098] Furthermore, the first weight calculated based on multimodal data analysis is and the second weight , calculate the difference between the two , the dynamically adjusted warning threshold As a benchmark;
[0099] when When a warning message is received, it is considered that there are potential risks and abnormal behaviors, and the warning mechanism will be triggered, including sending a warning notification to the administrator, recording the warning in the abnormality log, starting the automatic backup process, and adjusting resource allocation to reduce the load;
[0100] When an alert is triggered, measures are taken to increase monitoring frequency, check hardware status, optimize database configuration parameters, review recent change logs, quickly locate the root cause, and make necessary repairs;
[0101] Record the triggering time of the warning event, abnormal details, measures taken and their effects, and feed them back to the operation and maintenance for further analysis;
[0102] when When the price is adjusted, it is considered that there is no potential risk or abnormal behavior and no adjustment is made.
[0103] Through the above steps, an automated and efficient early warning system is implemented, which can detect and handle potential problems in a timely manner when the difference between the first weight and the second weight exceeds the preset threshold, thereby ensuring the stability and reliability of the database system.
[0104] S6. Regularly evaluate the early warning system and adjust the warning thresholds based on the evaluation results.
[0105] Furthermore, a week is proposed as an evaluation cycle. On the first day of the next cycle, all warning records in the previous cycle are collected, the number of false positives and missed negatives is counted, and the warning accuracy of the warning system is calculated. The expression is as follows:
[0106] ;
[0107] When the accuracy rate is lower than 80%, it means that the warning threshold is too high, and there are many missed alarms, so the warning threshold needs to be lowered. When the accuracy rate is higher than 95%, it means that the warning value is too low, and there are many false alarms, so the warning threshold needs to be increased.
[0108] Apply the adjusted warning threshold in the next cycle.
[0109] It should be noted that this process ensures that the threshold of the early warning system can be dynamically adjusted according to actual conditions, thereby improving the accuracy and efficiency of the early warning system. Through improvements, the early warning system can more effectively respond to various abnormal situations that occur in the database and ensure the stable operation of the database.
[0110] The present embodiment also provides a database early warning system for an automated operation system, comprising a preset database query module, a production database monitoring module, a multimodal data analysis module, a dynamic threshold adjustment module, an early warning trigger module and a system evaluation and optimization module; the preset database query module is used to obtain a preset structured statement executed by a preset database, and determine a first weight according to the execution time of the preset structured statement; the production database monitoring module is used to obtain a production structured statement executed by an automated operation database, and determine a second weight according to the execution time of the production structured statement; the multimodal data analysis module is used to further optimize the first weight and the second weight by using multimodal data analysis; the dynamic threshold adjustment module is used to dynamically adjust the preset threshold of the early warning system by analyzing the execution time and resource consumption trend; the early warning trigger module is used to issue an early warning to the production database when the difference between the first weight and the second weight exceeds the preset threshold; the system evaluation and optimization module is used to regularly evaluate the early warning system and adjust the early warning threshold according to the evaluation result.
[0111] This embodiment also provides a computer device, which is suitable for the database early warning method of the automated operation system, including: a memory and a processor; the memory is used to store computer executable instructions, and the processor is used to execute computer executable instructions to implement the database early warning method of the automated operation system proposed in the above embodiment.
[0112] The computer device may be a terminal, and the computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covered on the display screen, or a key, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.
[0113] The present embodiment also provides a storage medium on which a computer program is stored. When the program is executed by a processor, the method for realizing a database early warning of an automated operation system as proposed in the above embodiment is implemented. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic storage device, a flash memory, a magnetic disk or an optical disk.
[0114] In summary, the present invention accurately measures the performance of preset structured statements by writing structured statements for predefined task instruction sets in a preset database and recording the execution time, which helps to quickly identify inefficient query operations. By continuously monitoring the execution time of SQL statements in the production environment, the performance of SQL statements in the production environment is monitored, potential problems are discovered and responded to in a timely manner, and by combining the execution time with the CPU utilization rate, memory usage and the number of I / O operations, the false alarms and missed alarms are reduced, and the overall reliability of the early warning system is improved. By utilizing a prediction model based on a time series, the adaptability and accuracy of the early warning system are improved, and the false alarms or missed alarms caused by fixed thresholds are reduced.
[0115] Example 2, referring to Table 1, is the second example of the present invention. To further verify the technical solution of the present invention, experimental simulation data of a database early warning method for an automated operation system is provided.
[0116] A server equipped with an Intel Xeon E5-2680 v4 CPU and 64GB RAM was used, and the PostgreSQL 14.2 database system was installed. A preset database containing a large number of preset task instruction sets and a production database simulating a real business environment were built.
[0117] We selected a database with predefined task instruction sets, wrote preset structured statements for these instruction sets, and used the EXPLAIN ANALYZE tool to test the execution time of each SQL statement. Based on the execution time, we calculated the first weight of each SQL statement. .
[0118] Deployed database monitoring tools to continuously monitor database activities in the production environment and record the execution of all production structured statements. Used EXPLAIN ANALYZE tools to collect the execution time of SQL statements during off-peak hours and calculate the second weight. .
[0119] We collected additional metrics during SQL execution, including CPU usage, memory usage, and I / O operation times, and used multimodal data analysis methods to optimize and .
[0120] A time series-based prediction model was built to predict future execution time and resource consumption, and the warning thresholds were adjusted based on historical data.
[0121] When the difference between the first weight and the second weight exceeds the preset threshold, the system triggers an early warning and records the triggering time of the early warning event, abnormal details, measures taken and their effects.
[0122] The details are shown in the following table:
[0123] Table 1 Performance data of database early warning method for automated operation system
[0124] SQL Statements Execution time (seconds) CPU usage (%) Memory usage (MB) Number of I / O operations First / Second Weight A 5 50 100 20 0.28 B 10 60 200 30 0.12 C 3 45 90 15 0.35 D 8 55 180 25 0.15
[0125] It can be seen from the above table that the execution time of preset structured statements A and C are shorter than those of production structured statements B and D, respectively, while the CPU usage, memory usage and number of I / O operations are relatively low. Therefore, the calculated first weight is significantly higher than the second weight, which shows that the method of the present invention can effectively identify the advantages of preset structured statements over production structured statements.
[0126] The execution time of A is only 5 seconds, while the execution time of production structured statement B is 10 seconds. Although the CPU usage of the preset structured statement A is higher, the overall resource consumption is smaller, so the first weight Much larger than the second weight , which shows that preset structured statements have obvious advantages in execution efficiency.
[0127] Compared with the production structured statement D, although the execution time is similar, the preset structured statement C has lower CPU usage, memory usage, and I / O operation times, so the first weight is It is also significantly higher than the second weight ,This shows that the preset structured statements perform better in terms of ,resource consumption.
[0128] The database early warning method of the automated operation system of the present invention can effectively optimize the first weight and the second weight through multimodal data analysis, and timely discover potential risks and abnormal behaviors by dynamically adjusting the early warning threshold, thereby improving the accuracy and reliability of the early warning system.
[0129] It should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A database early warning method for an automated operation system, characterized in that: include, Obtaining a preset structured statement executed by a preset database, and determining a first weight according to an execution time of the preset structured statement; Obtaining a production structured statement executed by the automated operation database, and determining a second weight according to the execution time of the production structured statement; Using multimodal data analysis, further optimizing the first weight and the second weight; Dynamically adjust the preset thresholds of the early warning system by analyzing execution time and resource consumption trends; When the difference between the first weight and the second weight exceeds a preset threshold, an early warning is issued to the production database; Regularly evaluate the early warning system and adjust the warning thresholds based on the evaluation results; The step of obtaining a preset structured statement executed by a preset database and determining a first weight according to the execution time of the preset structured statement is as follows: Write preset structured SQL statements according to business needs and store the written SQL statements in the preset database; Use the built-in EXPLAIN ANALYZE tool in PostgreSQL to test and record the actual execution time of each SQL statement. Define the first weight as the inverse expression of the execution time of the preset structured statement as follows: Wherein, W1 is the first weight of the SQL statement, and T1 is the execution time of the preset structured statement; The step of obtaining the production structured statements executed by the automated operation database and determining the second weight according to the execution time of the production structured statements is as follows: Deploy database monitoring to continuously detect all activities of the automated operation system's database and record all production structured SQL statements; Use the built-in EXPLAIN ANALYZE tool in PostgreSQL to collect the execution time of each SQL statement in the database of the automated job system during off-peak hours; Calculate the average execution time of the collected SQL statements during off-peak hours, and define the second weight as the inverse of the production structured statement execution time. The expression is as follows: Wherein, W2 is the second weight, T2 is the execution time of the production structured statement; By analyzing the execution time and resource consumption trends, the preset threshold of the early warning system is dynamically adjusted. The specific steps are as follows: Establish a time series-based prediction model that comprehensively considers SQL statement execution time, CPU usage, memory usage, and I / O operation times, and predicts future execution time and resource consumption based on historical execution time and resource consumption trends; Define a function F that describes the trend of execution time and resource consumption, whose expression is: Among them, F(t) is the trend of execution time and resource consumption at time point t, T(t) is the SQL statement execution time at time point t, C(t) is the CPU usage at time point t, M(t) is the memory usage at time point t, I(t) is the number of I / O operations at time point t, μ C , σ C are the mean and standard deviation of CPU usage, μ M , σ M are the mean and standard deviation of memory usage, μ I , σ I are the mean and standard deviation of the number of I / O operations, respectively; Use F(t) to calculate the resource usage forecast value P(t+Δt) at the future time point t+Δt, and further calculate the warning threshold adjustment ΔV and the new warning threshold V new (t+Δt), the expression is as follows: ΔV = θ × (P (t + Δt) - P (t)); V new (t+Δt)=V(t)+ΔV; Among them, λ is the coefficient used to smooth the trend change of resource usage, H is the time span of historical data, θ is the coefficient used to calculate the threshold adjustment amount, P(t) is the predicted value of resource usage at time point t, V(t) is the warning threshold at time point t, Δt is the time interval, and dt represents the small change of the integral variable t.
2. The database early warning method of the automated operation system according to claim 1, characterized in that: The method of using multimodal data analysis to further optimize the first weight and the second weight is as follows: The built-in EXPLAIN ANALYZE tool in PostgreSQL is used to collect additional indicators during SQL execution, including CPU usage, memory usage, and I / O operation times. I / O operations refer to disk read and write operations. Multimodal data analysis methods are used to comprehensively consider SQL execution time, CPU usage, memory usage, and I / O operation times, and the first and second weights are optimized. The expressions are as follows: Where W is the optimization weight of the SQL statement, which is W1 for the preset structured statement and W2 for the production structured statement. T is the SQL statement execution time, C is the CPU usage during SQL execution, and C max , C min are the highest and lowest CPU usage during SQL execution, M is the memory usage during SQL execution, and M max 、M min are the highest and lowest memory usage during SQL execution, I is the number of I / O operations during SQL execution, and I max ,I min The maximum and minimum number of I / O operations during SQL execution.
3. The database early warning method of the automated operation system according to claim 2, characterized in that: When the difference between the first weight and the second weight exceeds a preset threshold, an early warning is issued to the production database. The specific steps are as follows: Based on the first weight W1 and the second weight W2 calculated after multimodal data analysis, the difference between the two |ΔW| is calculated, and the dynamically adjusted warning threshold V new (t+Δt) is taken as the benchmark; When |ΔW|≤V new When (t+Δt), it is considered that there are potential risks and abnormal behaviors, and the early warning mechanism will be triggered, including sending an early warning notification to the administrator, recording the early warning in the abnormal log, starting the automatic backup process, and adjusting resource allocation to reduce the load; When an alert is triggered, measures are taken to increase monitoring frequency, check hardware status, optimize database configuration parameters, review recent change logs, quickly locate the root cause, and make necessary repairs; Record the triggering time of the warning event, abnormal details, measures taken and their effects, and feed them back to the operation and maintenance for further analysis; When |ΔW|>V new When (t+Δt), it is considered that there is no potential risk and abnormal behavior, and no adjustment is made.
4. The database early warning method of the automated operation system according to claim 3, characterized in that: The said early warning system is regularly evaluated and the early warning threshold is adjusted according to the evaluation results. The specific steps are as follows: One week is planned as one evaluation cycle. On the first day of the next cycle, all warning records in the previous cycle are collected, the number of false alarms and missed alarms is counted, and the warning accuracy of the warning system is calculated; When the accuracy rate is lower than 80%, it means that the warning threshold is too high, and there are many missed alarms, so the warning threshold needs to be lowered. When the accuracy rate is higher than 95%, it means that the warning value is too low, and there are many false alarms, so the warning threshold needs to be increased. Apply the adjusted warning threshold in the next cycle.
5. A database early warning system for an automated operation system, based on the database early warning method for an automated operation system according to any one of claims 1 to 4, characterized in that: Including, preset database query module, production database monitoring module, multimodal data analysis module, dynamic threshold adjustment module, early warning trigger module and system evaluation and optimization module; The preset database query module is used to obtain a preset structured statement executed by the preset database, and determine a first weight according to the execution time of the preset structured statement; The production database monitoring module is used to obtain the production structured statements executed by the automated operation database, and determine the second weight according to the execution time of the production structured statements; The multimodal data analysis module is used to further optimize the first weight and the second weight by using multimodal data analysis; The dynamic threshold adjustment module is used to dynamically adjust the preset threshold of the early warning system by analyzing the execution time and resource consumption trend; The warning trigger module is used to issue a warning to the production database when the difference between the first weight and the second weight exceeds a preset threshold; The system evaluation and optimization module is used to regularly evaluate the early warning system and adjust the early warning threshold according to the evaluation results.
6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the database early warning method of the automated operation system according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the database early warning method of the automated operation system according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Structured query language statement distribution method, distributed database and storage medium
CN116226175A
Database performance monitoring method and related system
WO2024055663A1