Database log cleaning method and device

By checking log cleaning indicators and quantity thresholds in a large-scale distributed database environment and automatically triggering log cleaning, the impact of traditional methods on database performance and disk capacity is resolved, achieving safe and stable log cleaning and business continuity.

CN114691655BActive Publication Date: 2025-10-03NETSUNION CLEARING CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011581308.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-28
Publication Date
2025-10-03
Estimated Expiration
2040-12-28

AI Technical Summary

Technical Problem

In a large-scale distributed database environment, traditional log cleaning methods may affect the database's read and write performance and business continuity, resulting in a waste of disk capacity.

Method used

By checking before log cleaning, ensuring that the log cleaning indicators meet the online cleaning conditions before triggering cleaning, and cleaning when the number of logs exceeds the threshold, automated detection and cleaning strategies are adopted to avoid affecting database performance and wasting disk capacity.

Benefits of technology

It achieves safe and stable log cleaning, avoids the impact on database online performance and waste of disk capacity, and ensures business continuity and refined management of cleaning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691655B_ABST
    Figure CN114691655B_ABST
Patent Text Reader

Abstract

This application discloses a database log cleaning method and apparatus. The method comprises: determining a database log cleaning indicator; detecting the number of logs in the database when the log cleaning indicator meets the database's online cleaning conditions; and cleaning the logs in the database when the log number exceeds a log number threshold. The technical solution of this application ensures secure and stable log cleaning, avoiding impacts on the database's online performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a method and device for cleaning database logs. Background Art

[0002] In a large-scale distributed database environment, as business volume grows rapidly, a large number of database logs are generated every day. If a large number of expired logs are eliminated at a fixed time according to the traditional method, it may affect the database's read and write performance, and ultimately affect business continuity. Summary of the Invention

[0003] The embodiments of the present application provide a method and device for cleaning logs of a database to ensure safe and stable log cleaning without affecting the online operation of the database and ensuring business continuity.

[0004] The embodiments of this application adopt the following technical solutions:

[0005] In a first aspect, an embodiment of the present application provides a method for cleaning logs of a database, which is applied to a log management device, comprising:

[0006] Determine a log cleaning index of a database; when the log cleaning index meets an online cleaning condition of the database, detect the number of logs in the database; when the number of logs exceeds a log number threshold, clean the logs in the database.

[0007] In a second aspect, an embodiment of the present application further provides a database log cleaning device, which is applied to a log management device and includes:

[0008] An indicator determination unit is used to determine the log cleaning indicator of the database; a judgment detection unit is used to detect the number of logs in the database when the log cleaning indicator meets the online cleaning condition of the database; and a log cleaning unit is used to clean the logs in the database when the number of logs exceeds a log number threshold.

[0009] In a third aspect, an embodiment of the present application further provides a log management device, comprising: a processor; and a memory arranged to store computer-executable instructions, wherein when the executable instructions are executed, the processor executes a database log cleaning method.

[0010] In a fourth aspect, an embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs. When the one or more programs are executed by a log management device including multiple applications, the log management device executes a log cleaning method for a database.

[0011] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:

[0012] On the one hand, the embodiment of the present application performs a check before log cleaning, and log cleaning is triggered only when the log cleaning index of the database meets the online cleaning conditions, ensuring the safety and stability of log cleaning and avoiding affecting the online performance of the database;

[0013] On the other hand, when triggering log cleaning, the embodiment of the present application will further detect the number of logs in the database. Only when the number of logs exceeds the threshold will the log cleaning operation be started and the logs will be cleared to minimize the granularity of log cleaning. This not only avoids cleaning too many logs at a time, causing fluctuations in database IO, but also avoids wasting disk capacity. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0015] Figure 1 This is a flowchart of a database cleaning method in an embodiment of the present application;

[0016] Figure 2 This is a log cleaning flow chart in an embodiment of the present application;

[0017] Figure 3 This is a structural block diagram of a database log cleaning device in an embodiment of the present application;

[0018] Figure 4 This is a structural diagram of a log management device in an embodiment of the present application. DETAILED DESCRIPTION

