A log clearing time modification method, device and medium

By obtaining the log information storage space during the task execution cycle and adjusting the binlog clearing time, the adaptability of MySQL in complex customer scenarios was resolved, and the stable operation of the system was achieved.

CN114860666BActive Publication Date: 2026-01-30JINAN INSPUR DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210461369.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-28
Publication Date
2026-01-30
Estimated Expiration
2042-04-28

AI Technical Summary

Technical Problem

An improperly configured binlog clearing time in MySQL can lead to poor adaptability in complex customer scenarios, potentially causing abnormal service interruptions.

Method used

By obtaining the storage space occupied by the log information generated during the task execution cycle, and based on the positive correlation between storage space and clearing time, the binlog clearing time is dynamically adjusted.

Benefits of technology

It enables dynamic adjustment of log information clearing time in complex customer scenarios, improves the system's scenario adaptability, and avoids system operation problems caused by unreasonable clearing time configuration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114860666B_ABST
    Figure CN114860666B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, and medium for modifying log clearing time, relating to the field of software development. It involves obtaining the tasks to be executed within an execution cycle; obtaining the log information generated during task execution within the execution cycle and determining the storage space occupied by the log information; and obtaining the log clearing time based on the storage space. The storage space and clearing time are positively correlated. Therefore, this solution, by obtaining different tasks under different customer environments and considering the storage status of the log information generated during task execution, generates corresponding clearing times, with a positive correlation between storage space and clearing time. This enables modification of log clearing time in complex customer scenarios, avoiding system operation problems caused by unreasonable log clearing time configuration, and exhibiting stronger scenario adaptability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of software development, and in particular to a method, apparatus and medium for modifying log clearing time. Background Technology

[0002] MySQL, as a commonly used relational database, boasts advantages such as low cost, an active open-source community, high stability, and fast query speed, making it widely used in software systems. High availability is a crucial indicator of a software system's reliability, and as a vital component, the database's high availability is particularly critical. Currently, MySQL high-availability solutions typically consist of multiple MySQL nodes. Each node is configured to synchronize, recording local operations in a binary log (binlog). Nodes then use a data synchronization thread to retrieve binlog information from the nodes requiring synchronization and replay the binlog on their own nodes, thus achieving data synchronization. MySQL's synchronization technology heavily relies on the binlog; setting a longer binlog clearing time allows for the retention of more binlog entries, facilitating data recovery in case of errors.

[0003] However, binlog generation is highly correlated with business scenarios. Frequent database modifications result in more binlog records, leading to larger binlog file sizes; conversely, frequent database queries result in fewer binlog records, resulting in smaller binlog file sizes. Therefore, when the service environment is maintained by the customer, it's difficult to uniformly configure storage settings for different customer scenarios. Using the default binlog cleanup time might lead to service interruptions when dealing with large amounts of data due to inappropriate hardware configurations, making it unsuitable for complex customer scenarios.

[0004] In view of the above problems, designing a method for modifying the log clearing time is an urgent problem to be solved by technical personnel in this field. Summary of the Invention

[0005] The purpose of this application is to provide a method, apparatus, and medium for modifying log clearing time, so as to modify the clearing time of log information in complex customer scenarios and improve scenario adaptability.

[0006] To address the aforementioned technical problems, this application provides a method for modifying log clearing time, comprising:

[0007] Obtain the tasks to be executed in the execution cycle;

[0008] Obtain the log information generated when the task is executed within the execution cycle, and determine the storage space occupied by the log information;

[0009] The clearing time of the log information is obtained based on the storage space; wherein, the storage space and the clearing time are positively correlated.

[0010] Preferably, the step of obtaining the clearing time of the log information based on the storage space includes:

[0011] The clearing time corresponding to multiple log messages is obtained based on multiple storage spaces;

[0012] The step of obtaining the clearing time corresponding to multiple log messages based on multiple storage spaces includes:

[0013] Obtain the storage space threshold and the data length of the sliding window; wherein the sliding window contains the number of times the task is executed;

[0014] Obtain the log information generated when the task is executed in each execution cycle within the sliding window, and determine the storage space occupied by each log information;

