A log processing method, computer program product, device and medium

By collecting and temporarily storing log data in the server and implementing multiple backup storage in the hard disk, the problem of too little log information caused by limited flash memory capacity is solved, the reliability and fault tolerance rate of log storage are improved, and better fault analysis is supported. and performance optimization.

CN118245461BActive Publication Date: 2024-08-23INSPUR (SHANDONG) COMPUTER TECH CO LTD
View PDF 13 Cites 0 Cited by

Patent Information

Application Number
CN202410667099.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-28
Publication Date
2024-08-23
Estimated Expiration
2044-05-28

AI Technical Summary

Technical Problem

In the existing technology, server operation logs are stored in flash memory due to limited capacity, resulting in too little log information, making it difficult to locate faults in a timely manner and perform system monitoring and performance optimization.

Method used

By collecting log data generated in real time and temporarily storing it in the cache area, multiple available hard disks are determined when the log disk placement conditions are met, and log management structure information is detected and written to realize multiple backup storage of log data and improve storage reliability. performance and fault tolerance.

Benefits of technology

The reliability, data volume, timeliness and fault tolerance rate of log storage have been improved. Logs can be viewed in a timely manner even in the event of a fault, providing better fault analysis and performance optimization support.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118245461B
    Figure CN118245461B
Patent Text Reader

Abstract

The present invention discloses a log processing method, a computer program product, a device and a medium in the field of computer technology. The present invention transfers the real-time generated log data from the cache area to multiple hard disks, realizes multiple backup storage of the same log, can improve the reliability, data volume, timeliness and fault tolerance of log storage, and even if the system crashes due to program failure, log viewing is not affected; at the same time, each hard disk is provided with log management structure information, which records whether the current disk is full of flags, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk, thereby timely calibrating the log writing position, improving the efficiency of log placement, and providing more data support for system fault analysis and performance optimization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a log processing method, a computer program product, a device and a medium. Background Art

[0002] At present, important operation logs of servers and other systems are generally stored in flash memory, but due to the limited capacity of flash memory, a large number of operation logs are overwritten and lost during the storage process. When a server fails, it may be impossible to locate the fault and restore the scene in time because there is too little stored operation log information, which brings inconvenience to fault analysis. In addition, due to the small amount of stored log information, it is also extremely difficult to carry out system monitoring and performance optimization.

[0003] Therefore, how to improve the storage capacity and reliability of system operation logs is a problem that those skilled in the art need to solve. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide a log processing method, computer program product, device and medium to improve the storage capacity and reliability of system operation logs. The specific scheme is as follows:

[0005] In a first aspect, the present invention provides a log processing method, comprising:

[0006] Collect log data generated in real time;

[0007] Temporarily storing the log data in a pre-applied buffer area;

[0008] Determine multiple available hard disks when the log flushing conditions are met;

[0009] Detect whether there is log management structure information in each available hard disk; wherein the log management structure information in each available hard disk includes: whether the current disk is full of flags, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk;

[0010] If log management structure information exists in each available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in each available hard disk according to the log management structure information in each available hard disk, and the log management structure information in each available hard disk is updated to record whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0011] On the other hand, the log storage conditions are: the cache area is full, or the time point for storing logs is reached, or the system is abnormally powered off;

[0012] Accordingly, when the log storage condition is met, multiple available hard disks are determined, including:

[0013] When the cache area is full, multiple available hard disks are determined; or when a timed time point for log write to disk is reached, multiple available hard disks are determined; when the system loses power abnormally, multiple available hard disks are determined.

[0014] On the other hand, identify multiple available hard disks, including:

[0015] Query the disk information of each hard disk in the system; the disk information includes: whether the disk is running normally, the remaining capacity of the disk, the total capacity of the disk and the base address of the disk;

[0016] Select multiple available hard disks based on the disk information of each hard disk.

[0017] On the other hand, each hard disk is divided into a plurality of logic blocks of equal size, and the space size of a single logic block is not less than the space size of the cache area.

[0018] On the other hand, writing the log data in the buffer area to the next writable logical block indicated by the log management structure information in each available hard disk includes:

[0019] Querying the disk physical address corresponding to the next writable logical block indicated by the log management structure information in each available hard disk through the memory management unit;

[0020] The log data in the buffer area is written into the corresponding disk physical address.

[0021] On the other hand, it also includes:

[0022] If the log management structure information does not exist in any available hard disk, after the log management structure information is created in the currently available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in the currently available hard disk according to the log management structure information in the currently available hard disk, and the log management structure information in the currently available hard disk is updated to record whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0023] On the other hand, it also includes:

[0024] If the log management structure information in any available hard disk indicates that the current disk is full, then the logical block with the longest data storage time in the current available hard disk is erased;

[0025] The erased logical block is used as the next writable logical block indicated by the log management structure information in the currently available hard disk, and the log management structure information in the currently available hard disk records whether the current disk is full and the amount of data stored in each logical block in the current disk. According to the log management structure information in the currently available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in the currently available hard disk, and the log management structure information in the currently available hard disk records whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0026] On the other hand, it also includes:

