Log storage method, device and equipment and nonvolatile storage medium

By mounting the storage partition of the mirrored memory to the log file system when the out-of-band management controller is powered on, and determining the storage location according to the log type, the problem of tight log storage space is solved, and the log storage performance is improved and log analysis is comprehensive.

CN119739350AActive Publication Date: 2025-04-01INSPUR SUZHOU INTELLIGENT TECH CO LTD

Patent Information

Application Number
CN202412000504.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-01
Estimated Expiration
2044-12-31

AI Technical Summary

Technical Problem

Out-of-band management controllers generate a large number of logs during operation, resulting in tight storage space, and the existing technology is difficult to effectively solve the log storage performance problem.

Method used

When the out-of-band management controller is powered on, the first memory partition in the first mirror memory and the second memory partition in the second mirror memory are mounted to the log file system, the target storage location is determined according to the type of log information, and log rotation and file renaming are implemented in the storage space to expand the storage space.

Benefits of technology

By dynamically expanding the log storage space, improving the log storage performance of out-of-band management controllers can store more logs, which helps comprehensive log analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119739350A_ABST
    Figure CN119739350A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of servers, and particularly discloses a log storage method, device and equipment and a nonvolatile storage medium. When an out-of-band management controller is powered on, a first storage partition in a first mirror image memory and a second storage partition in a second mirror image memory are mounted to a log file system; and the free storage space in the standby mirror image memory of the out-of-band management controller is fully utilized as the expansion of the log storage space in the original main mirror image memory, so that the dynamic expansion of the log storage space of the out-of-band management controller is realized. Therefore, after the log information is generated, the target storage position of the log information in the log storage space is determined according to the log type corresponding to the log information, and the log information is written into the target storage position, so that more logs can be stored through a larger log storage space, comprehensive log analysis based on the out-of-band management controller is facilitated, and the user experience is improved. And the log storage performance of the out-of-band management controller is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of server technology, and in particular to a log storage method, device, equipment and non-volatile storage medium. Background Art

[0002] An out-of-band management controller is a hardware and software management device that can be independent of the server's main operating system and network when the server and other equipment are running. It is an important device for monitoring the server's operating status, and a baseboard management controller (BMC) is often used. During operation, the out-of-band management controller will generate a large number of logs to record the events it monitors. These logs can help operation and maintenance personnel analyze equipment problems. The longer the time span of the log and the richer the information, the more helpful it is for analyzing problems.

[0003] However, a large number of logs will take up a lot of storage space, and they need to be stored in a storage space that will not be lost after power failure, which leads to an increasingly tight space for the out-of-band management controller to store logs. There are currently two main solutions: one is to use the remote log forwarding function, where the out-of-band management controller forwards the log to another server for storage when it generates the log; the other is to optimize the log information in the code to reduce invalid logs, duplicate logs, etc. However, the former solution is not conducive to collecting and viewing logs through the local out-of-band management controller, and the latter solution may cause the loss of key information for analyzing problems during the log screening process.

[0004] How to improve the log storage performance of the out-of-band management controller so as to perform comprehensive log analysis based on the out-of-band management controller is a technical problem that those skilled in the art need to solve. Summary of the invention

[0005] The object of the present invention is to provide a log storage method, apparatus, device and non-volatile storage medium for improving the log storage performance of an out-of-band management controller so as to perform comprehensive log analysis based on the out-of-band management controller.

[0006] In order to solve the above technical problems, the present invention provides a log storage method, which is applied to an out-of-band management controller, comprising: When powered on, a first storage partition in a first mirror memory of the out-of-band management controller and a second storage partition in a second mirror memory of the out-of-band management controller are mounted to a log file system to serve as a log storage space of the out-of-band management controller; After the log information is generated, determining a target storage location of the log information in the log storage space according to a log type corresponding to the log information; The log information is written into the target storage location.

[0007] On the one hand, determining a target storage location of the log information in the log storage space according to the log type corresponding to the log information includes: If the target log file corresponding to the log type in the log file system is not full, directly using the storage location of the target log file as the target storage location; If the target log file is full, the target log file is renamed, a new target log file is created, and the storage location of the new target log file is used as the target storage location.

[0008] On the other hand, the log rotation quantity corresponding to the log type is a value obtained by dividing the sum of the size of the first storage partition and the size of the second storage partition by the greatest common divisor of the size of the first storage partition and the size of the second storage partition minus 1; The size of the log file that triggers the log rotation operation corresponding to the log type is the value of the storage space size allocated to the log type divided by the log rotation number plus 1.

[0009] On the other hand, the target log file is stored in the first storage partition; Log storage methods also include: If the number of log files corresponding to the log type in the first storage partition reaches a first preset number, the log file corresponding to the log type in the first storage partition with the earliest generation time is moved to the second storage partition.