[0019] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0020] Existing technology controls log cleanup through database parameters, with the minimum granularity for some database cleanup being daily. Specifically, the database system automatically cleans up database logs older than a configured number of days based on database parameters specifically for log cleanup, such as the Expire_log_days parameter. If the configured number of days is one, and a large number of logs are generated within that day, an automatic cleanup can cause fluctuations in database I / O, impacting online services, affecting business continuity, and wasting disk capacity.

[0021] The following describes in detail the technical solutions provided by various embodiments of the present application in conjunction with the accompanying drawings.

[0022] Figure 1 This is a flow chart of a database log cleaning method in an embodiment of the present application. Figure 1 The method in is applied to log management devices, such as Figure 1 As shown, the method of this embodiment includes the following steps:

[0023] S110: Determine a log cleaning index for the database.

[0024] In this embodiment, log cleanup metrics can be understood as metrics that impact database online performance on the user side; and as metrics that impact database availability on the service side. Therefore, in determining log cleanup metrics, database availability testing can be performed to determine the metrics. Log cleanup metrics include, but are not limited to, performance parameter metrics and database environment metrics.

[0025] S120 , when the log cleaning indicator meets the online cleaning condition of the database, detecting the number of logs in the database.

[0026] The log cleaning indicators here generally include multiple indicators, of course, including the case of a single indicator. The online cleaning condition mentioned in this step should be understood as: each log cleaning indicator meets its own cleaning condition. That is, when the log cleaning indicators include performance parameter indicators and database environment indicators, if each performance parameter indicator meets its corresponding parameter threshold, and each database environment indicator meets its corresponding environment indicator, it is determined that the database meets the online cleaning condition. In this case, log cleaning will not affect online performance.

[0027] In this step, when the log cleaning indicators meet the online cleaning conditions, the database log quantity detection is automatically triggered to perform log cleaning based on the detection results.

[0028] S130: When the number of logs exceeds a log number threshold, clear the logs in the database.

[0029] The log count threshold setting should be based on the disk capacity of the database storing logs. Larger disk capacity corresponds to a larger log count threshold, while smaller disk capacity corresponds to a smaller log count threshold. When the log count exceeds the threshold, expired logs exceeding the threshold should be cleaned up to avoid impacting the database's online performance. When the log count does not exceed the threshold, the database has sufficient resources to support online functionality, and log cleanup is not necessary.

[0030] Depend on Figure 1 As shown, on the one hand, this embodiment performs a check before log cleaning, and only triggers log cleaning when the log cleaning index of the database meets the online cleaning conditions, thereby ensuring the safety and stability of log cleaning and avoiding affecting the online performance of the database; on the other hand, when triggering log cleaning, this embodiment further detects the number of logs in the database, and only starts the log cleaning operation when the number of logs exceeds the threshold, clearing the logs to minimize the granularity of log cleaning, which not only avoids cleaning too many logs at one time, causing fluctuations in database IO, but also avoids wasting disk capacity.

[0031] In one embodiment, the above step S110 is to perform a database availability test on the database and determine the log cleaning index according to the test result.

[0032] For databases, database environment indicators can be a good measure of database availability. Therefore, when determining log cleaning indicators, you can perform database environment detection on the database to obtain multiple database environment indicators. Then, you can filter the multiple database environment indicators based on the degree of impact on database availability and determine the filtered database environment indicators as log cleaning indicators.

[0033] For example, a first type of availability impact table can be pre-set, and the first type of availability impact table lists the impact of all database environment indicators on database availability, wherein the impact on database availability can be quantified by an impact factor. For example, based on multiple experiments, the impact of each database environment indicator on database availability is statistically calculated, and then the impact factor is set. The larger the impact factor value, the greater the impact on the database availability, and conversely, the smaller the impact factor value, the smaller the impact on the database availability. In this way, after performing database availability detection, all detected database environment indicators can be screened according to the availability impact table. For example, database environment indicators with impact factor values ​​greater than a preset value (for example, greater than 0.4, of course, the preset value can be other values ​​and can be set according to application requirements) are screened out, and one or more screened database environment indicators are determined as log cleaning indicators, that is, the log cleaning indicators determined at this time are composed of database environment indicators.

[0034] The database environment indicators selected in this embodiment include, but are not limited to, login indicators and backup indicators. The login indicator indicates whether the database can provide normal external services, while the backup indicator indicates whether the data within the database can be backed up / archived. Generally speaking, login and backup indicators have the greatest impact on database availability, with the login indicator having a greater impact on database availability than the backup indicator.