[0027] Query the log management structure information in each hard disk through the preset log query interface;

[0028] Compare the log management structure information in each hard disk to determine the hard disk with the largest amount of stored data;

[0029] Read the log data from the hard disk with the largest storage data volume for log analysis.

[0030] On the other hand, compare the log management structure information in each hard disk to determine the hard disk with the largest amount of stored data, including:

[0031] Compare the identification addresses of the next writable logical blocks recorded in the log management structure information in each hard disk to determine the next writable logical block with the largest identification address;

[0032] The hard disk where the next writable logical block with the largest identification address is located is used as the hard disk with the largest storage data volume.

[0033] On the other hand, it also includes:

[0034] Query the log data in each hard disk through the preset log query interface;

[0035] After reading the log data in each hard disk, perform a merge operation and a deduplication operation on all the read log data to obtain a merged and deduplicated result;

[0036] Perform log analysis on the merged deduplication result.

[0037] On the other hand, log data generated in real time is collected, including:

[0038] Filter the raw log data generated in real time;

[0039] Collect filtered log data.

[0040] On the other hand, before temporarily storing the log data in the pre-applied buffer area, the method further includes:

[0041] The log data is converted into a unified target data format, and a log timestamp and event type are added.

[0042] In another aspect, the present invention provides an electronic device, comprising:

[0043] Memory for storing computer programs;

[0044] The processor is used to execute the computer program to implement the aforementioned disclosed log processing method.

[0045] On the other hand, the present invention provides a non-volatile storage medium for storing a computer program, wherein the computer program implements the aforementioned disclosed log processing method when executed by a processor.

[0046] On the other hand, the present invention provides a computer program product, including a computer program / instruction, which implements the steps of the aforementioned disclosed log processing method when executed by a processor.

[0047] It can be seen from the above scheme that the present invention provides a log processing method, including: collecting log data generated in real time; temporarily storing the log data in a pre-applied cache area; determining multiple available hard disks when the log storage condition is met; detecting whether there is log management structure information in each available hard disk; wherein the log management structure information in each available hard disk includes: whether the current disk is full of flags, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk; if there is log management structure information in each available hard disk, then according to the log management structure information in each available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in each available hard disk, and the log management structure information in each available hard disk records whether the current disk is full of flags, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0048] It can be seen that the beneficial effects of the present invention are: the log data generated in real time is transferred from the cache area to multiple hard disks, thereby realizing multiple backup storage of the same log, which can improve the reliability, data volume, timeliness and fault tolerance of log storage, and even if the system crashes due to a program failure, log viewing will not be affected; at the same time, each hard disk is provided with log management structure information, which records whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk, thereby being able to timely calibrate the log write position, improve the efficiency of log placement, and provide more data support for system fault analysis and performance optimization.

[0049] Correspondingly, a log processing computer program product, device and medium provided by the present invention also have the above-mentioned technical effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0051] Figure 1 A flow chart of a log processing method disclosed in the present invention;

[0052] Figure 2 A flow chart of a log storage process method disclosed in the present invention;

[0053] Figure 3 A schematic diagram of the connection between a RAID card and a hard disk disclosed in the present invention;

[0054] Figure 4 A flow chart of a method for saving logs using a timer disclosed in the present invention;

[0055] Figure 5 A disk saving flow chart disclosed in the present invention;

[0056] Figure 6 A schematic diagram of a hard disk storing data disclosed in the present invention;

[0057] Figure 7 A schematic diagram of a log processing device disclosed in the present invention;

[0058] Figure 8 A server structure diagram provided by the present invention;

[0059] Fig. 9 A terminal structure diagram provided by the present invention. DETAILED DESCRIPTION

[0060] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other examples obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0061] At present, generally, important operation logs of systems such as servers are stored in flash memory, but due to the limited capacity of flash memory, a large number of operation logs are overwritten and lost during the storage process. When a server fails, it may be too little to locate the fault and restore the scene in time, which brings inconvenience to fault analysis. In addition, due to the little log information stored, it is also very difficult to carry out system monitoring and performance optimization. For this reason, the present invention provides a log processing scheme, which can improve the reliability, data volume, timeliness and fault tolerance of log storage.

[0062] See also Figure 1 As shown, an embodiment of the present invention discloses a log processing method, including:

[0063] S101. Collect log data generated in real time.

[0064] Log data is a record or file that records the activities of the system, application or event in the server, usually including information about operations, status, errors, warnings, events, etc. It can be stored in the form of text files for easy viewing, searching and analysis, and can contain timestamps, messages, levels, event types and other information. Its main function is to track and record the operation of the system or application so as to conduct troubleshooting, performance analysis, security audits and problem solving when necessary. It can be seen that by collecting and analyzing key system logs, engineers can remotely monitor the system for maintenance and fault location, and can also provide strong support for security audit functions.

[0065] The method provided in this embodiment is applied to computer devices such as servers, and the log data is log information about operations, states, errors, warnings, and events generated by the operation of the device, such as RAID card operation logs. In one embodiment, collecting the log data generated in real time includes: filtering the original log data generated in real time; and collecting the filtered log data. Among them, the preset filtering rules can be used to remove unimportant log data that does not affect the operation of the device to achieve log filtering.