[0010] On the other hand, moving the log file with the earliest generation time in the first storage partition to the second storage partition includes: The number of the log files corresponding to the log type that need to be moved from the first storage partition to the second storage partition is determined according to the size of the first storage partition and the size of the second storage partition.

[0011] On the other hand, moving the log file with the earliest generation time in the first storage partition to the second storage partition includes: If the log file corresponding to the log type exists in the second storage partition, after renaming the log file corresponding to the log type in the second storage partition, move the log file with the earliest generation time corresponding to the log type in the first storage partition to the second storage partition; If the number of the log files stored in the second storage partition reaches the maximum number of the log files corresponding to the log type in the second storage partition, the log file with the earliest generation time corresponding to the log type in the second storage partition is deleted.

[0012] On the other hand, mounting a first storage partition in a first mirror memory of the out-of-band management controller and a second storage partition in a second mirror memory of the out-of-band management controller to a log file system as a log storage space of the out-of-band management controller includes: Using the log storage partition in the first mirror storage as the first storage partition, and determining the second storage partition in the read-write partition in the second mirror storage; Starting the first image in the first image storage device, and mounting the first storage partition and the second storage partition to the log file system; After the log information is generated, determining a target storage location of the log information in the log storage space according to a log type corresponding to the log information includes: If the target log file corresponding to the log type in the log file system is not full, directly using the storage location of the target log file as the target storage location; If the target log file is full, rename the target log file, create a new target log file, and use the storage location of the new target log file as the target storage location; Also includes: Running a monitoring program to obtain a first signal sent by the operating system kernel when monitoring that a new log file is created under the log file system; If the first signal is obtained, checking the number of the log files corresponding to the log type of the newly created log file in the first storage partition; If the number of the log files reaches a first preset number, the log file with the earliest generation time corresponding to the log type in the first storage partition is moved to the second storage partition.

[0013] In order to solve the above technical problems, the present invention further provides a log storage device, which is applied to an out-of-band management controller, comprising: A configuration unit, configured to mount, upon power-on, a first storage partition in a first mirror memory of the out-of-band management controller and a second storage partition in a second mirror memory of the out-of-band management controller to a log file system to serve as a log storage space of the out-of-band management controller; a determination unit, configured to determine, after generating log information, a target storage location of the log information in the log storage space according to a log type corresponding to the log information; A write control unit is used to write the log information into the target storage location.

[0014] In order to solve the above technical problems, the present invention further provides a log storage device, comprising: Memory for storing computer programs; The processor is used to execute the computer program, and the computer program, when executed by the processor, implements the steps of any one of the log storage methods described above.

[0015] In order to solve the above technical problems, the present invention further provides a non-volatile storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the log storage method as described in any one of the above items are implemented.

[0016] The log storage method provided by the present invention has the beneficial effect that when the out-of-band management controller is powered on, the first storage partition in the first mirror memory of the out-of-band management controller and the second storage partition in the second mirror memory of the out-of-band management controller are mounted to the log file system as the log storage space of the out-of-band management controller, thereby making full use of the free storage space in the backup mirror memory of the out-of-band management controller as an extension of the log storage space in the original main mirror memory, and realizing the dynamic expansion of the log storage space of the out-of-band management controller. Therefore, after the log information is generated, the target storage location of the log information in the log storage space is determined according to the log type corresponding to the log information, and the log information is written to the target storage location, so that more logs can be stored through a larger log storage space, which is helpful for comprehensive log analysis based on the out-of-band management controller and improves the log storage performance of the out-of-band management controller.

[0017] The log storage device, equipment and non-volatile storage medium provided by the present invention have the above-mentioned beneficial effects, which will not be described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions of 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 some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 A flow chart of a log storage method provided by an embodiment of the present invention; Figure 2A schematic diagram of the structure of a log storage system provided by an embodiment of the present invention; Figure 3 A schematic diagram of the structure of a log storage device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0020] The core of the present invention is to provide a log storage method, device, equipment and non-volatile storage medium, which are used to improve the log storage performance of an out-of-band management controller so as to perform comprehensive log analysis based on the out-of-band management controller.

[0021] 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 embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0022] To facilitate understanding of the technical solution provided by the embodiment of the present invention, some key terms used in the embodiment of the present invention are first explained here.