[0015] The clearing time of the log information is obtained based on the storage space threshold, the data length, and the storage space.

[0016] Preferably, after obtaining the clearing time of the log information based on the storage space, the method further includes:

[0017] Write the clearing time of the log information into the MySQL configuration file for use in clearing the log information.

[0018] Preferably, before obtaining the task to be executed in the execution cycle, the method further includes:

[0019] Determine whether this is the first time the MySQL configuration file has been configured;

[0020] If not, proceed to the step of obtaining the task to be executed in the execution cycle;

[0021] If so, the default time for clearing the generated log information.

[0022] Preferably, the default clearing time for generating the log information includes:

[0023] Obtain the current storage space of the log information;

[0024] The default clearing time for the log information is obtained based on the current storage space.

[0025] Preferably, before determining whether the MySQL configuration file is being configured for the first time, the method further includes:

[0026] Determine whether to enable data synchronization for the MySQL database;

[0027] If so, proceed to the step of determining whether the MySQL configuration file is being configured for the first time.

[0028] Preferably, the method further includes: if a fixed clearing time for the log information is set, then stopping the acquisition of the log information clearing time and writing the fixed clearing time into the configuration file of the MySQL.

[0029] To address the aforementioned technical problems, this application also provides a log clearing time modification device, comprising:

[0030] The first acquisition module is used to acquire the tasks to be executed in the execution cycle;

[0031] The second acquisition module is used to acquire the log information generated when the task is executed within the execution cycle, and to determine the storage space occupied by the log information;

[0032] The third acquisition module is used to acquire the clearing time of the log information based on the storage space; wherein the storage space and the clearing time are positively correlated.

[0033] Preferably, it further includes:

[0034] The writing module is used to write the clearing time of the log information into the MySQL configuration file for clearing the log information.

[0035] Preferably, it further includes:

[0036] The first judgment module is used to determine whether the configuration file of the MySQL is being configured for the first time; if not, the first acquisition module is triggered; if yes, the default clearing time of the log information is generated.

[0037] Preferably, it further includes:

[0038] The second judgment module is used to determine whether data synchronization of the MySQL is enabled; if so, the first judgment module is triggered.

[0039] To address the aforementioned technical problems, this application also provides another log clearing time modification device, comprising:

[0040] Memory, used to store computer programs;

[0041] A processor is configured to implement the steps of the log clearing time modification method described above when executing the computer program.

[0042] To address the aforementioned technical problems, this application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the log clearing time modification method described above.

[0043] The log clearing time modification method provided in this application obtains the tasks to be executed in the execution cycle; obtains the log information generated during the execution of the tasks in the execution cycle and determines the storage space occupied by the log information; and obtains the clearing time of the log information based on the storage space. The storage space and clearing time are positively correlated. Therefore, the above solution, by obtaining different tasks in different customer environments and considering the storage status of the log information generated during task execution, generates corresponding clearing times, with a positive correlation between storage space and clearing time. This enables modification of the log information clearing time in complex customer scenarios, avoiding system operation problems caused by unreasonable log information clearing time configuration, and has stronger scenario adaptability.

[0044] In addition, this application also provides a log clearing time modification device and medium, which have the same effect as above. Attached Figure Description

[0045] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0046] Figure 1 A flowchart illustrating a method for modifying log clearing time provided in an embodiment of this application;

[0047] Figure 2 A flowchart illustrating another method for modifying log clearing time provided in this application embodiment;

[0048] Figure 3 This is a schematic diagram of a log clearing time modification device provided in an embodiment of this application;

[0049] Figure 4 A schematic diagram of another log clearing time modification device provided in an embodiment of this application;

[0050] Figure 5 The flowchart illustrates the log clearing time modification method provided in this application embodiment in an application scenario. Detailed Implementation

[0051] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0052] The core of this application is to provide a method, apparatus, and medium for modifying log clearing time, so as to modify the clearing time of log information in complex customer scenarios and improve scenario adaptability.