[0066] S102: temporarily storing the log data in a pre-applied buffer area.

[0067] In one embodiment, before temporarily storing the log data in a pre-applied cache area, the process also includes: converting the log data into a unified target data format (such as text, XML, JSON, etc.), and adding a log timestamp and event type to facilitate subsequent log retrieval and analysis.

[0068] S103: Determine multiple available hard disks when the log storage condition is met.

[0069] Multiple hard disks can be plugged into computer devices such as servers. Some hard disks may operate abnormally due to software failure or hardware failure. These are unavailable hard disks, while others are available hard disks. Each hard disk is divided into multiple logical blocks of equal size, and the space size of a single logical block is not less than the space size of the cache area. In one embodiment, determining multiple available hard disks includes: querying the disk information of each hard disk in the system; the disk information includes: whether the disk is operating normally, the remaining capacity of the disk, the total capacity of the disk, and the disk base address; and selecting multiple available hard disks based on the disk information of each hard disk.

[0070] In one embodiment, the conditions for log writing to disk are: the cache area is full, or the time point for log writing to disk is reached, or the system loses power abnormally; accordingly, multiple available hard disks are determined when the conditions for log writing to disk are met, including: determining multiple available hard disks when the cache area is full; or determining multiple available hard disks when the time point for log writing to disk is reached; determining multiple available hard disks when the system loses power abnormally.

[0071] S104: Detect whether there is log management structure information in each available hard disk.

[0072] The log management structure information in each available hard disk includes: whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0073] S105. If log management structure information exists in each available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in each available hard disk according to the log management structure information in each available hard disk, and the log management structure information in each available hard disk is updated to record whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0074] S106. If the log management structure information does not exist in any available hard disk, after the log management structure information is created in the currently available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in the currently available hard disk according to the log management structure information in the currently available hard disk, and the log management structure information in the currently available hard disk is updated to record whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0075] After the log data in the buffer area is written to the next writable logical block indicated by the log management structure information in the available hard disk, the buffer area is cleared so that the buffer area can temporarily store the newly generated logs.

[0076] In one embodiment, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in each available hard disk, including: querying the disk physical address corresponding to the next writable logical block indicated by the log management structure information in each available hard disk through the memory management unit; and writing the log data in the cache area to the corresponding disk physical address.

[0077] In one embodiment, if the log management structure information in any available hard disk indicates that the current disk is full, the logical block that has stored data for the longest time in the current available hard disk is erased; the erased logical block is used as the next writable logical block indicated by the log management structure information in the current available hard disk, and the log management structure information in the current available hard disk records whether the current disk is full and the amount of data stored in each logical block in the current disk. According to the log management structure information in the current available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in the current available hard disk, and the log management structure information in the current available hard disk records whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0078] In one embodiment, the log management structure information in each hard disk is queried through a preset log query interface; the log management structure information in each hard disk is compared to determine the hard disk with the largest amount of stored data; the log data in the hard disk with the largest amount of stored data is read to perform log analysis. In one embodiment, the log management structure information in each hard disk is compared to determine the hard disk with the largest amount of stored data, including: comparing the identification address of the next writable logical block recorded in the log management structure information in each hard disk to determine the next writable logical block with the largest identification address; the hard disk where the next writable logical block with the largest identification address is located is used as the hard disk with the largest amount of stored data.

[0079] In one embodiment, the log data in each hard disk is queried through a preset log query interface; after reading the log data in each hard disk, all the read log data are merged and deduplicated to obtain a merged and deduplicated result; and log analysis is performed on the merged and deduplicated result.

[0080] It can be seen that this embodiment transfers the real-time generated log data from the cache area to multiple hard disks, realizes multiple backup storage of the same log, and can improve the reliability, data volume, timeliness and fault tolerance of log storage. Even if a program failure causes the system to crash, log viewing will not be affected. At the same time, each hard disk is provided with log management structure information, which records whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk. In this way, the log write position can be calibrated in time, the efficiency of log placement can be improved, and more data support can be provided for system fault analysis and performance optimization.

[0081] See also Figure 2 , the log storage process generally includes:

[0082] 1. Collect logs: Systems, applications or devices will generate various types of logs, such as event logs, error logs and security logs, which may contain key operation and event information. In the process of log preservation, you first need to collect these logs.

[0083] 2. Screening and filtering: Since logs may generate a large amount of data, in order to improve storage efficiency and reduce storage costs, logs can be screened and filtered. You can define screening rules and filtering conditions according to your needs and goals to save only the required and important log information.

[0084] 3. Storage formatting: Before saving the log to the storage medium, you can format the log. You can convert the log into a specific format, such as text, XML, JSON, etc. If necessary, you can add timestamps and event types to facilitate subsequent retrieval and analysis.