[0023] In devices such as servers, out-of-band management controllers are used to implement out-of-band management monitoring functions, usually using baseboard management controllers (BMCs). The baseboard management controller is usually installed on the motherboard or the mainboard of the monitored device, and uses but is not limited to the Intelligent Platform Management Interface (IPMI) protocol to monitor the status of the hardware in the server by monitoring the sensors in the server system. The baseboard management controller can use an integrated circuit bus (such as an Inter-Integrated Circuit (I2C)) or an Intelligent Platform Management BUS (IPMB) to communicate with modules inside the server, such as the south bridge (Platform Controller Hub, PCH), memory (such as dual-inline-memory-modules (DIMMs)), power supply, etc. The baseboard management controller can also connect to sensors in the server through the integrated circuit bus or the intelligent platform management bus, and monitor the status of the hardware in the server through sensors, such as temperature, humidity, power supply voltage, fan speed, communication parameters, and operating system (OS) functions. If any of these variables exceeds the specified limit, the baseboard management controller will notify the system administrator. The baseboard management controller can provide network (web) services, which have network communication functions and provide web pages to display the monitoring interface. Operation and maintenance personnel can obtain the monitoring data of the baseboard management controller by connecting the baseboard management controller of the monitored device through a network cable at the equipment site, or by connecting the baseboard management controllers of multiple monitored devices through the network in the data center.

[0024] Therefore, the out-of-band management controller generates a large number of logs during operation, including audit logs that record user operations, system event logs that record system alarms, and debug logs, operation logs, and error logs output during code execution. These logs can help developers analyze problems. The longer the time span of the log and the richer the information, the more helpful it is for analyzing problems. However, a large number of logs will take up more space, and the logs need to be stored in the non-volatile memory of the server without being lost when the power is off. The space available for log storage is very limited, so it is necessary to make full use of the limited space to store as many logs as possible.

[0025] When the log storage space of the out-of-band management controller is insufficient, there are currently two main solutions. One is to use the log remote forwarding function. When the out-of-band management controller generates logs, it forwards the logs to another server for storage. However, this solution is usually applicable to large-scale server clusters, not a general solution for a single server, and the forwarded logs cannot be collected and viewed by the out-of-band management controller, and this function depends on the network. Another solution is to optimize the log information in the code of the out-of-band management controller to reduce invalid logs, duplicate logs, etc. However, this solution requires continuous optimization and development of the out-of-band management controller code, and for some debug-level logs, it is often only when analyzing the problem that it is found whether they are useful, and it is impossible to accurately identify them; in addition, there is a conflict between optimizing and reducing logs and hoping for more logs to achieve a comprehensive analysis of problems generated during server operation. Even the most sophisticated optimization strategy may result in the loss of key information for analyzing the problem.

[0026] At present, out-of-band management controllers usually use dual images for backup. The image of the out-of-band management controller is a set of firmware stored on the server hardware, which is used to start and manage the out-of-band management controller. The image of the out-of-band management controller is usually stored in a non-volatile memory (such as Flash or EEPROM) in the server, and the dual images of the out-of-band management controller are stored in two non-volatile memories respectively. Among them, the partition of the main image is usually consistent with the image of the out-of-band management controller, and the backup image is kept as a backup and does not need to be run for a long time. Therefore, it is usually only necessary to ensure that the basic functions of the backup image, such as users, networks, and upgrades, are normal, and that the main image can be started and upgraded from the backup image in an emergency, so as to meet the needs.

[0027] Therefore, the log storage solution provided by the embodiment of the present invention optimizes the partition of the backup image of the out-of-band management controller, uses the storage partition of the backup image to expand the log storage space of the primary image, and realizes the expansion of the log storage space of the out-of-band management controller.

[0028] The log storage method provided by the embodiment of the present invention is described below with reference to the accompanying drawings.

[0029] Figure 1 A flow chart of a log storage method provided by an embodiment of the present invention; Figure 2 A schematic diagram of the structure of a log storage system provided by an embodiment of the present invention.

[0030] like Figure 1 As shown, applied to an out-of-band management controller, the log storage method provided by an embodiment of the present invention may include: S101: When power is turned on, a first storage partition in a first mirror storage of the out-of-band management controller and a second storage partition in a second mirror storage of the out-of-band management controller are mounted to a log file system to serve as a log storage space of the out-of-band management controller; S102: after the log information is generated, determining a target storage location of the log information in the log storage space according to the log type corresponding to the log information; S103: Write the log information into the target storage location.

[0031] In a specific implementation, the out-of-band management controller in the embodiment of the present invention may refer to a baseboard management controller. One of the first image memory and the second image memory may be a primary image memory of the out-of-band management controller, and the other may be a backup image memory of the out-of-band management controller. The image that is consistent with the image of the out-of-band management controller is the primary image, and the backup image that only maintains basic functions is the backup image.

[0032] For ease of description, the embodiment of the present invention is described with the first mirror memory being the primary mirror memory and the second mirror memory being the backup mirror memory.

[0033] The partitions of the main image of the out-of-band management controller mainly include the main image boot loader (u-boot), the environment variables associated with the main image startup (u-boot-env), the main image operating system kernel program (kernel), the main image read-only partition (ro), and the main image read-write partition (rw). The partitions of the backup image of the out-of-band management controller mainly include the backup image boot loader (alt-u-boot), the environment variables associated with the backup image startup (alt-u-boot-env), the backup image operating system kernel program (alt-kernel), the backup image read-only partition (alt-ro), and the backup image read-write partition (alt-rw). In an embodiment of the present invention, the original log storage partition in the first mirror memory can be used as the first storage partition, and the second storage partition can be determined in the read-write partition in the second mirror memory.