[0035] Since the performance parameter indicators of the database will also have a significant impact on the database availability, in some embodiments, after obtaining multiple database environment indicators, the database can also be subjected to performance parameter detection to obtain multiple performance parameter indicators; the multiple performance parameter indicators are screened according to the degree of impact on the database availability, and the screened performance parameter indicators are determined as log cleaning indicators.

[0036] For example, a second type of availability impact table can be pre-set, which lists the impact of all performance parameter indicators on database availability. The impact on database availability can be quantified by an impact factor. For example, based on multiple experiments, the impact of each performance parameter indicator on database availability is statistically analyzed, and then the impact factor is set. Here, the larger the impact factor value, the greater the impact on database availability. Conversely, the smaller the impact factor value, the smaller the impact on database availability. In this way, after performing performance parameter detection, all detected performance parameter indicators can be screened according to the availability impact table. For example, performance parameter indicators with impact factor values ​​greater than a preset value (for example, greater than 0.5, of course, the preset value can be other values ​​and can be set according to application requirements) are screened out, and one or more screened performance parameter indicators are determined as log cleaning indicators. That is, the log cleaning indicators determined at this time are composed of database environment indicators and performance parameter indicators.

[0037] The performance parameters selected in this embodiment include, but are not limited to, database concurrency, number of connections, and latency. Concurrency refers to the amount of data stream writes processed simultaneously by the CPU, connections refers to the number of connections an application makes to the database, and latency refers to the delay between a backup database and the primary database. Generally speaking, performance parameters such as concurrency, connections, and latency are common and have a significant impact on database availability. Therefore, this embodiment exemplifies the performance parameters selected, including concurrency, connections, and latency.

[0038] The embodiment of the present application shows a specific implementation method of the aforementioned step S110. Of course, it should be understood that step S110 can also be implemented in other ways, and the embodiment of the present application does not limit this. And the determined log cleaning indicators are not limited to the above-mentioned database environment indicators and performance parameter indicators. Indicators such as disk IO, disk memory, and disk CPU can also be determined as log cleaning indicators. Here, disk IO refers to the amount of data read and written by the disk per second, disk memory refers to the proportion or occupancy of data in the memory, and disk CPU refers to the number of tasks processed by the CPU per second.

[0039] In one embodiment, a detection task can be configured through automation technology. The detection task specifies a detection period. For example, the detection period is less than 24 hours (1 day), preferably between 1 hour and 12 hours. In this way, the detection task is started on the log management device, and the detection task is used to perform database environment detection on the database according to the detection period (or perform database environment detection and performance parameter detection).

[0040] Specifically, a first detection task corresponding to the database environment is started and a second detection task corresponding to the performance parameter is started. The first detection task specifies a first detection period and the second detection task specifies a second detection period. The first detection task is used to perform a database environment detection on the database according to the first detection period, and the second detection task is used to perform a performance parameter detection on the database according to the second detection period. Since the impact of the database environment indicator on the database availability is greater than the impact of the performance parameter indicator on the database availability, the value of the first detection period can be set to be smaller than the value of the second detection period, for example, the first detection period is 1 hour and the second detection period is 2 hours. Of course, the data of the first detection period can also be equal to the value of the second detection period, and this embodiment does not make specific limitations on this.

[0041] In this embodiment, the log management device can manage one or more databases. By deploying the above-mentioned first detection task and second detection task on the log management device, the first detection task and the second detection task are used to detect the log cleaning indicators of all databases, and the changes in each log cleaning indicator are obtained. When each log cleaning indicator meets the online cleaning condition, that is, when each performance parameter indicator meets its corresponding parameter threshold, and each database environment indicator meets its corresponding environment indicator, it is determined that the database meets the online cleaning condition, and the logs in the database are cleaned.

[0042] In this way, by setting up a detection task to periodically detect log cleaning indicators to trigger database log cleaning, and by setting a detection cycle, the log cleaning granularity can be refined, and the original cleaning plan of cleaning logs by day can be adjusted to detecting the number of logs according to the detection cycle, so as to clean up based on the number of logs.