[0085] 4. Storage location selection: Choose an appropriate storage location to save logs, which can be local storage media (such as hard disk, flash memory), network storage (such as file server, network attached storage) or cloud storage service. Among them, you can consider factors such as capacity, reliability, scalability and security when choosing a storage location.

[0086] 5. Storage management: Once the logs are saved, storage management is required to ensure their integrity and availability. Storage management includes regular backup, archiving, and deletion of old, no longer needed logs. Storage management strategies can be formulated based on demand and compliance requirements, and then used to manage the log data stored in each hard disk.

[0087] 6. Monitoring and alarm: During the log storage process, monitoring and alarm are required to ensure the normal storage and availability of logs. Specifically, it can include: monitoring storage space usage, detecting storage failures, monitoring the rate of log generation, etc. When an abnormal situation occurs, an alarm message is sent to notify relevant personnel.

[0088] In this embodiment, each hard disk is combined into a RAID (Redundant Array of Independent Disks). RAID is a data storage technology. Simply put, it is a technology that combines multiple independent physical hard disks in different ways to form a hard disk group, thereby providing higher storage performance and data backup than a single hard disk. RAID card is a hardware device used to control and manage RAID arrays. The connection between RAID card and hard disk is as follows: Figure 3 As shown in the figure. RAID is a technology that combines multiple independent hard disks to form a logical volume. RAID can provide functions such as data redundancy, fault tolerance, and performance enhancement. RAID technology protects data and improves data read and write performance by distributing data on multiple disks and using different data distribution and redundancy strategies.

[0089] In this embodiment, a logical block is set as the smallest storage unit in a hard disk, that is, a hard disk is divided into a number of logical blocks. Assuming that the hard disk space is 16M and each logical block is 4K, then a hard disk has a total of 16M / 4K=4096 logical blocks. Of course, the space size of a logical block can be 512 bytes, etc., which can be set specifically according to the server operating system.

[0090] LBA (Logical Block Address) is an addressing method for disk storage, which divides the disk into logical blocks and uses logical block addresses to access them. LBA provides a unified addressing method that allows operating systems and applications to directly access data on disks. In RAID, LBA is used as a mapping between logical volumes and physical disks. Logical volumes are logically divided into multiple logical blocks, and the addresses of these logical blocks are LBA. The RAID controller is responsible for mapping logical blocks to corresponding locations on physical disks and performing data read and write operations. With RAID technology, the LBA address space of a logical volume can exceed the capacity limit of a single physical disk because RAID can distribute data across multiple physical disks. The RAID controller divides the data into blocks and distributes them to different physical disks to provide redundancy or performance enhancement based on the specific RAID level and configuration. In summary, LBA is a disk data addressing method, and RAID is a technology that forms a logical volume by combining multiple independent hard disks. RAID uses LBA to map the relationship between logical volumes and physical disks and to achieve data distribution and redundancy. RAID can provide higher storage performance, fault tolerance, and scalability, while using LBA to provide transparent access to logical volumes.

[0091] In order to improve the capacity and reliability of log storage, this embodiment takes advantage of the rich hard disk resources of the RAID card to store a large number of operation logs in a specific area of ​​the hard disk, thereby realizing the need to store a large number of logs without occupying flash memory resources. At the same time, the log management structure information is designed to provide great convenience for log storage and subsequent management and monitoring analysis.

[0092] See also Figure 4 , you can use the timer to save the log. The specific steps include:

[0093] Step 1: Apply for a buffer: Apply for a buffer in the memory. To improve the utilization of the hard disk, the size of the buffer can refer to the size of a single logical block. In this example, the buffer is applied for 4096 bytes (4KB). The buffer size remains the same as the size of a single logical block.

[0094] Step 2, initialize the timer: Apply for a periodic software timer to handle the situation where the buffer is not full for a long time, resulting in the log content in the buffer not being saved to the hard disk in time. This is an alternative solution for saving logs to the hard disk. The timer time can be set according to the frequency of log generation in the system.

[0095] Step 3: Create a task to monitor in real time whether the buffer is full and whether the timer has expired. If any of the conditions are met, the save process can be started. When the save process is completed, the buffer is cleared.

[0096] In one example, the save process can be seen in Figure 5 , the specific steps include:

[0097] Step 1: Get the list of available disks: Since the server usually has many hard disks, in order to ensure reliability, a copy of the log is saved on each available disk. Here, first check whether the disk is in place to get the list of available disks.

[0098] Step 2: Get the basic information of the current disk, including logical block base address, disk capacity, etc.

[0099] Step 3: Read the log management structure information.

[0100] For the convenience of management, this embodiment designs a log management structure information to manage the hard disk storing logs. The log management structure information of a disk includes: whether the disk is full, the logical block number to be written when saving logs next time, and the size of the saved logs in each logical block except the management logical block. The management logical block is located at the first position in the current disk and is used to store the log management structure information of the disk. If the log management structure information can be read from a disk, it means that logs have been saved on this disk. You can directly save and update the log management structure information on this disk later; if you cannot read the log management information, it means that no log has been saved on this disk (usually occurs when saving for the first time). At this time, you need to create a new log management structure information on this disk. The detailed steps include: if the flag is_full=false on a disk, the number of available logical blocks on the disk lba_wrote_size=4092=4096-4, and the logical block number to be written when saving the log next time is 5, which is represented by save_loc=4 (4 means that the number of the next logical block to be written is 5), then no log has been saved on this disk. The first 4 logical blocks are management logical blocks, so the total number of logical blocks on the disk 4096 minus 4 equals the number of available logical blocks on the disk. In this example, the first 4 logical blocks are reserved as management logical blocks, and of course more or fewer management logical blocks can be reserved.