[0034] Since the backup mirror read-write partition needs to store files for emergency backup, the entire read-write partition in the second mirror storage device cannot be used as the second storage partition. In an embodiment of the present invention, the method for determining the second storage partition may include: determining the amount of data stored in the read-write partition of the second mirror storage device during operation of the out-of-band management controller through testing, and determining the second storage partition in the remaining storage space in the read-write partition.

[0035] In an embodiment of the present invention, for S101, when the out-of-band management controller is powered on, the first storage partition and the second storage partition are mounted to the journal file system. If the first storage partition uses the journal storage partition in the main mirror memory, there is no need to modify the storage partition, and the second storage partition can be mounted to the main mirror. The second storage partition can be mounted as a jffs2 file system to facilitate writing files. The command is: mount–t jffs2 / dev / mtd / alt-bu / run / media / alt-bu. jffs2 (Journalling Flash File System Version 2) is a journaling file system designed specifically for embedded systems. It stores data and metadata nodes in a sequential manner on flash memory.

[0036] For S102, the out-of-band management controller needs to store multiple types of logs. To ensure the storage of each log type, a corresponding storage space can be allocated in advance for each log type, that is, the log file of the log type is allowed to be written beyond the storage space size.

[0037] like Figure 2 As shown, in the out-of-band management controller, the log generation module is used to call the interface to generate logs, and the log recording module is used to capture the logs and record them in files.

[0038] After the log generation module generates log information, the log recording module records the log information into a log file in the log file system.

[0039] In some optional implementations of the embodiments of the present invention, determining the target storage location of the log information in the log storage space according to the log type corresponding to the log information in S102 may include: if the first storage location corresponding to the log type in the first storage partition is not full, then determining the target storage location in the first storage location; if the first storage location is full, then determining the target storage location in the second storage location corresponding to the log type in the second storage partition. On this basis, if the second storage location corresponding to the log type in the second storage partition is full, the log information may be overwritten and written to the log file of the first storage log. Alternatively, if both the first storage location and the second storage location are full, the log writing may be stopped and the user may be prompted that the log space is full, and the historical log may be deleted or transferred.

[0040] In summary, the first storage space and the second storage space are used as log storage spaces, and after the target storage position of the log information in the log storage space is determined, the log recording module is used to write the log information into the log storage space.

[0041] The log storage method provided by the embodiment of the present invention may further include: upon receiving a log reading command, determining the log type of the log to be read, and reading all log files corresponding to the log type from the first storage partition and the second storage partition in response to the log reading command.

[0042] The log storage method provided by the embodiment of the present invention mounts the first storage partition in the first mirror memory of the out-band management controller and the second storage partition in the second mirror memory of the out-band management controller to the log file system when the out-band management controller is powered on, so as to serve as the log storage space of the out-band management controller, thereby making full use of the free storage space in the backup mirror memory of the out-band management controller as an extension of the log storage space in the original main mirror memory, and realizing the dynamic expansion of the log storage space of the out-band management controller. Therefore, after the log information is generated, the target storage location of the log information in the log storage space is determined according to the log type corresponding to the log information, and the log information is written to the target storage location, so that more logs can be stored through a larger log storage space, which is helpful for comprehensive log analysis based on the out-band management controller and improves the log storage performance of the out-band management controller.

[0043] Based on the above embodiment, the embodiment of the present invention further illustrates a method for writing log information into a log storage space.

[0044] In the log storage space of the out-of-band management controller, you can configure the log rotation function. This is a mechanism for managing the size and retention policy of log files. Through log rotation, the system can automatically manage log files and prevent them from growing indefinitely, thereby saving disk space and improving the efficiency of log management. Figure 2 The log rotation module shown can control the size of the log file according to the configuration through the log rotation tool. When the log file reaches a certain size, the log rotation tool will rename the current log file (for example, add a suffix such as .1) and create a new log file to continue recording new log information. The log rotation tool can be configured to retain a certain number of log file backups. For example, the configuration can specify that 3 backup files be retained. When this number is reached, the oldest backup will be automatically deleted to ensure that only the latest log file is retained. It should be noted that the above-mentioned "backup" refers to the backup of the old log information in the log file when the new log information is written to the log file corresponding to the interface of the current log file system, and does not mean saving multiple copies of the same log file.