[0053] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0054] High-availability solutions for MySQL typically consist of multiple MySQL nodes. Each node is configured with synchronization features enabled, recording local operations in its binlog. The binlog records all MySQL Data Manipulation Language (DML) operations, enabling data recovery, incremental backups, master-master replication, master-slave replication, and more. Nodes then use a data synchronization thread to retrieve binlog information from the nodes requiring synchronization and replay the binlog on their local nodes, thus achieving data synchronization. MySQL's synchronization technology heavily relies on the binlog; setting a longer binlog cleanup interval allows for the retention of more binlog entries, facilitating data recovery in case of errors. However, binlog generation is highly dependent on the business scenario. Frequent database modifications result in more binlog entries, leading to a larger binlog file size; conversely, more frequent database queries result in fewer binlog entries, resulting in a smaller binlog file size. Therefore, when the environment running the service is maintained by the customer, it is difficult to uniformly configure the storage settings for different customer scenarios. Using the default binlog clearing time may lead to service interruptions due to inappropriate hardware configuration when the data volume is large, resulting in poor adaptability to complex customer scenarios. Therefore, the log clearing time modification method provided in this application is mainly applied to the scenario of modifying the binlog clearing time in MySQL synchronization. Figure 1 This is a flowchart illustrating a method for modifying log clearing time, as provided in an embodiment of this application. Figure 1 As shown, the method includes:

[0055] S10: Obtain the task to be executed in the execution cycle.

[0056] S11: Obtain the log information generated during the execution of tasks within the execution cycle, and determine the storage space occupied by the log information.

[0057] S12: Obtain the log information clearing time based on the storage space; where the storage space and clearing time are positively correlated.

[0058] In practice, the first step is to obtain the tasks in the MySQL synchronization process. These tasks have execution cycles and are executed at intervals within those cycles. The log information generated during task execution within each cycle, known as the binlog, is then retrieved, and the storage space occupied by the binlog is determined using a log information space calculation device.

[0059] It should be noted that during the binlog acquisition process, log information from one execution cycle or multiple execution cycles can be obtained; this embodiment does not impose any restrictions. After acquiring the log information, the log information space calculation device confirms the storage space occupied by the log information, mainly confirming the size of the storage space occupied by the binlog file and the percentage of storage space occupied.

[0060] After obtaining the storage space occupied by the log information, the configuration computing device determines the log information clearing time based on the storage space. In this embodiment, the specific method for obtaining the log information clearing time is not limited. The clearing time can be obtained based on the storage space occupied by the log information over multiple execution cycles, or it can be obtained based on the storage space occupied by the log information within a single execution cycle, depending on the specific implementation. Furthermore, storage space and clearing time are positively correlated, meaning that the log information clearing time is positively correlated with the storage space it occupies; that is, when the storage space occupied by the log information changes, the log information clearing time will also change.

[0061] In this embodiment, the following steps are taken: First, the task to be executed within the execution cycle is obtained. Then, log information generated during task execution within the execution cycle is obtained, and the storage space occupied by the log information is determined. Finally, the log information clearing time is obtained based on the storage space. Storage space and clearing time are positively correlated. Therefore, the above solution, by obtaining different tasks under different customer environments and considering the storage status of log information generated during task execution, generates corresponding clearing times, with a positive correlation between storage space and clearing time. This enables modification of log information clearing times in complex customer scenarios, avoiding system operation problems caused by unreasonable log information clearing time configuration, and exhibiting stronger scenario adaptability.

[0062] Based on the above embodiments:

[0063] As a preferred embodiment, the log information clearing time obtained based on storage space includes:

[0064] Obtain the clearing time corresponding to multiple log messages based on multiple storage spaces;

[0065] The clearing time corresponding to multiple log messages obtained from multiple storage spaces includes:

[0066] Obtain the storage space threshold and the data length of the sliding window; the sliding window contains the number of times the task is executed;

[0067] Obtain the log information generated during task execution in each execution cycle within the sliding window, and determine the storage space occupied by each log information;

[0068] The log information is retrieved based on storage space thresholds, data length, and the clearing time for each storage space.