[0101] Each hard disk corresponds to a log management structure information, such as Figure 6 As shown, each row represents a hard disk.

[0102] Step 4: Determine whether the current disk is full according to is_full in the management structure. If it is full, erase the oldest log content first. If it is not full, proceed to step 5.

[0103] Step 5: Write the log content to the disk.

[0104] Step 6: Update the log management structure information, including: lba_wrote_size[save_loc]=write disk size (i.e. buffer content size); save_loc=save_loc+1; if save_loc exceeds the size of the available logical block, save_loc=0, is_full=true; then write the updated management structure information back to the beginning of the first logical block.

[0105] At this point, the log storage for a single disk has ended.

[0106] Since this embodiment is used to save the same log to multiple hard disks, each available disk can be processed cyclically by repeating steps 2 to 6, ensuring that a copy of the log content is saved on each disk, thereby improving log reliability.

[0107] Furthermore, this embodiment also provides a log query interface. Through the log query interface, it is possible to query and determine which hard disk has the most complete logs, where the log with the largest save_loc value is the most complete; if the save_loc values ​​of multiple hard disks are the same, the logs in these two hard disks can be merged, and then deduplication can be performed. Of course, the logs in all hard disks can also be merged, and then deduplication can be performed.

[0108] This embodiment proposes a method for improving the log storage capacity and reliability. By saving the operation log data of the RAID card on the hard disk, the log storage capacity is improved. By saving the log on each disk, the reliability and fault tolerance of the log are increased. By adding a timer storage mechanism, the timeliness of log storage is guaranteed. At the same time, the log management structure is designed to make the storage and viewing of the log clear and convenient. It provides strong data support for RAID card fault analysis, performance monitoring optimization and compliance audit, and solves the problems of limited storage capacity of RAID card logs, inability to view after power failure, lack of flexibility and reliability, etc.

[0109] A log processing device provided by an embodiment of the present invention is introduced below. The log processing device described below can be referenced to other embodiments described in this document.

[0110] See also Figure 7 As shown, an embodiment of the present invention discloses a log processing device, including:

[0111] The collection module 701 is used to collect log data generated in real time;

[0112] A temporary storage module 702 is used to temporarily store the log data in a pre-applied buffer area;

[0113] A determination module 703 is used to determine a plurality of available hard disks when the log storage condition is met;

[0114] The detection module 704 is used to detect whether there is log management structure information in each available hard disk; wherein the log management structure information in each available hard disk includes: whether the current disk is full of flags, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk;

[0115] Storage module 705 is used to write the log data in the cache area to the next writable logical block indicated by the log management structure information in each available hard disk if there is log management structure information in each available hard disk, and update the log management structure information in each available hard disk to record whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0116] In one embodiment, the conditions for the log to be written to the disk are: the cache area is full, or the time point for the log to be written to the disk is reached, or the system loses power abnormally; accordingly, the determination module is specifically used to: determine multiple available hard disks when the cache area is full; or determine multiple available hard disks when the time point for the log to be written to the disk is reached; determine multiple available hard disks when the system loses power abnormally.

[0117] In one embodiment, the determination module is specifically used to: query the disk information of each hard disk in the system; the disk information includes: whether the disk is operating normally, the remaining capacity of the disk, the total capacity of the disk and the disk base address; select multiple available hard disks according to the disk information of each hard disk.

[0118] In one implementation, each hard disk is divided into a plurality of logic blocks of equal size, and the space size of a single logic block is not less than the space size of the cache area.

[0119] In one embodiment, the storage module is specifically used for:

[0120] Querying the disk physical address corresponding to the next writable logical block indicated by the log management structure information in each available hard disk through the memory management unit;

[0121] The log data in the buffer area is written into the corresponding disk physical address.

[0122] In one embodiment, the storage module is also used for: if the log management structure information does not exist in any available hard disk, then after creating the log management structure information in the currently available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in the currently available hard disk according to the log management structure information in the currently available hard disk, and the log management structure information in the currently available hard disk is updated to record whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0123] In one embodiment, the storage module is also used for: if the log management structure information in any available hard disk indicates that the current disk is full, then erasing the logical block that has stored data for the longest time in the currently available hard disk; using the erased logical block as the next writable logical block indicated by the log management structure information in the currently available hard disk, and updating the current disk full flag and the amount of data stored in each logical block in the current disk recorded in the log management structure information in the currently available hard disk; according to the log management structure information in the currently available hard disk, writing the log data in the cache area to the next writable logical block indicated by the log management structure information in the currently available hard disk, and updating the current disk full flag, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk recorded in the log management structure information in the currently available hard disk.