[0045] Then in the embodiment of the present invention, the target storage location of the log information in the log storage space is determined according to the log type corresponding to the log information in S102, and it can also include: if the target log file corresponding to the log type in the log file system is not full, then the storage location of the target log file is directly used as the target storage location; if the target log file is full, then after renaming the target log file, a new target log file is created, and the storage location of the new target log file is used as the target storage location. That is to say, for the convenience of management, when viewing the log files corresponding to a certain log type from the upper log file system, they are all named the same, for example, the audit log file is displayed as audit.log.0 in the log file system, and when the log rotation function is implemented in the bottom storage, when the log file is full, the original audit.log.0 can be renamed as audit.log.1 and a new audit.log.0 can be created to write new log information, or the original audit.log.0 can be copied and named audit.log.1, and the new log information can be overwritten and written into audit.log.0.

[0046] An example of log rotation configuration is as follows: / var / log / audit / audit.log { rotate 2 size 1M nocompress nodateext missingok copytruncate postrotate systemctl reload rsyslog 2> / dev / null || true endscrip }.

[0047] Among them, "audit.log" indicates the audit log; "rotate 2" indicates that the number of log rotations is 2, which means that this log type can store up to 3 log files in the log storage space; "size "1M" means that the size of the log file that triggers the log rotation operation is 1MB, that is, if the current log file is filled with 1MB of log information, the above log rotation operation will be performed; "nocompress" means no compression processing; "nodateext" means prohibiting the addition of a date extension to the log file name after rotation; "missingok" means that if the specified log file does not exist, no error message will be generated and other instructions in the configuration file will continue to be executed; "copytruncate" is a parameter for processing the log file being used, specifically, copying the current log file and renaming it, then clearing the original log file, and keeping the file descriptor unchanged for the log file that has been opened and written; "postrotate" is a command for specifying the command or script to be executed after the log rotation operation is completed; "systemctl" is a system control tool for managing system services, "reload" is a systemctl command used to reload the service configuration file without stopping and restarting the service, "rsyslog" is a log service used to receive, process and forward log messages, "systemctl reloadrsyslog 2" is a command used to reload the rsyslog service. This command is usually placed in the postrotate part, which means it is executed after the log rotation operation is completed. The number 2 here is the exit status code of the command, which is used to indicate whether the log rotation operation command is executed successfully; " / dev / null || true" means to try to redirect some data to / dev / null. If this operation fails (although it is almost impossible to fail in reality), then execute the true command; "endscrip" means to end the instruction.

[0048] In the configuration information of the log rotation function in the above example, when the size of the audit log file audit.log exceeds 1MB, a file named audit.log.1 will be automatically copied, the content of the original log file audit.log will be cleared, and new log information will continue to be recorded. The number of log rotations (rotate) is configured as 2, which means that the number of backup files is 2, and a maximum of 3 audit log files can be stored in the log storage space, which can be named audit.log, audit.log.1, and audit.log.2 respectively.

[0049] In the embodiment of the present invention, in order to implement the log rotation function based on the log storage area composed of the first storage partition and the second storage partition, two parameters, namely the log rotation number (rotate) and the log file size (size) that triggers the log rotation operation, need to be configured. These two parameters can be determined according to the size of the first storage partition and the size of the second storage partition.

[0050] In some optional implementations of the embodiments of the present invention, the log rotation number corresponding to the log type can be the sum of the size of the first storage partition and the size of the second storage partition divided by the greatest common divisor of the size of the first storage partition and the size of the second storage partition minus 1. Then the log rotation number can be calculated by the following formula: ; in, Indicates the number of log rotations. Indicates the size of the first storage partition, Indicates the size of the second storage partition, Indicates the greatest common divisor of the sizes of the first storage partition and the second storage partition.

[0051] The size of the log file that triggers the log rotation operation corresponding to the log type can be the value of the storage space allocated to the log type divided by the number of log rotations plus 1. Then the size of the log file that triggers the log rotation operation corresponding to the audit log can be calculated by the following formula: ; in, Indicates the size of the log file that triggers the log rotation operation corresponding to the audit log. Indicates the storage space allocated to the audit log. Indicates the number of log rotations. For other log types, the log file size that triggers log rotation can also be calculated according to the above formula.

[0052] Depending on the number of log rotations, the log files corresponding to the log type can be named audit.log, audit.log.1, audit.log.2, audit.log.3, etc., that is, audit.log. (rotate).

[0053] In some other optional implementations of the embodiment of the present invention, different log rotation numbers may also be set for different log types.

[0054] In the above embodiment of the present invention, the first storage partition can be a log storage partition in the primary mirror storage device, and the second storage partition can be a storage partition determined from the read-write space of the backup mirror storage device. In this case, the log files read and written by the log file system are preferentially stored in the first storage partition.

[0055] In some optional implementations of the embodiments of the present invention, the target log file is stored in the first storage partition; the log storage method provided by the embodiments of the present invention may also include: if the number of log files corresponding to the log type in the first storage partition reaches a first preset number, the log file with the earliest generation time corresponding to the log type in the first storage partition is moved to the second storage partition. That is to say, the log file corresponding to the log file system interface, that is, the log file storing the latest log information, is stored in the primary mirror storage partition, and after the storage space corresponding to the log type in the primary mirror storage partition is filled, the log file corresponding to the earliest written log information is moved to the second storage partition in the backup mirror.