[0069] In the above embodiments, the specific method for obtaining the log information clearing time is not limited and depends on the specific implementation. As a preferred embodiment, in this embodiment, the clearing time corresponding to multiple log information is obtained based on multiple storage spaces, that is, log information generated by tasks within multiple execution cycles is obtained, and then the clearing time is obtained based on the storage space occupied by each of the multiple log information.

[0070] Specifically, the configuration computing device first obtains the storage space threshold m and the data length n of the sliding window. The storage space threshold m is a limit value for disk storage space; the size of the content stored on the disk cannot exceed this threshold. In this embodiment, m can be the default threshold of 0.7. The sliding window is a window that collects log information and storage space generated by tasks within multiple execution cycles, including the number of times the task was executed. The sliding window can also be slid to switch between different task execution cycles on the timeline.

[0071] Furthermore, the log information generated during task execution within each execution cycle of the sliding window is obtained, and the storage space occupied by each log information is determined by the log information space calculation device. The clearing time of the log information is obtained based on the storage space threshold m, the data length n, and the storage space, as shown in the following formula:

[0072]

[0073] It is understandable that i in the formula nThe storage space occupied by log information in the nth execution cycle within the sliding window is the percentage of disk space used; and t is the clearing time of the obtained log information. In practical implementation, log information for a corresponding number of execution cycles can be obtained based on different sliding window data lengths n, and the clearing time can be obtained based on the storage space occupied by each log information.

[0074] In practice, the above formula can be modified, for example, by changing the storage space threshold m or the data length n of the sliding window, and then obtaining the log information clearing time according to the modified formula. It is important to note that if the calculation rules need to be modified, the current process for obtaining the clearing time must be stopped, restarted after the modification is complete, and the process must be executed again from step S10 to finally obtain the log information clearing time.

[0075] In this embodiment, the clearing time corresponding to multiple log messages is obtained based on multiple storage spaces. Specifically, the clearing time of log messages is obtained based on the storage space threshold, the sliding window data length, and the storage space occupied by log messages in each execution cycle of the sliding window. This realizes the acquisition of log message clearing time, which can save log messages for a longer period of time within an appropriate range. It also enables the modification of log message clearing time in complex customer scenarios, and has stronger scenario adaptability.

[0076] Figure 2 A flowchart illustrating another method for modifying log clearing time provided in an embodiment of this application. For example... Figure 2 As shown, after obtaining the log information clearing time based on storage space, the process also includes:

[0077] S13: Write the log message clearing time to the MySQL configuration file for use in clearing log messages.

[0078] It is understood that the log information clearing time obtained in the above embodiments is the binlog clearing time. In order to clear the binlog using this clearing time, it is also necessary to configure MySQL through the configuration file update device to write the obtained clearing time into the MySQL configuration file for use in clearing log information.

[0079] In this embodiment, the log information clearing time is written into the MySQL configuration file to facilitate subsequent log information clearing.

[0080] like Figure 2 As shown, before obtaining the task to be executed in the execution cycle, the following steps are also included:

[0081] S14: Determine if this is the first time configuring the MySQL configuration file; if not, proceed to step S10; if yes, proceed to step S15.

[0082] S15: Default time for clearing generated log information.

[0083] It is understandable that the MySQL configuration file contains configuration information for binlog clearing time. In the above embodiment, the clearing time is generated based on the storage space occupied by the log information generated by the task, and the configuration file is configured accordingly, based on different user scenarios. However, in actual implementation, there should also be a default clearing time for log information. Therefore, before step S10, it is necessary to determine whether the MySQL configuration file is being configured for the first time.

[0084] If it is confirmed that this is not the first time configuring the MySQL configuration file, proceed to step S10; if it is confirmed that this is the first time configuring the MySQL configuration file, generate a default clearing time for log information. In this embodiment, the specific method for generating the default clearing time is not limited and depends on the specific implementation. The default clearing time can be generated using the calculation formula for the clearing time in the above embodiment, or a default clearing time can be set, depending on the specific implementation.

[0085] In this embodiment, before obtaining the task to be executed in the execution cycle, it is also determined whether the MySQL configuration file is configured for the first time. If so, the default clearing time of log information is generated, thus realizing the generation of the default clearing time of log information.