[0124] In one embodiment, it further includes:

[0125] The query module is used to query the log management structure information in each hard disk through a preset log query interface; compare the log management structure information in each hard disk to determine the hard disk with the largest amount of stored data; read the log data in the hard disk with the largest amount of stored data to perform log analysis.

[0126] In one embodiment, the query module is specifically used to: compare the identification address of the next writable logical block recorded in the log management structure information of each hard disk to determine the next writable logical block with the largest identification address; and use the hard disk where the next writable logical block with the largest identification address is located as the hard disk with the largest amount of stored data.

[0127] In one embodiment, it further includes:

[0128] The query module is used to query the log data in each hard disk through a preset log query interface; after reading the log data in each hard disk, merge and deduplicate all the read log data to obtain a merged and deduplicated result; and perform log analysis on the merged and deduplicated result.

[0129] In one embodiment, the collection module is specifically used for:

[0130] Filter the raw log data generated in real time;

[0131] Collect filtered log data.

[0132] In one embodiment, it further includes:

[0133] The format conversion module is used to convert the log data into a unified target data format and add a log timestamp and event type.

[0134] Among them, for more specific working processes of each module and unit in this embodiment, reference can be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0135] It can be seen that this embodiment provides a log processing device, which can improve the reliability, data volume, timeliness and fault tolerance of log storage.

[0136] An electronic device provided by an embodiment of the present invention is introduced below. The electronic device described below can be referenced to other embodiments described in this document.

[0137] An embodiment of the present invention discloses an electronic device, including:

[0138] Memory, used to store computer programs;

[0139] A processor is used to execute the computer program to implement the method disclosed in any of the above embodiments.

[0140] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: collecting log data generated in real time; temporarily storing the log data in a pre-applied cache area; determining multiple available hard disks when the log storage conditions are met; detecting whether there is log management structure information in each available hard disk; wherein the log management structure information in each available hard disk includes: whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk; if log management structure information exists in each available hard disk, then according to the log management structure information in each available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in each available hard disk, and the log management structure information in each available hard disk records whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0141] In this embodiment, when the processor executes the computer program stored in the memory, the following steps may be specifically implemented: determining multiple available hard disks when the cache area is full; or determining multiple available hard disks when the timed time point for log write to disk is reached; determining multiple available hard disks when the system loses power abnormally. The log write to disk conditions are: the cache area is full, or the timed time point for log write to disk is reached, or the system loses power abnormally.

[0142] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: querying the disk information of each hard disk in the system; the disk information includes: whether the disk is operating normally, the remaining capacity of the disk, the total capacity of the disk and the disk base address; selecting multiple available hard disks based on the disk information of each hard disk.

[0143] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: querying the disk physical address corresponding to the next writable logical block indicated by the log management structure information in each available hard disk through the memory management unit; writing the log data in the cache area to the corresponding disk physical address.

[0144] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: if the log management structure information does not exist in any available hard disk, then after creating the log management structure information in the currently available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in the currently available hard disk according to the log management structure information in the currently available hard disk, and the log management structure information in the currently available hard disk records whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0145] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: if the log management structure information in any available hard disk indicates that the current disk is full, then the logical block that has stored data for the longest time in the currently available hard disk is erased; the erased logical block is used as the next writable logical block indicated by the log management structure information in the currently available hard disk, and the log management structure information in the currently available hard disk records whether the current disk is full and the amount of data stored in each logical block in the current disk. According to the log management structure information in the currently available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in the currently available hard disk, and the log management structure information in the currently available hard disk records whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0146] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: querying the log management structure information in each hard disk through a preset log query interface; comparing the log management structure information in each hard disk to determine the hard disk with the largest amount of stored data; reading the log data in the hard disk with the largest amount of stored data to perform log analysis.

[0147] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: comparing the identification address of the next writable logical block recorded in the log management structure information in each hard disk to determine the next writable logical block with the largest identification address; and using the hard disk where the next writable logical block with the largest identification address is located as the hard disk with the largest amount of stored data.

[0148] In this embodiment, when the processor executes the computer program stored in the memory, the following steps can be specifically implemented: querying the log data in each hard disk through a preset log query interface; after reading the log data in each hard disk, performing a merge operation and a deduplication operation on all the read log data to obtain a merged and deduplicated result; and performing log analysis on the merged and deduplicated result.

[0149] Furthermore, an embodiment of the present invention also provides an electronic device. The electronic device can be Figure 8 The server shown can also be Fig. 9 Terminal shown. Figure 8 and Fig. 9 All of them are structural diagrams of electronic devices according to an exemplary embodiment, and the contents in the diagrams cannot be regarded as any limitation on the scope of application of the present invention.

[0150] Figure 8 A schematic diagram of the structure of a server provided in an embodiment of the present invention. The server may specifically include: at least one processor, at least one memory, a power supply, a communication interface, an input / output interface, and a communication bus. The memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the relevant steps in the log processing disclosed in any of the aforementioned embodiments.