[0056] like Figure 2 As shown, the above functions can be implemented through a log directory monitoring module. The log storage method provided by an embodiment of the present invention may also include: running a monitoring program to obtain a first signal sent by the operating system kernel when it monitors that a new log file is created under the log file system; if the first signal is obtained, then checking the number of log files corresponding to the log type of the newly created log file in the first storage partition; if the number of log files reaches a first preset number, then moving the log file with the earliest generation time corresponding to the log type in the first storage partition to the second storage partition. The out-of-band management controller can use the inotify function of the Linux system to monitor file changes in the log directory of the log file system, and determine whether to move the backup log to the second storage partition whenever a backup log is generated. inotify is a file system event monitoring mechanism provided by the Linux kernel, which allows applications to monitor events in the file system, such as file creation, deletion, modification, etc. The embodiment of the present invention implements a monitoring program based on the thread of the out-of-band management controller to monitor the log directory ( / var / log / audit / ) of the log file system. When a new log file is created in the log directory, the operating system kernel will send a first signal (IN_CREATE), which will be captured by the monitoring program implemented in the embodiment of the present invention. If the maximum number of log files allowed to be stored in the first storage partition for this log type (i.e., the first preset number) is exceeded, the log file storing the earliest written log information will be moved to the second storage partition.

[0057] When the first storage partition allows the storage of multiple backup logs of this log type, it is necessary to determine how many backup logs to move to the second storage partition. In an embodiment of the present invention, moving the log file with the earliest generation time in the first storage partition to the second storage partition may include: determining the number of log files corresponding to the log type that need to be moved from the first storage partition to the second storage partition based on the size of the first storage partition and the size of the second storage partition. Specifically, the maximum number of log files in the first storage partition and the maximum number of logs in the second storage partition can be determined based on the ratio of the size of the first storage partition to the size of the second storage partition and the number of log rotations corresponding to the log type. In an embodiment of the present invention, the count value count can be configured to be calculated by the following formula: ; in, Indicates the size of the first storage partition, Indicates the size of the second storage partition, Indicates the greatest common divisor of the sizes of the first storage partition and the second storage partition.

[0058] All log files with a file suffix exceeding (rotate-count) need to be moved to the second storage partition. In fact, because each time the audit.log.(rotate-count+1) file is generated, it will be transferred immediately, so the log files with subsequent numbers will not be generated in the first storage partition.

[0059] like Figure 2 As shown, assuming that the number of log rotations corresponding to a certain log type is 3, the log file connected to the log file system in the first storage partition is log 0, and the maximum number of log files in the first storage partition is calculated to be 2, and the maximum number of logs in the second storage partition is 2. When log 0 is full, a copy of log 0 is made and named log 1, and the data of log 0 is cleared to write new log information. When log 0 is full again, log 2 is generated and moved to the second storage partition. When log 2 is generated for the second time in the first storage partition, if log 2 is directly moved to the second storage partition, it will cause the same name as log 2 in the second storage partition.

[0060] In an embodiment of the present invention, moving the log file with the earliest generation time in the first storage partition to the second storage partition may include: if there is a log file corresponding to the log type in the second storage partition, renaming the log file corresponding to the log type in the second storage partition, and then moving the log file with the earliest generation time corresponding to the log type in the first storage partition to the second storage partition; if the number of log files stored in the second storage partition reaches the maximum number of log files corresponding to the log type in the second storage partition, deleting the log file with the earliest generation time corresponding to the log type in the second storage partition.

[0061] That is, when moving a log file from the first storage partition to the second storage partition, if the second storage partition already stores a log file corresponding to the log type, the existing log file in the second storage partition is renamed to distinguish it. For example, the file name of the existing log file in the second storage partition can be increased by 1, that is, Figure 2 As shown, the old log 2 is named as log 3, and the new log 2 can be stored in the second storage partition.

[0062] When the number of log files corresponding to the log type in the second storage partition exceeds the maximum number of logs in the second storage partition, the redundant log files are deleted. At this time, the log file with the earliest generation time corresponding to the log type in the second storage partition can be deleted, such as Figure 2 For example, when the log file to be renamed to log 4 is deleted directly, log 4 will not be generated.

[0063] An embodiment of the present invention provides a log storage method under a log rotation configuration. In S101, a first storage partition in a first mirror storage of an out-of-band management controller and a second storage partition in a second mirror storage of the out-of-band management controller are mounted to a log file system to serve as a log storage space of the out-of-band management controller. The method may include: using the log storage partition in the first mirror storage as the first storage partition, and determining the second storage partition in the read-write partition in the second mirror storage; starting the first mirror in the first mirror storage, and mounting the first storage partition and the second storage partition to the log file system.