[0043] refer to Figure 2 , initiate a detection task on a remote log management device to avoid logging into all databases one by one and testing the online cleanup conditions of the databases. Exemplary log cleanup indicators include: login indicators, backup indicators, concurrency, number of connections, and latency. Accordingly, the following method can be used to determine whether each log cleanup indicator meets the online cleanup conditions of the database:

[0044] Whether the login indicator indicates that the database can provide external services, whether the backup indicator indicates that the data in the database can be backed up / archived, whether the concurrency is lower than the concurrency threshold, whether the number of connections is lower than the connection threshold, and whether the latency exceeds the latency indicator;

[0045] If the login indicator indicates that the database can provide external services, the backup indicator indicates that the data in the database can be backed up / archived, the concurrency is lower than the concurrency threshold, the number of connections is lower than the connection threshold, and the latency does not exceed the latency indicator, the online cleanup conditions are considered to be met. Otherwise, if any one or more of the indicators do not meet the above thresholds or indicators, the online cleanup conditions are considered to be not met. If the online cleanup conditions are not met, the log cleanup indicators that do not meet the above thresholds or indicators will be written to the database, and an error will be returned to the application layer.

[0046] The concurrency threshold, connection threshold, and latency index can be set based on the maximum concurrency, maximum connection, and maximum latency supported by the database standby database. For example, the concurrency threshold can be set to half of the maximum concurrency, the connection threshold to half of the maximum connection, and the latency index to half of the maximum latency.

[0047] When it is detected that the log cleaning index of the database meets the online cleaning condition, the number of logs in the database is detected. When the number of logs exceeds the log number threshold, the expired logs exceeding the log number threshold are cleaned according to the cleaning strategy. The cleaning of expired logs exceeding the log number threshold according to the cleaning strategy includes at least one of the following three items:

[0048] The first item is to clean up, according to the data modification type indicated by the cleaning policy, expired logs in the database having the data modification type exceeding a log quantity threshold;

[0049] The second item is to clean up the expired logs in the database having the log identifiers that exceed a log quantity threshold according to the log identifiers indicated by the cleaning policy;

[0050] The third item is to clean up the expired logs in the database that exceed a threshold number of logs in the time sequence indicated by the cleaning policy.

[0051] The data modification type includes writing, modifying and deleting data in the log; the log flag includes a clearable flag and an uncleanable flag; and the time sequence includes the order of log generation time from earliest to latest.

[0052] For example, when the cleanup strategy indicates the data modification type, log identifier, and time sequence, and the data modification type includes the writing of data in the log, the log identifier includes the cleanable identifier, and the time sequence includes the order of log generation time from earliest to latest. Then, when the number of logs exceeds the log number threshold, the logs in the database whose data modification type is the writing of data are filtered out to obtain the first screening result. From the first screening result, the logs with the cleanable identifier are filtered out to obtain the second screening result. The logs in the second screening result are sorted in the order of log generation time from earliest to latest, and the logs that exceed the log number threshold are deleted from the sorted second-category screening results. Assuming that the sorted second screening result is 1,000 logs, and the number of logs that exceed the log number threshold is 500, the first 500 logs with the earliest generation time will be deleted. If the number of logs that exceed the log number threshold is 1,500, a reminder should be returned to the application layer to remind the modification of the cleanup strategy. The current cleanup strategy cannot effectively clean up the logs in the database.

[0053] It should be noted that since most database logs are generated based on a database log template, i.e., the size and type of the database logs are the same, this embodiment does not illustrate an embodiment for performing log cleanup based on the size and type of the database logs during the cleanup process according to the cleanup policy. If database logs differ in size and type, the cleanup policy may also indicate the size and type of the database logs, and log cleanup may be performed based on the indicated size and type of the database logs.

[0054] After clearing the expired logs, the number of logs in the database is re-detected, and when the number of logs re-detected is less than a log number threshold, it is determined that the expired logs have been successfully cleared.

[0055] After the log cleaning is completed, a log cleaning report is generated for the cleaned logs. The log cleaning report includes but is not limited to whether the cleaning is successful, the number of cleaned logs, the cleaning time, the number of surviving logs, etc.

[0056] As described above, this embodiment provides an automated method for pre-cleanup inspection and post-cleanup statistics, adjusting the cleanup strategy from "days" to "numbers". When the database log quantity threshold is triggered, the database logs are automatically cleaned to avoid cleaning too many logs at one time.