[0151] In this embodiment, the power supply is used to provide working voltage for each hardware device on the server; the communication interface can create a data transmission channel between the server and external devices, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present invention, and is not specifically limited here; the input and output interface is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0152] In addition, the memory as a carrier for resource storage can be a read-only memory, random access memory, disk or CD, etc. The resources stored thereon include operating system, computer programs and data, etc. The storage method can be temporary storage or permanent storage.

[0153] The operating system is used to manage and control the hardware devices and computer programs on the server to realize the operation and processing of the data in the memory by the processor, and it can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the log processing method disclosed in any of the aforementioned embodiments, the computer program can further include computer programs that can be used to complete other specific tasks. In addition to data such as application update information, the data can also include data such as application developer information.

[0154] Fig. 9 A schematic diagram of the structure of a terminal provided in an embodiment of the present invention, wherein the terminal may specifically include but is not limited to a smart phone, a tablet computer, a laptop computer or a desktop computer.

[0155] Generally, the terminal in this embodiment includes: a processor and a memory.

[0156] Among them, the processor may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0157] The memory may include one or more computer non-volatile storage media, which may be non-transitory. The memory may also include high-speed random access memory, and non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory is at least used to store the following computer program, wherein, after the computer program is loaded and executed by the processor, it can implement the relevant steps in the log processing method performed by the terminal side disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory may also include an operating system and data, etc., and the storage method may be short-term storage or permanent storage. Among them, the operating system may include Windows, Unix, Linux, etc. The data may include but is not limited to update information of the application.

[0158] In some embodiments, the terminal may also include a display screen, an input and output interface, a communication interface, a sensor, a power supply, and a communication bus.

[0159] Those skilled in the art will understand that Fig. 9 The structure shown in the figure does not constitute a limitation on the terminal, and may include more or fewer components than those shown in the figure.

[0160] A nonvolatile storage medium provided in an embodiment of the present invention is introduced below. The nonvolatile storage medium described below and other embodiments described herein may be cross-referenced.

[0161] A non-volatile storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the log processing method disclosed in the above embodiment. The non-volatile storage medium is a computer-readable non-volatile storage medium, which, as a carrier for resource storage, may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system, a computer program and data, etc., and the storage method may be temporary storage or permanent storage.

[0162] In this embodiment, the computer program executed by the processor can specifically implement the following steps: collect log data generated in real time; temporarily store the log data in a pre-applied cache area; determine multiple available hard disks when the log storage conditions are met; detect whether there is log management structure information in each available hard disk; wherein the log management structure information in each available hard disk includes: whether the current disk is full of flags, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk; if log management structure information exists in each available hard disk, then according to the log management structure information in each available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in each available hard disk, and the log management structure information in each available hard disk records whether the current disk is full of flags, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0163] In this embodiment, the computer program executed by the processor can specifically implement the following steps: determining multiple available hard disks when the cache area is full; or determining multiple available hard disks when the timer for log write to disk is reached; determining multiple available hard disks when the system loses power abnormally. The log write to disk conditions are: the cache area is full, or the timer for log write to disk is reached, or the system loses power abnormally.

[0164] In this embodiment, the computer program executed by the processor can specifically implement the following steps: query the disk information of each hard disk in the system; the disk information includes: whether the disk is operating normally, the remaining capacity of the disk, the total capacity of the disk and the disk base address; select multiple available hard disks based on the disk information of each hard disk.

[0165] In this embodiment, the computer program executed by the processor can specifically implement the following steps: query the disk physical address corresponding to the next writable logical block indicated by the log management structure information in each available hard disk through the memory management unit; write the log data in the cache area to the corresponding disk physical address.

[0166] In this embodiment, the computer program executed by the processor can specifically implement the following steps: if the log management structure information does not exist in any available hard disk, then after the log management structure information is created in the currently available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in the currently available hard disk according to the log management structure information in the currently available hard disk, and the log management structure information in the currently available hard disk is updated to record whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

[0167] In this embodiment, the computer program executed by the processor can specifically implement the following steps: if the log management structure information in any available hard disk indicates that the current disk is full, then erase the logical block that has stored data for the longest time in the currently available hard disk; use the erased logical block as the next writable logical block indicated by the log management structure information in the currently available hard disk, and update the current disk full flag and the amount of data stored in each logical block in the current disk recorded in the log management structure information in the currently available hard disk; according to the log management structure information in the currently available hard disk, write the log data in the cache area to the next writable logical block indicated by the log management structure information in the currently available hard disk, and update the current disk full flag, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk recorded in the log management structure information in the currently available hard disk.

[0168] In this embodiment, the computer program executed by the processor can specifically implement the following steps: query the log management structure information in each hard disk through a preset log query interface; compare the log management structure information in each hard disk to determine the hard disk with the largest amount of stored data; read the log data in the hard disk with the largest amount of stored data to perform log analysis.

[0169] In this embodiment, the computer program executed by the processor can specifically implement the following steps: compare the identification address of the next writable logical block recorded in the log management structure information in each hard disk to determine the next writable logical block with the largest identification address; and use the hard disk where the next writable logical block with the largest identification address is located as the hard disk with the largest amount of stored data.