[0064] After the log information is generated in S102, the target storage location of the log information in the log storage space is determined according to the log type corresponding to the log information, which may include: if the target log file corresponding to the log type in the log file system is not full, then directly using the storage location of the target log file as the target storage location; if the target log file is full, then renaming the target log file, creating a new target log file, and using the storage location of the new target log file as the target storage location.

[0065] The log storage method provided by an embodiment of the present invention may also include: running a monitoring program to obtain a first signal sent by the operating system kernel when it monitors that a new log file is created under the log file system; if the first signal is obtained, checking the number of log files corresponding to the log type of the newly created log file in the first storage partition; if the number of log files reaches a first preset number, moving the log file with the earliest generation time corresponding to the log type in the first storage partition to the second storage partition.

[0066] The implementation of the embodiments of the present invention may refer to the description of the above embodiments.

[0067] It should be noted that in the embodiments of the log storage method of the present invention, some of the steps or features can be ignored or not executed. The hardware or software functional modules divided for the convenience of description are not the only implementation form of the log storage method provided by the embodiment of the present invention.

[0068] The above describes in detail various embodiments corresponding to the log storage method. On this basis, the present invention also discloses a log storage device, equipment, non-volatile storage medium and computer program product corresponding to the above method.

[0069] Applied to an out-of-band management controller, the log storage device provided by the embodiment of the present invention may include: A configuration unit, used for mounting, when powered on, a first storage partition in a first mirror memory of the out-of-band management controller and a second storage partition in a second mirror memory of the out-of-band management controller to a log file system to serve as a log storage space of the out-of-band management controller; A determination unit, used to determine a target storage location of the log information in the log storage space according to a log type corresponding to the log information after the log information is generated; A write control unit is used to write log information to a target storage location.

[0070] It should be noted that in each implementation of the log storage device provided by the embodiment of the present invention, the division of units is only a logical functional division, and other division methods can be used. The connection method between different units can be electrical, mechanical or other connection methods. The separated units can be located in the same physical location or distributed on multiple network nodes. Each unit can be implemented in the form of hardware or in the form of a software functional unit. That is, part or all of the units provided by the embodiment of the present invention can be selected according to actual needs and the corresponding connection method or integration method can be adopted to achieve the purpose of the embodiment of the present invention.

[0071] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.

[0072] Figure 3 A schematic diagram of the structure of a log storage device provided by an embodiment of the present invention.

[0073] like Figure 3 As shown, the log storage device provided by the embodiment of the present invention includes: a memory 310, used to store a computer program 311; a processor 320, used to execute the computer program 311, and when the computer program 311 is executed by the processor 320, the steps of the log storage method provided in any of the above embodiments are implemented.

[0074] Among them, the processor 320 may include one or more processing cores, such as a 3-core processor, an 8-core processor, etc. The processor 320 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array. The processor 320 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 central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 320 may be integrated with a graphics processing unit (GPU), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 320 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.

[0075] The memory 310 may include one or more non-volatile storage media, which may be non-transitory. The memory 310 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 310 is at least used to store the following computer program 311, wherein the computer program 311, after being loaded and executed by the processor 320, can implement the relevant steps in the log storage method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 310 may also include an operating system 312 and data 313, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 312 may be Windows or other types of operating systems. Data 313 may include, but is not limited to, the data involved in the above method.

[0076] In some embodiments, the log storage device may further include a display screen 330 , a power supply 340 , a communication interface 350 , an input / output interface 360 ​​, a sensor 370 , and a communication bus 380 .

[0077] Those skilled in the art will understand that Figure 3 The structure shown in the figure does not constitute a limitation on the log storage device, and may include more or fewer components than those shown in the figure.

[0078] The log storage device provided by the embodiment of the present invention includes a memory and a processor. When the processor executes the program stored in the memory, it can implement the steps of the log storage method provided by the above embodiment, and the effect is the same as above.

[0079] An embodiment of the present invention provides a non-volatile storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the log storage method provided in any one of the above embodiments can be implemented.

[0080] The non-volatile storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0081] For the introduction of the non-volatile storage medium provided in the embodiment of the present invention, please refer to the above method embodiment, and the effect thereof is the same as the log storage method provided in the embodiment of the present invention, and the present invention will not be elaborated here.

[0082] An embodiment of the present invention provides a computer program product, including a computer program, which implements the steps of the log storage method provided in any one of the above embodiments when executed by a processor.

[0083] For an introduction to the computer program product provided by the embodiment of the present invention, please refer to the above method embodiment, and the effect thereof is the same as the log storage method provided by the embodiment of the present invention, and the present invention will not elaborate on it here.