[0057] This embodiment can automatically clean up logs of all online databases without manual intervention, reducing disk capacity; this embodiment can minimize the granularity of log cleaning, facilitating refined operations; this embodiment checks the database before log cleaning to ensure that the cleaning is safe and stable and does not affect online performance, and issues a log cleaning report after log cleaning to ensure that the cleaning is accurate and complete.

[0058] Figure 3 This is a structural block diagram of a database log cleaning device in an embodiment of the present application. The device of this embodiment is applied to a log management device, such as Figure 3 As shown, the log cleaning device 300 includes:

[0059] An indicator determination unit 310 is used to determine a log cleaning indicator of a database;

[0060] The judgment and detection unit 320 is used to detect the number of logs in the database when the log cleaning indicator meets the online cleaning condition of the database;

[0061] The log clearing unit 330 is configured to clear the logs in the database when the number of logs exceeds a log number threshold.

[0062] In one embodiment, the indicator determination unit 310 is further configured to perform a database availability test on the database and determine the log cleaning indicator based on the test results, including performing a database environment test on the database to obtain a plurality of database environment indicators; screening the plurality of database environment indicators based on the degree of impact on the database availability, and determining the screened database environment indicators as the log cleaning indicator; and after obtaining the plurality of database environment indicators, performing a performance parameter test on the database to obtain a plurality of performance parameter indicators; screening the plurality of performance parameter indicators based on the degree of impact on the database availability, and determining the screened performance parameter indicators as the log cleaning indicator.

[0063] In one embodiment, the indicator determination unit 310 is also used to start a first detection task corresponding to the database environment and a second detection task corresponding to the performance parameter, the first detection task specifies a first detection cycle, and the second detection task specifies a second detection cycle; the first detection task is used to perform database environment detection on the database according to the first detection cycle, and the second detection task is used to perform performance parameter detection on the database according to the second detection cycle.

[0064] In one embodiment, the judgment and detection unit 320 is further configured to determine that the database meets the online cleanup condition when each database environment indicator meets its corresponding environment indicator and each performance parameter indicator meets its corresponding parameter threshold.

[0065] In one embodiment, the log cleaning unit 330 is also used to clean up the expired logs that exceed the log number threshold according to the cleaning policy when the log number exceeds the log number threshold, including at least one of the following: cleaning up the expired logs in the database that exceed the log number threshold and have the data modification type according to the data modification type indicated by the cleaning policy; and / or cleaning up the expired logs in the database that exceed the log number threshold and have the log identifier according to the log identifier indicated by the cleaning policy; and / or cleaning up the expired logs in the database that exceed the log number threshold and conform to the time order indicated by the cleaning policy.

[0066] It can be understood that the above-mentioned log cleaning device can implement the various steps of the log cleaning method performed by the log management device provided in the above-mentioned embodiment. The relevant explanations about the log cleaning method are applicable to the log cleaning device and will not be repeated here.

[0067] Figure 4 This is a structural diagram of a log management device according to an embodiment of the present application. Figure 4 At the hardware level, the log management device includes a processor and, optionally, an internal bus, a network interface, and memory. The memory may include internal memory, such as high-speed random-access memory (RAM), or non-volatile memory, such as at least one disk drive. Of course, the log management device may also include other hardware required for the business.

[0068] The processor, network interface, and memory can be interconnected via an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or one type of bus.

[0069] The memory is used to store programs. Specifically, the program may include program code, which includes computer operating instructions. The memory may include internal memory and non-volatile memory, and provides instructions and data to the processor.

[0070] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a log cleaning device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:

[0071] Determine the log cleanup indicators for the database;

[0072] When the log cleaning indicator meets the online cleaning condition of the database, detecting the number of logs in the database;

[0073] When the number of logs exceeds a log number threshold, the logs of the data volume are cleared.

[0074] The above application Figure 1 The method performed by the database log cleaning device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits in the processor or software instructions. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The various methods, steps, and logic block diagrams disclosed in the embodiments of this application can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in conjunction with the embodiments of this application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps of the above method.

[0075] The log management device can also perform Figure 1 The method for executing the log cleaning device of the database in Figure 1 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.

[0076] The embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a plurality of application log management devices, enable the log management device to execute Figure 1 The method performed by the log cleaning device in the embodiment shown is specifically used to perform:

[0077] Determine the log cleanup indicators for the database;

[0078] When the log cleaning indicator meets the online cleaning condition of the database, detecting the number of logs in the database;

[0079] When the number of logs exceeds a log number threshold, the logs of the database are cleared.

[0080] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0081] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0082] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0083] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0084] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0085] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0086] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0087] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0088] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0089] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A method for cleaning database logs, wherein: The method is applied to a log management device and includes: Determine the log cleanup indicators for the database; When the log cleaning indicator meets the online cleaning condition of the database, detecting the number of logs in the database; When the number of logs exceeds a log number threshold, clearing the logs in the database; Determine the log cleaning indicators for the database, including: Performing a database availability test on the database, and determining the log cleaning indicator according to the test result; Wherein, the availability detection includes at least one of database environment detection and performance parameter detection; Performing a database availability test on the database and determining the log cleaning indicator based on the test result includes: Performing database environment detection on the database to obtain multiple database environment indicators; Screening a plurality of database environment indicators according to the degree of influence on the database availability, and determining the screened database environment indicators as the log cleaning indicators; After obtaining multiple database environment indicators, it also includes: Performing performance parameter detection on the database to obtain multiple performance parameter indicators; A plurality of performance parameter indicators are screened according to the degree of influence on the database availability, and the screened performance parameter indicators are determined as the log cleaning indicators.

2. The method according to claim 1, wherein: Performing a database availability test on the database includes: Starting a first detection task corresponding to the database environment and starting a second detection task corresponding to the performance parameter, wherein the first detection task specifies a first detection period, and the second detection task specifies a second detection period; The first detection task is used to perform a database environment detection on the database according to a first detection period, and the second detection task is used to perform a performance parameter detection on the database according to a second detection period.

3. The method according to claim 1, wherein: When the log cleaning indicator meets the online cleaning condition of the database, detecting the number of logs in the database includes: When each database environment indicator satisfies its corresponding environment indicator and each performance parameter indicator satisfies its corresponding parameter threshold, it is determined that the database meets the online cleanup condition.

4. The method according to claim 1, wherein: When the number of logs exceeds a log number threshold, the logs in the database are cleaned up, including: When the number of logs exceeds a log number threshold, expired logs exceeding the log number threshold are cleared according to a clearing strategy.

5. The method according to claim 4, wherein: Clearing out expired logs that exceed the log quantity threshold according to a clearing policy, including at least one of the following: Cleaning up, according to the data modification type indicated by the cleaning policy, expired logs in the database having the data modification type exceeding a log quantity threshold; Cleaning up the expired logs in the database that have the log identifiers and exceed a log quantity threshold according to the log identifiers indicated by the cleaning policy; According to the time sequence indicated by the cleaning policy, expired logs in the database that are in the time sequence and exceed a log quantity threshold are cleaned up.

6. A database log cleaning device, wherein: The device is applied to a log management device and includes: An indicator determination unit, used to determine a log cleaning indicator of a database; a judgment and detection unit, configured to detect the number of logs in the database when the log cleaning indicator meets the online cleaning condition of the database; a log cleaning unit, configured to clean up the logs in the database when the number of logs exceeds a log number threshold; The indicator determination unit is also used to: Performing a database availability test on the database, and determining the log cleaning indicator according to the test result; Wherein, the availability detection includes at least one of database environment detection and performance parameter detection; The indicator determination unit is also used to: Performing database environment detection on the database to obtain multiple database environment indicators; Screening a plurality of database environment indicators according to the degree of influence on the database availability, and determining the screened database environment indicators as the log cleaning indicators; After obtaining multiple database environment indicators, the indicator determination unit is further used to: Performing performance parameter detection on the database to obtain multiple performance parameter indicators; A plurality of performance parameter indicators are screened according to the degree of influence on the database availability, and the screened performance parameter indicators are determined as the log cleaning indicators.

7. A log management device, comprising: processor; as well as A memory arranged to store computer-executable instructions, which, when executed, cause the processor to perform the method of any one of claims 1 to 5.

Citation Information

Patent Citations

  • Database detection method and device, computer equipment and storage medium

    CN110874311A

  • Data cleaning method and device and electronic equipment

    CN111930735A