[0170] In this embodiment, the computer program executed by the processor can specifically implement the following steps: query the log data in each hard disk through a preset log query interface; after reading the log data in each hard disk, merge and deduplicate all the read log data to obtain a merged and deduplicated result; and perform log analysis on the merged and deduplicated result.

[0171] A computer program product provided by an embodiment of the present invention is introduced below. The computer program product described below can be referenced to other embodiments described in this document.

[0172] A computer program product includes a computer program / instruction, which implements the steps of the aforementioned disclosed log processing method when executed by a processor.

[0173] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0174] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of non-volatile storage medium known in the art.

[0175] Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A log processing method, characterized in that: include: Collect log data generated in real time; Temporarily storing the log data in a pre-applied buffer area; Determine multiple available hard disks when the log flushing conditions are met; Detect whether there is log management structure information in each available hard disk; wherein the log management structure information in each available hard disk includes: whether the current disk is full of flags, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk; If log management structure information exists in each available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in each available hard disk according to the log management structure information in each available hard disk, and the log management structure information in each available hard disk is updated to record whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

2. The method according to claim 1, characterized in that The log storage conditions are: the cache is full, or the log storage time is reached, or the system is abnormally powered off; Accordingly, when the log storage condition is met, multiple available hard disks are determined, including: When the cache area is full, multiple available hard disks are determined; or when a timed time point for log write to disk is reached, multiple available hard disks are determined; or when the system loses power abnormally, multiple available hard disks are determined.

3. The method according to claim 1, characterized in that Identify multiple available hard drives, including: Query the disk information of each hard disk in the system; the disk information includes: whether the disk is running normally, the remaining capacity of the disk, the total capacity of the disk and the base address of the disk; Select multiple available hard disks based on the disk information of each hard disk.

4. The method according to claim 1, characterized in that: Each hard disk is divided into a plurality of logic blocks of equal size, and the space size of a single logic block is not less than the space size of the cache area.

5. The method according to claim 1, characterized in that Writing the log data in the buffer area into the next writable logical block indicated by the log management structure information in each available hard disk includes: Querying the disk physical address corresponding to the next writable logical block indicated by the log management structure information in each available hard disk through the memory management unit; The log data in the buffer area is written into the corresponding disk physical address.

6. The method according to claim 1, characterized in that Also includes: If the log management structure information does not exist in any available hard disk, after the log management structure information is created in the currently available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in the currently available hard disk according to the log management structure information in the currently available hard disk, and the log management structure information in the currently available hard disk is updated to record whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

7. The method according to claim 1, characterized in that Also includes: If the log management structure information in any available hard disk indicates that the current disk is full, then the logical block with the longest data storage time in the current available hard disk is erased; The erased logical block is used as the next writable logical block indicated by the log management structure information in the currently available hard disk, and the log management structure information in the currently available hard disk records whether the current disk is full and the amount of data stored in each logical block in the current disk. According to the log management structure information in the currently available hard disk, the log data in the cache area is written to the next writable logical block indicated by the log management structure information in the currently available hard disk, and the log management structure information in the currently available hard disk records whether the current disk is full, the next writable logical block in the current disk, and the amount of data stored in each logical block in the current disk.

8. The method according to any one of claims 1 to 7, characterized in that: Also includes: Query the log management structure information in each hard disk through the preset log query interface; Compare the log management structure information in each hard disk to determine the hard disk with the largest amount of stored data; Read the log data from the hard disk with the largest storage data volume for log analysis.

9. The method according to claim 8, characterized in that Compare the log management structure information in each hard disk to determine the hard disk with the largest amount of stored data, including: Compare the identification addresses of the next writable logical blocks recorded in the log management structure information in each hard disk to determine the next writable logical block with the largest identification address; The hard disk where the next writable logical block with the largest identification address is located is used as the hard disk with the largest storage data volume.

10. The method according to any one of claims 1 to 7, characterized in that: Also includes: Query the log data in each hard disk through the preset log query interface; After reading the log data in each hard disk, perform a merge operation and a deduplication operation on all the read log data to obtain a merged and deduplicated result; Perform log analysis on the merged deduplication result.

11. The method according to any one of claims 1 to 7, characterized in that: Collects log data generated in real time, including: Filter the raw log data generated in real time; Collect filtered log data.

12. The method according to any one of claims 1 to 7, characterized in that: Before temporarily storing the log data in a pre-applied buffer area, the method further includes: The log data is converted into a unified target data format, and a log timestamp and event type are added.

13. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 12 is implemented.

14. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the method according to any one of claims 1 to 12.

15. A non-volatile storage medium, characterized in that: Used to store a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.

Citation Information

Patent Citations

  • Log recording method and log recording system

    CN103176888A

  • Multithreading based log management method and system

    CN105183621A

  • Efficient storage of small random changes to data on disk

    CN105339885A

  • Data processing method and system based on solid state disk array and cache

    CN107402890A

  • Log management method and system for SAN storage system and related module

    CN111159119A