[0086] Based on the above embodiments:

[0087] As a preferred embodiment, the default clearing time for generated log information includes:

[0088] Get the current storage space of the log information;

[0089] The default clearing time for log information is obtained based on the current storage space.

[0090] In the above embodiments, the specific method for generating the default cleanup time is not limited and depends on the specific implementation. As a preferred embodiment, this embodiment first obtains the current storage space of the log information. Since this is the first time configuring the MySQL configuration file, there are no tasks to be executed in the execution cycle, that is, there is no log information to be generated subsequently; however, there will be some initial log information during MySQL synchronization, so the current storage space occupied by this log information is directly obtained through the storage space calculation device.

[0091] Furthermore, the configuration computing device obtains the default clearing time for log information based on the current storage space. The default clearing time can be generated using the formula in the above embodiments. Since only the storage space occupied by the current log information (i.e., the disk space usage percentage) needs to be known, and it can be assumed that there is only one execution cycle in the sliding window during the initial configuration, the data length n of the sliding window is 1. Combined with the storage space threshold m, the default clearing time is obtained using the clearing time calculation formula in the above embodiments. After obtaining the default clearing time, it is written to the MySQL configuration file for use in clearing log information. It is understood that the calculation formula for the default clearing time can also be modified during its generation process, and the modification method is consistent with the above embodiments, which will not be elaborated here.

[0092] In this embodiment, by obtaining the current storage space of log information and obtaining the default clearing time of log information based on the current storage space, the default clearing time is generated when configuring the MySQL configuration file for the first time.

[0093] like Figure 2 As shown, before determining whether it's the first time configuring the MySQL configuration file, the following steps are also included:

[0094] S16: Determine whether MySQL data synchronization is enabled; if yes, proceed to step S14.

[0095] In the above embodiments, the configuration of MySQL needs to be executed under the condition that MySQL is performing data synchronization. Therefore, before step S14, the configuration file analyzer also needs to analyze the configuration file and determine whether the current node has enabled MySQL data synchronization based on the MySQL configuration file. If yes, proceed to step S14; otherwise, end.

[0096] In this embodiment, once MySQL data synchronization is confirmed to be enabled, the system proceeds to determine whether the MySQL configuration file is being configured for the first time, in order to facilitate the clearing of subsequent log information.

[0097] Based on the above embodiments:

[0098] As a preferred embodiment, if a fixed clearing time for log information is set, then the clearing time for obtaining log information will be stopped, and the fixed clearing time will be written into the MySQL configuration file.

[0099] It is understood that the generation of log information clearing time in the above embodiments is based on the storage space occupied by the log information. However, in specific implementations, a fixed clearing time for log information can also be set directly. Specifically, if a fixed clearing time for log information is set, the step of obtaining the clearing time of log information in the above embodiments is stopped, and the configuration file update device writes the fixed clearing time into the MySQL configuration file so that the log information can be cleared using the fixed clearing time in the configuration file.

[0100] In this embodiment, by stopping the clearing time of log information acquisition and writing a fixed clearing time into the MySQL configuration file, the fixed clearing time of log information is set.

[0101] The log clearing time modification method has been described in detail in the above embodiments. This application also provides embodiments corresponding to the log clearing time modification device. It should be noted that this application describes the device embodiments from two perspectives: one is based on the functional modules, and the other is based on the hardware structure.

[0102] Figure 3 This is a schematic diagram of a log clearing time modification device provided in an embodiment of this application.

[0103] like Figure 3 As shown, the log clearing time modification device includes:

[0104] The first acquisition module 10 is used to acquire the tasks to be executed in the execution cycle.

[0105] The second acquisition module 11 is used to acquire the log information generated when the task is executed within the execution cycle, and to determine the storage space occupied by the log information.

[0106] The third acquisition module 12 is used to acquire the clearing time of the log information based on the storage space; wherein the storage space and the clearing time are positively correlated.

[0107] In a preferred embodiment, the log clearing time modification device further includes:

[0108] The write module is used to write the log information clearing time to the MySQL configuration file for use in clearing the log information.

