A log storage method, device, equipment and nonvolatile storage medium
Patent Information
- Application Number
- CN202412000504.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2044-12-31
AI Technical Summary
但前一种方案不利于通过本地的带外管理控制器收集查看日志,后一种方案则可能导致日志筛选过程中丢失掉分析问题的关键信息
[0016]本发明提供的日志存储方法,有益效果在于带外管理控制器在上电时,将带外管理控制器的第一镜像存储器中的第一存储分区和带外管理控制器的第二镜像存储器中的第二存储分区挂载至日志文件系统,以作为带外管理控制器的日志存储空间,从而充分利用带外管理控制器的备镜像存储器中空闲的存储空间作为原本主镜像存储器中日志存储空间的扩展,实现对带外管理控制器日志存储空间的动态扩容。由此,在生成日志信息后,根据日志信息对应的日志类型确定日志信息在日志存储空间中的目标存储位置,将日志信息写入目标存储位置,可以通过更大的日志存储空间存储更多的日志,有助于基于带外管理控制器进行全面的日志分析,提高带外管理控制器的日志存储性能。
Smart Images

Figure CN119739350B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of server technology, and in particular to a log storage method, apparatus, device, and non-volatile storage medium. Background Technology
[0002] Out-of-band management controllers are hardware and software management devices that operate independently of the server's main operating system and network. They are crucial for monitoring the server's operational status and are commonly found as Baseboard Management Controllers (BMCs). During operation, out-of-band management controllers generate extensive logs to record monitored events. These logs help maintenance personnel analyze device problems; the longer the log time span and the richer the information, the more helpful the problem analysis.
[0003] However, a large volume of logs consumes significant storage space, and this storage needs to be secure even after power failure, leading to increasing scarcity of space available for log storage on the out-of-band management controller. Current solutions primarily involve two approaches: one is to employ remote log forwarding, where the out-of-band management controller forwards logs to another server for storage when they are generated; the other is to optimize log information in the code, reducing invalid and duplicate logs. However, the former approach is not conducive to collecting and viewing logs through a local out-of-band management controller, while the latter may result in the loss of crucial information for problem analysis during log filtering.
[0004] Improving the log storage performance of out-of-band management controllers to enable comprehensive log analysis based on them is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention
[0005] The purpose of this invention is to provide a log storage method, apparatus, device, and non-volatile storage medium to improve the log storage performance of out-of-band management controllers, so as to enable comprehensive log analysis based on out-of-band management controllers.
[0006] To address the aforementioned technical problems, this invention provides a log storage method applied to an out-of-band management controller, comprising: Upon power-up, 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 to serve as the log storage space of the out-of-band management controller. After generating log information, 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. Write the log information to the target storage location.
[0007] On the one hand, determining the target storage location of the log information in the log storage space based on 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, then the storage location of the target log file is directly used 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 number corresponding to the log type is the sum of the sizes of the first storage partition and the second storage partition divided by the greatest common divisor of the sizes of the first storage partition and the second storage partition, minus 1. The size of the log file that triggers the log rotation operation for the log type is the storage space allocated to the log type divided by the number of log rotations 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, then 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.
[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 log files corresponding to the log type that need to be moved from the first storage partition to the second storage partition is determined based on 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 second storage partition contains the log file corresponding to the log type, then after renaming the log file 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 first storage partition is moved to the second storage partition. If the number of log files stored in the second storage partition reaches the maximum number of log files of the log type in the second storage partition, then delete the log file of the log type with the earliest generation time in the second storage partition.
[0012] On the other hand, mounting 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 to the log file system to serve as the log storage space of the out-of-band management controller includes: The log storage partition in the first mirror memory is used as the first storage partition, and the second storage partition is determined in the read / write partition of the second mirror memory; Start the first image in the first image storage, and mount the first storage partition and the second storage partition to the log file system; After generating log information, 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, including: 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, the target log file is renamed and a new target log file is created. The storage location of the new target log file is used as the target storage location. Also includes: Run a monitoring program to obtain the first signal issued by the operating system kernel when it detects the creation of a new log file under the journaling file system; If the first signal is received, check the number of log files corresponding to the log type of the newly created log files in the first storage partition; If the number of 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 will be moved to the second storage partition.
[0013] To address the aforementioned technical problems, the present invention also provides a log storage device applied to an out-of-band management controller, comprising: The configuration unit is used to mount 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 to the log file system when powered on, so as to serve as the log storage space of the out-of-band management controller. The determining unit is used to determine the target storage location of the log information in the log storage space according to the log type corresponding to the log information after the log information is generated; A write control unit is used to write the log information to the target storage location.
[0014] To address the aforementioned technical problems, the present invention also provides a log storage device, comprising: Memory, used to store computer programs; A processor for executing the computer program, which, when executed by the processor, implements the steps of the log storage method as described in any of the preceding descriptions.
[0015] To address the aforementioned technical problems, the present invention also provides a non-volatile storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the steps of the log storage method described in any of the preceding claims.
[0016] The log storage method provided by this invention has the advantage that, upon power-up, the out-of-band management controller mounts the first storage partition in its first mirror memory and the second storage partition in its second mirror memory to the log file system, using them as the log storage space for the out-of-band management controller. This fully utilizes the idle storage space in the backup mirror memory of the out-of-band management controller as an extension of the original log storage space in the primary mirror memory, achieving dynamic expansion of the out-of-band management controller's log storage space. Therefore, after generating log information, 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. This allows for storing more logs in a larger log storage space, facilitating comprehensive log analysis based on the out-of-band management controller and improving its log storage performance.
[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 elaborated further here. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 A flowchart of a log storage method provided in an embodiment of the present invention; Figure 2This is a schematic diagram of the structure of a log storage system provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of a log storage device provided in an embodiment of the present invention. Detailed Implementation
[0020] The core of this invention is to provide a log storage method, apparatus, device, and non-volatile storage medium to improve the log storage performance of out-of-band management controllers, so as to enable comprehensive log analysis based on out-of-band management controllers.
[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0022] To facilitate understanding of the technical solutions provided in the embodiments of the present invention, some key terms used in the embodiments of the present invention will be explained here first.
[0023] In servers and other devices, out-of-band management controllers (BOMCs) are used to implement out-of-band management and monitoring functions. BOMCs are typically mounted on the motherboard or the motherboard of the monitored device and use, but are not limited to, the Intelligent Platform Management Interface (IPMI) protocol to monitor the hardware status of the server system by monitoring sensors. BOMCs can communicate with internal server modules, such as the Platform Controller Hub (PCH), memory (e.g., Dual-Inline Memory Modules (DIMMs)), and power supply, using integrated circuit buses (e.g., Inter-Integrated Circuit, I2C) or Intelligent Platform Management Bus (IPMB). BOMCs can also connect to sensors within the server via integrated circuit buses or IPMBs to monitor the hardware status, such as temperature, humidity, power supply voltage, fan speed, communication parameters, and operating system (OS) functions. If any of these variables exceeds the specified limits, the baseboard management controller will notify the system administrator. The baseboard management controller provides web services, featuring network communication capabilities and a webpage to display the monitoring interface. Maintenance personnel can access the baseboard management controller's monitoring data by connecting it to the monitored device's baseboard management controller at the equipment site via network cable, or by connecting multiple monitored device baseboard management controllers in the data center via network.
[0024] Therefore, out-of-band management controllers generate a large number of logs during operation, including audit logs recording user operations, system event logs recording system alarms, and debug logs, runtime logs, and error logs output during code execution. These logs help developers analyze problems; the longer the time span and the richer the information in the logs, the more helpful they are for problem analysis. However, a large number of logs consumes more space, and since logs need to be power-unrecoverable, they must be stored in non-volatile memory on the server. 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 remote log forwarding, where the out-of-band management controller forwards logs to another server for storage when they are generated. However, this solution is usually suitable for large-scale server clusters and is not a general solution for a single server. Furthermore, the forwarded logs cannot be collected and viewed by the out-of-band management controller, and this function relies on the network. The other solution is to optimize the logging information in the out-of-band management controller code to reduce invalid logs, duplicate logs, etc. However, this solution requires continuous optimization of the out-of-band management controller code, and for some debug-level logs, their usefulness is often only discovered during problem analysis, making accurate identification impossible. In addition, there is a conflict between optimizing to reduce logs and the expectation of having as many logs as possible to achieve comprehensive analysis of problems arising during server operation. Even the most refined optimization strategies may lead to the loss of key information for problem analysis.
[0026] Currently, out-of-band management controllers typically employ dual mirroring for backup. The out-of-band management controller image is a set of firmware stored on the server hardware, used for booting and managing the controller. This image is usually stored in non-volatile memory (such as Flash or EEPROM) within the server, and the dual images are stored in two separate non-volatile memory locations. The primary image's partitions are typically identical to the primary image, while the backup image is kept in reserve and does not require long-term operation. Therefore, generally, ensuring the backup image's basic functions—such as user access, network connectivity, and upgrade capabilities—are functional, and that it can boot from the backup image and upgrade the primary image in emergencies, is sufficient to meet the requirements.
[0027] Therefore, the log storage scheme provided in this embodiment of the invention optimizes the partitioning of the backup image of the out-of-band management controller, expands the log storage space of the primary image by utilizing the storage partition of the backup 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 embodiments of the present invention will be described below with reference to the accompanying drawings.
[0029] Figure 1 A flowchart of a log storage method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of a log storage system provided in an embodiment of the present invention.
[0030] like Figure 1 As shown, when applied to an out-of-band management controller, the log storage method provided in this embodiment of the invention may include: S101: Upon power-up, 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 to serve as the log storage space of the out-of-band management controller. S102: After generating log information, determine the 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 to the target storage location.
[0031] In specific implementations, the out-of-band management controller in this embodiment of the invention may refer to a baseboard management controller. One of the first image memory and the second image memory can be the primary image memory of the out-of-band management controller, and the other is a backup image memory of the out-of-band management controller. The image memory that maintains consistency with the image memory of the out-of-band management controller is the primary image memory, while the backup image memory only maintains basic functions.
[0032] For ease of explanation, the embodiments of the present invention will be described with the first mirror memory as the primary mirror memory and the second mirror memory as the backup mirror memory.
[0033] The primary image partitions of the out-of-band management controller mainly include the primary image bootloader (u-boot), the environment variables associated with primary image startup (u-boot-env), the primary image operating system kernel (kernel), the primary image read-only partition (ro), and the primary image read-write partition (rw). The backup image partitions of the out-of-band management controller mainly include the backup image bootloader (alt-u-boot), the backup image startup environment variables (alt-u-boot-env), the backup image operating system kernel (alt-kernel), the backup image read-only partition (alt-ro), and the backup image read-write partition (alt-rw). Therefore, in this embodiment of the invention, the original log storage partition in the first image storage can be used as the first storage partition, and the second storage partition can be determined from the read-write partition in the second image storage.
[0034] Since the backup mirror read / write partition needs to store files for emergency backup, the entire read / write partition in the second mirror memory cannot be used as the second storage partition. In this embodiment of the 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 memory during operation by testing, and determining the second storage partition from the remaining storage space in the read / write partition.
[0035] In this embodiment of the 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 journaling file system. If the first storage partition is a journaling storage partition in the master image storage, then there is no need to modify the storage partition, and the second storage partition can be mounted to the master image. The second storage partition can be mounted as a jffs2 file system for easy file writing; the command is: mount -t jffs2 / dev / mtd / alt-bu / run / media / alt-bu. jffs2 (Journaling Flash File System Version 2) is a journaling file system designed specifically for embedded systems, which stores data and metadata nodes on flash memory in a sequential manner.
[0036] For S102, the out-of-band management controller needs to store logs of various types. To ensure the storage of each log type, a corresponding storage space can be pre-allocated for each log type, that is, allowing the log files of this log type to be written beyond the size of this storage space.
[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 to a file.
[0038] After the log generation module generates log information, the log recording module records the log information to the log file in the log file system.
[0039] In some optional 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 step S102 may include: if the first storage location corresponding to the log type in the first storage partition is not full, then the target storage location is determined in the first storage location; if the first storage location is full, then the target storage location is determined in the second storage location corresponding to the log type in the second storage partition. Based on this, if the second storage location corresponding to the log type in the second storage partition is full, the log information can be overwritten into the log file of the first storage log. Alternatively, if both the first and second storage locations are full, writing logs can be stopped and the user can be notified that the log space is full, and historical logs can be deleted or transferred.
[0040] In summary, using the first and second storage spaces as log storage spaces, after determining the target storage location of log information within the log storage space, the log recording module is used to write the log information into the log storage space.
[0041] The log storage method provided in this embodiment of the invention may further include: upon receiving a log read 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 read command.
[0042] The log storage method provided in this invention mounts a first storage partition in the first mirror memory and a second storage partition in the second mirror memory of the out-of-band management controller to a log file system upon power-up. This serves as the log storage space for the out-of-band management controller, fully utilizing the idle storage space in the backup mirror memory as an extension of the original log storage space in the primary mirror memory, thus achieving dynamic expansion of the out-of-band management controller's log storage space. Consequently, after generating log information, the target storage location of the log information in the log storage space is determined according to the log type, and the log information is written to the target storage location. This allows for storing more logs in a larger log storage space, facilitating comprehensive log analysis based on the out-of-band management controller and improving its log storage performance.
[0043] Based on the above embodiments, the present invention further describes the method for writing log information into the log storage space.
[0044] In the out-of-band management controller's log storage space, a log rotation function can be configured. This is a mechanism for managing log file size and retention policies. Through log rotation, the system can automatically manage log files, preventing them from growing indefinitely, thereby saving disk space and improving log management efficiency. Figure 2 The log rotation module shown allows the log file size to be controlled according to the configuration. When a log file reaches a certain size, the log rotation tool renames the current log file (e.g., by adding a suffix like .1) and creates 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 retaining 3 backup files. When this number is reached, the oldest backup will be automatically deleted, ensuring that only the latest log file is retained. It should be noted that the above "backup" refers to backing up the old log information in the log file when writing new log information to the log file corresponding to the interface of the current log file system, not saving multiple identical log files.
[0045] In this embodiment of the 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 further 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 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. That is to say, for ease of management, when viewing the log files corresponding to a certain log type from the upper-level log file system, they all have the same name. For example, the audit log file is displayed as audit.log.0 in the log file system. When the log rotation function is implemented in the lower-level storage, when the log file is full, the original audit.log.0 can be renamed to 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 to audit.log.0.
[0046] The configuration information for an example log rotation feature 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] Where, "audit.log" represents the audit log; "rotate 2" indicates that the log rotation count is 2, meaning that this log type will store a maximum of 3 log files in the log storage space; "size "1M" indicates that the log file size triggering 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" indicates no compression processing. "nodateext" indicates that adding a date extension to the rotated log file name is prohibited. "missingok" indicates 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 used to process log files currently in use; specifically, it copies and renames the current log file, then clears the original log file. For log files that are already open and being written to, the file descriptor remains unchanged. "postrotate" is an instruction used to specify the command or script to be executed after the log rotation operation is completed. "systemctl" is a system control tool used to manage system services. "reload" is a systemctl command used to reload the service's configuration file without stopping and restarting the service. "rsyslog" is a logging service used to receive, process, and forward log messages; "systemctl reloadrsyslog" is used to reload the service's configuration file. "2" is a command used to reload the rsyslog service. This command is usually placed in the postrotate section, meaning it is executed after the log rotation operation is complete. The number 2 here is the exit status code of the command, used to indicate whether the log rotation operation was successful. " / dev / null || true" means to attempt to redirect some data to / dev / null. If this operation fails (although it is almost impossible for it to fail in practice), then the true command is executed. "endscrip" means to terminate the command.
[0048] In the log rotation configuration information of the example above, when the size of the audit log file audit.log exceeds 1MB, a file named audit.log.1 will be automatically copied, the contents of the original log file audit.log will be cleared, and new log information will continue to be recorded. The log rotation number (rotate) is configured to 2, indicating that the number of backup files is 2. Therefore, 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 this embodiment of the invention, to implement the log rotation function based on the log storage area consisting of a first storage partition and a second storage partition, two parameters need to be configured: the number of log rotations (rotate) and the size of the log file that triggers the log rotation operation (size). These two parameters can be determined based on the size of the first storage partition and the size of the second storage partition.
[0050] In some optional embodiments of the present invention, the log rotation count corresponding to the log type can be the sum of the sizes of the first and second storage partitions divided by the greatest common divisor of the sizes of the first and second storage partitions, minus 1. The log rotation count can then be calculated using 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. This represents the greatest common divisor of the sizes of the first and second storage partitions.
[0051] The size of the log file that triggers log rotation for a given log type can be calculated by dividing the allocated storage space for that log type by the number of log rotations plus 1. Therefore, the size of the log file that triggers log rotation for the audit log can be calculated using the following formula: ; in, This indicates the size of the log file that triggered the log rotation operation corresponding to the audit log. This indicates the amount of storage space allocated to the audit logs. This indicates the number of log rotations. For other log types, the size of the log file that triggers the log rotation operation can also be calculated using the above formula.
[0052] Depending on the number of log rotations, the log files corresponding to the log type can be named sequentially as audit.log, audit.log.1, audit.log.2, audit.log.3, and so on, i.e., audit.log. (rotate).
[0053] In some alternative embodiments of the present invention, different log rotation numbers can be set for different log types.
[0054] As described in the above embodiments of the present invention, the first storage partition can be the log storage partition in the primary mirror storage, and the second storage partition can be the storage partition determined from the read / write space of the backup mirror storage. In this case, log files read and written by the log file system are preferentially stored in the first storage partition.
[0055] In some optional embodiments of the present invention, the target log file is stored in the first storage partition; the log storage method provided by the present invention may further include: if the number of log files corresponding to the log type in the first storage partition reaches a first preset number, then 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, 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 image storage partition, and after the storage space corresponding to the log type in the primary image storage partition is full, the log file corresponding to the earliest written log information is moved to the second storage partition in the backup image.
[0056] like Figure 2 As shown, the above functions can be achieved through a log directory monitoring module. The log storage method provided in this embodiment of the invention may further include: running a monitoring program to obtain a first signal issued by the operating system kernel when it detects the creation of a new log file 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 creation 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 listen to events in the file system, such as file creation, deletion, and modification. In this embodiment of the invention, a monitoring program is implemented 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 issue a first signal (IN_CREATE), which is captured by the monitoring program implemented in this embodiment of the invention. If the 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 storage of multiple backup logs of a certain log type, it is necessary to determine how many backup logs to move to the second storage partition. In this embodiment of the 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 log rotation number corresponding to the log type. In this embodiment of the invention, the count value 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. This represents the greatest common divisor of the sizes of the first and second storage partitions.
[0058] Log files with file extensions exceeding (rotate-count) need to be moved to the second storage partition. In fact, since each time audit.log.(rotate-count+1) file is generated, it is immediately moved, so log files with subsequent numbers will not be generated in the first storage partition.
[0059] like Figure 2 As shown, assuming the log rotation count for a certain log type is 3, and the log file in the first storage partition connected to the journaling file system is Log 0, 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 also 2. When Log 0 is full, Log 0 is copied and named Log 1, and the data in 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. If Log 2 is directly moved to the second storage partition when it is generated a second time in the first storage partition, it will result in a name conflict with the Log 2 already in the second storage partition.
[0060] In this embodiment of the invention, moving the log file with the earliest generation time in the first storage partition to the second storage partition may include: if the second storage partition contains a log file corresponding to the log type, then renaming the log file corresponding to the log type in the second storage partition and 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, then deleting the log file with the earliest generation time corresponding to the log type in the second storage partition.
[0061] In other words, when moving log files from the first storage partition to the second storage partition, if the second storage partition already contains a log file corresponding to that log type, the existing log file in the second storage partition will be renamed to distinguish it. For example, the filename of an existing log file in the second storage partition can be incremented by 1. Figure 2 The old log 2 is renamed to log 3. At this point, the new log 2 can be stored in the second storage partition.
[0062] If the number of log files corresponding to this log type in the second storage partition exceeds the maximum number of log files in the second storage partition, the excess log files should be deleted. In this case, the earliest generated log file corresponding to this log type in the second storage partition can be deleted, such as... Figure 2 For example, when you want to rename the log file to log4, simply delete the log file that needs to be renamed to log4, so that log4 will not be generated.
[0063] This invention provides a log storage method under a log rotation configuration. In step S101, a first storage partition in the first mirror memory of the out-of-band management controller and a second storage partition in the second mirror memory of the out-of-band management controller are mounted to a log file system to serve as the log storage space for the out-of-band management controller. This step may include: using the log storage partition in the first mirror memory as the first storage partition, determining the second storage partition in the read / write partition of the second mirror memory; starting the first mirror in the first mirror memory, and mounting the first and second storage partitions to the log file system.
[0064] In step S102, after generating log information, 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. This may include: if the target log file corresponding to the log type in the log file system is not full, the storage location of the target log file is directly used as the target storage location; if the target log file is full, the target log file is renamed and a new target log file is created, and the storage location of the new target log file is used as the target storage location.
[0065] The log storage method provided in this embodiment of the invention may further include: running a monitoring program to obtain a first signal issued by the operating system kernel when it detects that a new log file has been 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 methods of the embodiments of the present invention can be referred to the description of the above embodiments.
[0067] It should be noted that in the embodiments of the log storage methods of the present invention, some steps or features may be ignored or not executed. The hardware or software functional modules described are for ease of explanation and are not the only implementation of the log storage methods provided in the embodiments of the present invention.
[0068] The above details various embodiments of the log storage method. Based on this, the present invention also discloses log storage devices, equipment, non-volatile storage media, and computer program products corresponding to the above methods.
[0069] Applied to out-of-band management controllers, the log storage device provided in this embodiment of the invention may include: The configuration unit is used to mount 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 to the log file system when powered on, so as to serve as the log storage space of the out-of-band management controller. The determination unit is used to determine the target storage location of the log information in the log storage space according to the log type corresponding to the log information after the log information is generated; The write control unit is used to write log information to the target storage location.
[0070] It should be noted that in the various embodiments of the log storage device provided in this invention, the division of units is only a logical functional division, and other division methods can be used. The connection between different units can be electrical, mechanical, or other connection methods. Separate units can be located in the same physical location or distributed across multiple network nodes. Each unit can be implemented in hardware or as a software functional unit. That is, some or all of the units provided in this invention can be selected according to actual needs, and corresponding connection or integration methods can be used to achieve the purpose of the solution in this invention.
[0071] Since the embodiments of the apparatus and the embodiments of the method correspond to each other, please refer to the description of the embodiments of the method for the embodiments of the apparatus, which will not be repeated here.
[0072] Figure 3 This is a schematic diagram of the structure of a log storage device provided in an embodiment of the present invention.
[0073] like Figure 3 As shown, the log storage device provided in this embodiment of the invention includes: a memory 310 for storing a computer program 311; and a processor 320 for executing the computer program 311, wherein the computer program 311, when executed by the processor 320, implements the steps of the log storage method provided in any of the above embodiments.
[0074] The processor 320 may include one or more processing cores, such as a 3-core processor or an 8-core processor. The processor 320 may be implemented using at least one hardware form selected from 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, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 320 may integrate a Graphics Processing Unit (GPU) responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 320 may also include an Artificial Intelligence (AI) processor for handling computational 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 high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 310 is used to store at least the following computer program 311, wherein, after being loaded and executed by the processor 320, the computer program 311 is able to implement the relevant steps in the log storage method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 310 may also include an operating system 312 and data 313, and the storage method may be temporary storage or permanent storage. The operating system 312 may be Windows or other types of operating systems. The data 313 may include, but is not limited to, the data involved in the above methods.
[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 does not constitute a limitation on the log storage device and may include more or fewer components than illustrated.
[0078] The log storage device provided in this embodiment of the 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 in the above embodiment, and the effect is the same as above.
[0079] This invention provides a non-volatile storage medium storing a computer program thereon, which, when executed by a processor, can implement the steps of the log storage method provided in any of the above embodiments.
[0080] The non-volatile storage medium may include: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks or optical disks, and other media that can store program code.
[0081] For an introduction to the non-volatile storage medium provided in the embodiments of the present invention, please refer to the above method embodiments. The effects it achieves are the same as those of the log storage method provided in the embodiments of the present invention, and the present invention will not repeat them here.
[0082] This invention provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the log storage method provided in any of the above embodiments.
[0083] For a description of the computer program product provided in the embodiments of the present invention, please refer to the above method embodiments, and its effect is the same as that of the log storage method provided in the embodiments of the present invention. The present invention will not repeat the details here.
[0084] The above provides a detailed description of a log storage method, apparatus, device, and non-volatile storage medium provided by the present invention. The various embodiments in the specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus, device, non-volatile storage medium, and computer program product disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and relevant parts can be referred to the method section. It should be noted that those skilled in the art can make several improvements and modifications to the present invention without departing from the principles of the invention, and these improvements and modifications also fall within the protection scope of the present invention.
[0085] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
Claims
1. A log storage method, characterized in that, Applications to out-of-band management controllers include: Upon power-up, 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 to serve as the log storage space of the out-of-band management controller. After generating log information, 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. Write the log information to the target storage location; Determining the target storage location of the log information in the log storage space based on 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, then the storage location of the target log file is directly used 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.
2. The log storage method according to claim 1, characterized in that, The log rotation count corresponding to the log type is the sum of the sizes of the first storage partition and the second storage partition, divided by the greatest common divisor of the sizes of the first storage partition and the second storage partition, minus 1. The size of the log file that triggers the log rotation operation for the log type is the storage space allocated to the log type divided by the number of log rotations plus 1.
3. The log storage method according to claim 1, 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, then 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.
4. The log storage method according to claim 3, 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 log files corresponding to the log type that need to be moved from the first storage partition to the second storage partition is determined based on the size of the first storage partition and the size of the second storage partition.
5. The log storage method according to claim 3, 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 second storage partition contains the log file corresponding to the log type, then after renaming the log file 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 first storage partition is moved to the second storage partition. If the number of log files stored in the second storage partition reaches the maximum number of log files of the log type in the second storage partition, then delete the log file of the log type with the earliest generation time in the second storage partition.
6. The log storage method according to claim 1, characterized in that, Mounting 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 to the log file system to serve as the log storage space of the out-of-band management controller includes: The log storage partition in the first mirror memory is used as the first storage partition, and the second storage partition is determined in the read / write partition of the second mirror memory; Start the first image in the first image storage, and mount the first storage partition and the second storage partition to the log file system; After generating log information, 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, including: 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 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: Run a monitoring program to obtain the first signal issued by the operating system kernel when it detects the creation of a new log file under the journaling file system; If the first signal is received, check the number of log files corresponding to the log type of the newly created log files in the first storage partition; If the number of 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 will be moved to the second storage partition.
7. A log storage device, characterized in that, Applications to out-of-band management controllers include: The configuration unit is configured to, upon power-up, mount 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 to the log file system, so as to serve as the log storage space of the out-of-band management controller; The determining unit is used to determine the target storage location of the log information in the log storage space according to the log type corresponding to the log information after the log information is generated; A write control unit is used to write the log information to the target storage location; Determining the target storage location of the log information in the log storage space based on 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, then the storage location of the target log file is directly used 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.
8. A log storage device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program, which, when executed by the processor, implements the steps of the log storage method as described in any one of claims 1 to 6.
9. A non-volatile storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the log storage method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method and device for testing log coverage mechanism
CN110569177A
Utilizing A Potentially Unreliable Memory Module For Memory Mirroring In A Computing System
US20090150721A1