[0084] The above is a detailed introduction to a log storage method, device, equipment and non-volatile storage medium provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can refer to each other. For the device, equipment, non-volatile storage medium and computer program product disclosed in the embodiment, since they correspond to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can refer to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, the present invention can also be improved and modified in several ways, and these improvements and modifications also fall within the scope of protection of the present invention.

[0085] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

Claims

1. A log storage method, characterized in that: Applicable to out-of-band management controllers, including: When powered on, a first storage partition in a first mirror memory of the out-of-band management controller and a second storage partition in a second mirror memory of the out-of-band management controller are mounted to a log file system to serve as a log storage space of the out-of-band management controller; After the log information is generated, determining a target storage location of the log information in the log storage space according to a log type corresponding to the log information; The log information is written into the target storage location.

2. The log storage method according to claim 1, characterized in that: Determining a target storage location of the log information in the log storage space according to a log type corresponding to the log information includes: If the target log file corresponding to the log type in the log file system is not full, directly using the storage location of the target log file as the target storage location; If the target log file is full, the target log file is renamed, a new target log file is created, and the storage location of the new target log file is used as the target storage location.

3. The log storage method according to claim 2, characterized in that: The log rotation quantity corresponding to the log type is the sum of the size of the first storage partition and the size of the second storage partition divided by the greatest common divisor of the size of the first storage partition and the size of the second storage partition minus 1; The size of the log file that triggers the log rotation operation corresponding to the log type is the value of the storage space size allocated to the log type divided by the log rotation number plus 1.

4. The log storage method according to claim 2, characterized in that: The target log file is stored in the first storage partition; Log storage methods also include: If the number of log files corresponding to the log type in the first storage partition reaches a first preset number, the log file corresponding to the log type in the first storage partition with the earliest generation time is moved to the second storage partition.

5. The log storage method according to claim 4, characterized in that: Moving the log file with the earliest generation time in the first storage partition to the second storage partition includes: The number of the log files corresponding to the log type that need to be moved from the first storage partition to the second storage partition is determined according to the size of the first storage partition and the size of the second storage partition.

6. The log storage method according to claim 4, characterized in that: Moving the log file with the earliest generation time in the first storage partition to the second storage partition includes: If the log file corresponding to the log type exists in the second storage partition, after renaming the log file corresponding to the log type in the second storage partition, move the log file with the earliest generation time corresponding to the log type in the first storage partition to the second storage partition; If the number of the log files stored in the second storage partition reaches the maximum number of the log files corresponding to the log type in the second storage partition, the log file with the earliest generation time corresponding to the log type in the second storage partition is deleted.

7. The log storage method according to claim 1, characterized in that: Mounting a first storage partition in a first mirror memory of the out-of-band management controller and a second storage partition in a second mirror memory of the out-of-band management controller to a log file system as a log storage space of the out-of-band management controller, including: Using the log storage partition in the first mirror storage as the first storage partition, and determining the second storage partition in the read-write partition in the second mirror storage; Starting the first image in the first image storage device, and mounting the first storage partition and the second storage partition to the log file system; After the log information is generated, determining a target storage location of the log information in the log storage space according to a log type corresponding to the log information includes: If the target log file corresponding to the log type in the log file system is not full, directly using the storage location of the target log file as the target storage location; If the target log file is full, rename the target log file, create a new target log file, and use the storage location of the new target log file as the target storage location; Also includes: Running a monitoring program to obtain a first signal sent by the operating system kernel when monitoring that a new log file is created under the log file system; If the first signal is obtained, checking the number of the log files corresponding to the log type of the newly created log file in the first storage partition; If the number of the log files reaches a first preset number, the log file with the earliest generation time corresponding to the log type in the first storage partition is moved to the second storage partition.

8. A log storage device, characterized in that: Applicable to out-of-band management controllers, including: A configuration unit, configured to mount, upon power-on, a first storage partition in a first mirror memory of the out-of-band management controller and a second storage partition in a second mirror memory of the out-of-band management controller to a log file system to serve as a log storage space of the out-of-band management controller; a determination unit, configured to determine, after generating log information, a target storage location of the log information in the log storage space according to a log type corresponding to the log information; A write control unit is used to write the log information into the target storage location.

9. A log storage device, characterized in that: include: Memory for storing computer programs; A processor is used to execute the computer program, and when the computer program is executed by the processor, the steps of the log storage method according to any one of claims 1 to 7 are implemented.

10. A non-volatile storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the log storage method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Method and device for testing log coverage mechanism

    CN110569177A

  • Log data storage method and device, electronic equipment and storage medium

    CN116185773A

  • Log file rotation method and device, equipment and storage medium

    CN116756112A

  • Utilizing A Potentially Unreliable Memory Module For Memory Mirroring In A Computing System

    US20090150721A1

Cited By

  • File system design method and system suitable for power distribution terminal

    CN120803340A