[0109] The first judgment module is used to determine whether the MySQL configuration file is being configured for the first time; if not, the first acquisition module is triggered; if so, the default clearing time for log information is generated.

[0110] The second judgment module is used to determine whether MySQL data synchronization is enabled; if so, the first judgment module is triggered.

[0111] In this embodiment, the log clearing time modification device includes a first acquisition module, a second acquisition module, and a third acquisition module. It acquires the tasks to be executed in the execution cycle; acquires the log information generated during task execution within the execution cycle and determines the storage space occupied by the log information; and obtains the log information clearing time based on the storage space. The storage space and clearing time are positively correlated. Therefore, the above solution, by acquiring different tasks in different customer environments and considering the storage status of log information generated during task execution, generates corresponding clearing times, with a positive correlation between storage space and clearing time. This enables modification of log information clearing time in complex customer scenarios, avoiding system operation problems caused by unreasonable log information clearing time configuration, and exhibiting stronger scenario adaptability.

[0112] Figure 4 This is a schematic diagram of another log clearing time modification device provided in an embodiment of this application. Figure 4 As shown, the log clearing time modification device includes:

[0113] Memory 20 is used to store computer programs.

[0114] The processor 21 is configured to implement the steps of the log clearing time modification method as described in the above embodiments when executing a computer program.

[0115] The log clearing time modification device provided in this embodiment may include, but is not limited to, smartphones, tablets, laptops, or desktop computers.

[0116] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one of the following hardware forms: Digital Signal Processor (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an Artificial Intelligence (AI) processor, which handles computational operations related to machine learning.

[0117] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 20 is used to store at least the following computer program 201, which, after being loaded and executed by the processor 21, is capable of implementing the relevant steps of the log clearing time modification method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, and the storage method may be temporary or permanent storage. The operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include, but is not limited to, the data involved in the log clearing time modification method.

[0118] In some embodiments, the log clearing time modification device may further include a display screen 22, an input / output interface 23, a communication interface 24, a power supply 25, and a communication bus 26.

[0119] Those skilled in the art will understand that Figure 4 The structure shown does not constitute a limitation on the log clearing time modification device and may include more or fewer components than illustrated.

[0120] Finally, this application also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps described in the above method embodiments.

[0121] It is understood that if the methods in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0122] To enable those skilled in the art to better understand the technical solution of this application, the following is combined with... Figure 5 This application will now provide a more detailed description of the above. Figure 5 A flowchart illustrating the log clearing time modification method provided in this application embodiment in an application scenario. For example... Figure 5 As shown, it includes:

[0123] S17: Configuration file analysis;

[0124] S18: Configuration Analysis;

[0125] S19: Obtain the storage space for log information;

[0126] S20: Log information clearing time;

[0127] S21: Configuration file updated.

[0128] The specific application scenario is as follows: analyze the configuration file to confirm the initiation of MySQL synchronization; analyze the configuration status to confirm whether it is the first time the configuration is performed or not; obtain the storage space of log information under different configuration conditions; generate the log information clearing time based on the log information storage space; update the configuration file and write the log information clearing time into the configuration file.

[0129] For example, the configuration file analyzer analyzes the configuration file to confirm that MySQL synchronization is currently enabled. It analyzes the configuration status and, if it's the first configuration, the storage space calculation device obtains the storage space for log information, and the configuration calculation device generates a log information clearing time based on the calculation rules for that storage space. If it's not the first configuration, the log information space calculation device obtains the storage space for log information, and the configuration calculation device generates a log information clearing time based on the calculation rules for that storage space. Then, the configuration file is updated, and the clearing time is written to the configuration file, thus modifying the log information clearing time.

[0130] The above describes the application scenarios of the log clearing time modification method provided in the embodiments of this application, which has the same beneficial effects as the log clearing time modification method mentioned above.

[0131] The above provides a detailed description of a log clearing time modification method, apparatus, and medium provided in this application. The various embodiments in the specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.

[0132] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

Claims

1. A log purge time modification method characterized by, The method comprises the following steps: acquiring a task to be executed in an execution cycle; acquiring log information generated when the task is executed in the execution cycle, and determining storage space occupied by the log information; acquiring a cleaning time of the log information according to the storage space, wherein the storage space and the cleaning time are in a positive correlation relationship; the acquiring of the cleaning time of the log information according to the storage space comprises: acquiring cleaning times corresponding to a plurality of pieces of the log information according to a plurality of the storage spaces; the acquiring of the cleaning times corresponding to the plurality of pieces of the log information according to the plurality of the storage spaces comprises: acquiring a storage space threshold and a data length of a sliding window, wherein the sliding window comprises a number of times of execution of the task; acquiring each piece of the log information generated when the task is executed in each of the execution cycles in the sliding window, and determining each of the storage spaces occupied by each piece of the log information; acquiring the cleaning time of the log information according to the storage space threshold, the data length and each of the storage spaces, and the formula is as follows: ; Wherein, t is the cleaning time of the log information, i n is the percentage of the disk space occupied by the log information in the n th execution cycle in the sliding window, m is the storage space threshold, and n is the data length.

2. The log cleaning time modification method according to claim 1, characterized by, after the acquiring of the cleaning time of the log information according to the storage space, the method further comprises the following steps: writing the cleaning time of the log information into a configuration file of MySQL, so as to clean the log information.

3. The log cleaning time modification method according to claim 2, characterized by, before the acquiring of the task to be executed in the execution cycle, the method further comprises the following steps: judging whether the configuration file of the MySQL is configured for the first time; if not, entering the step of acquiring the task to be executed in the execution cycle; if yes, generating a default cleaning time of the log information.

4. The log cleaning time modification method according to claim 3, characterized by, the generating of the default cleaning time of the log information comprises the following steps: acquiring a current storage space of the log information; acquiring the default cleaning time of the log information according to the current storage space.

5. The log cleaning time modification method according to claim 3, characterized by, before the judging of whether the configuration file of the MySQL is configured for the first time, the method further comprises the following steps: judging whether data synchronization of the MySQL is started; if yes, entering the step of judging whether the configuration file of the MySQL is configured for the first time.

6. The log cleaning time modification method according to claim 5, characterized by, the method further comprises the following steps: if a fixed cleaning time of the log information is set, stopping the acquiring of the cleaning time of the log information, and writing the fixed cleaning time into the configuration file of the MySQL.

7. A log cleaning time modification apparatus characterized by comprising: The method comprises the following steps: a first acquiring module is configured to acquire a task to be executed in an execution cycle; a second acquiring module is configured to acquire log information generated when the task is executed in the execution cycle, and determine storage space occupied by the log information; a third acquiring module is configured to acquire a cleaning time of the log information according to the storage space, wherein the storage space and the cleaning time are in a positive correlation relationship; the acquiring of the cleaning time of the log information according to the storage space comprises: acquiring cleaning times corresponding to a plurality of pieces of the log information according to a plurality of the storage spaces; the acquiring of the cleaning times corresponding to the plurality of pieces of the log information according to the plurality of the storage spaces comprises: acquiring a storage space threshold and a data length of a sliding window, wherein the sliding window comprises a number of times of execution of the task; acquiring each piece of the log information generated when the task is executed in each of the execution cycles in the sliding window, and determining each of the storage spaces occupied by each piece of the log information; acquiring the cleaning time of the log information according to the storage space threshold, the data length and each of the storage spaces, and the formula is as follows: acquiring each log information generated when executing the task in each execution period in the sliding window, and determining each storage space occupied by each log information; obtaining a cleaning time of the log information according to the storage space threshold, the data length and each storage space, and the formula is as follows: ; wherein t is the cleaning time of the log information, i n is the percentage of the disk space occupied by the log information in the n th execution cycle in the sliding window, m is the storage space threshold, and n is the data length.

8. A log cleaning time modification apparatus characterized by comprising: comprising: a memory for storing a computer program; a processor for executing the computer program to implement the steps of the log cleaning time modification method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the steps of the log cleaning time modification method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Log information writing method and system, storage medium and mobile terminal

    CN110716908A

  • Big data cluster log storage method, device and equipment and storage medium

    CN111008107A