CN113672419A - 一种适用于国产操作系统的日志记录的保护方法 - Google Patents

一种适用于国产操作系统的日志记录的保护方法 Download PDF

Info

Publication number
CN113672419A
CN113672419A CN202110909492.6A CN202110909492A CN113672419A CN 113672419 A CN113672419 A CN 113672419A CN 202110909492 A CN202110909492 A CN 202110909492A CN 113672419 A CN113672419 A CN 113672419A
Authority
CN
China
Prior art keywords
log
message
operating system
inode number
log message
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110909492.6A
Other languages
English (en)
Other versions
CN113672419B (zh
Inventor
赵冬
曹健
毛晨涛
李�浩
王子健
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Standard Software Co Ltd
Original Assignee
China Standard Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Standard Software Co Ltd filed Critical China Standard Software Co Ltd
Priority to CN202110909492.6A priority Critical patent/CN113672419B/zh
Publication of CN113672419A publication Critical patent/CN113672419A/zh
Application granted granted Critical
Publication of CN113672419B publication Critical patent/CN113672419B/zh
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0766Error or fault reporting or storing
    • G06F11/0787Storage of error reports, e.g. persistent data storage, storage using memory protection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0706Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment
    • G06F11/0718Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation the processing taking place on a specific hardware platform or in a specific software environment in an object-oriented system

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明提供的一种适用于国产操作系统的日志记录的保护方法,包括以下步骤:S01、添加日志消息标识:在rsyslog中,通过结构体instanceData区分日志文件的不同类型,在日志文件输出日志消息时标记该日志消息对应的Inode号;S02、在rsyslog中,检索日志消息的Inode号,以及判断该日志消息与日志文件类型的对应关系。本发明优化了国产操作系统平台下rsyslog日志服务系统,保证rsyslog每次保存日志消息时都能正确的保存到对应的日志文件中,留存系统的日志记录。

Description

一种适用于国产操作系统的日志记录的保护方法
技术领域
本发明关于一种计算机国产操作系统使用的日志管理方法,具体来说是一种对中标麒麟操作系统、银河麒麟操作系统以及深度操作系统等多种国产操作系统上日志记录的保护方法。
背景技术
在GNU/Linux(以下简称Linux)主流的操作系统中,日志记录是通过rsyslog日志服务,目前,各国产操作系统平台皆沿用Linux操作系统使用rsyslog作为日志服务。各国产操作系统平台采用rsyslog日志服务,是在于syslog的多线程增强版,能够提供高性能、极好的安全功能和模块化设计。
然而,将系统日志存储在/var/log/目录下的日志文件中,当删除日志文件或者使用文本编辑工具打开并重新保存日志文件后,操作系统在之后的运行过程中产生的日志消息将无法再保存到日志文件中,以至于日志消息丢失,无法形成日志记录。
发明内容
为解决上述问题,本发明提供一种适用于国产操作系统的日志记录的保护方法,在操作系统正常运行的过程中,当删除/var/log/目录下的日志文件或者使用文本编辑工具打开并重新保存日志文件后,当操作系统在后续运行的过程中有日志消息产生时,日志消息能正常保存到日志文件中,留存日志记录。
为达到上述目的,本发明所采取的技术方案为:
一种适用于国产操作系统的日志记录的保护方法,包括以下步骤:
S01、添加日志消息标识:在rsyslog中,通过结构体instanceData区分日志文件的不同类型,在日志文件输出日志消息时取得该日志消息对应的Inode号;
S02、在rsyslog中,检索日志消息的Inode号,以及判断该日志消息与日志文件类型的对应关系。
其中,步骤S01中,所述结构体instanceData的组成包括pStrm和fnode。
其中,rsyslog通过pStrm将日志输出并对日志消息添加标识。并且,pStrm的类型为strm_t。
进一步改进在于:fnode用于获取并保存日志消息的Inode号,在pStrm创建时获取Inode号保存到fnode中。
其中,步骤S02中,在判断日志消息的Inode号与日志文件类型对应关系前,还需要检索日志文件是否存在,检索到日志文件且该日志文件类型与日志消息的Inode号相对应时,将日志消息存入该日志文件形成日志记录。
其进一步改进在于:检索发现日志文件不存在或者日志消息的Inode号没有与其对应的日志文件类型时,销毁与该日志消息对应的pStrm,重复步骤S01,将步骤S01得到的Inode号保存至fnode中并建立新的日志文件类型,更新日志记录。
本发明的有益效果包括:
本发明优化了国产操作系统平台下rsyslog日志服务系统,保证rsyslog每次保存日志消息时都能正确的保存到对应的日志文件中,在用户误删除日志文件或者使用文本编辑工具打开并重新保存日志文件后,当操作系统在后续运行的过程中有日志消息产生时,日志消息能正常保存到日志文件中,留存系统的日志记录。
附图说明
图1是本发明的流程示意图。
具体实施方式
下面结合附图和具体实施方式对本发明进行详细说明。
本发明中涉及的各名词所表示的含义如下:
instanceData:在rsyslog中定义的一个结构体,用于区分不同的日志文件,一个instanceData实例对象对应一个日志文件。
fname:instanceData成员,标记日志消息名称。
pStrm:instanceData成员,日志消息打开后的日志消息输出流,输出流指向日志消息存储所在块区。
fnode:instanceData成员,标记在创建pStrm时日志消息的Inode号。
Inode号:文件存储所在块的元信息。
本发明提供了一种适用于国产操作系统的日志记录的保护方法,如图1所示,包括以下步骤:
S01、添加日志消息标识:在rsyslog中,通过结构体instanceData区分日志文件的不同类型,在日志文件输出日志消息时获取该日志消息对应的Inode号。
具体来说,rsyslog可接收各种来源的日志消息输入,并将这些日志消息进行转换,之后再将结果输出保存到不同的日志文件中留存为日志记录。在rsyslog的设计中,日志消息在保存到日志文件中时,通过结构体instanceData来区分不同类型的日志文件,使用instanceData的成员fname来标记日志消息的文件描述符以进行区分,从而能够将日志消息保存至与其类型对应的日志文件中。
本发明中,结构体instanceData的组成成员主要包括pStrm和fnode。其中,pStrm为日志输出流,该结构体包含了日志消息的文件描述符fname,其类型为strm_t,rsyslog能够通过pStrm标记的文件描述符判断日志消息的类型。
pStrm仅在rsyslog启动后第一次执行输入日志消息时创建,pStrm在创建时会打开日志消息被标记的文件描述符,之后每一次将日志消息写入到日志文件都是由创建时的该pStrm完成,这就导致在日志文件被删除后,之前打开的文件描述符无效,从而无法再记录日志消息,当使用文本编辑工具打开并重新保存日志消息时,由于文本编辑工具的保存机制是将原文件删除并创建同名的新文件,因此重新保存的日志消息也无法记录日志文件。
本发明的结构体instanceData中包括成员fnode,该fnode用于获取并保存日志消息的Inode号。在pStrm创建时,对日志消息添加标识,即由pStrm标记到Inode号,之后保存到instancrData的成员fnode中,保证pStrm指向的日志文件准确。
S02、在rsyslog中,检索日志消息的Inode号,以及判断该日志消息与日志文件类型的对应关系。并且,在判断日志消息的Inode号与日志文件类型对应关系前,还需要检索日志文件是否存在。
当检索到日志文件且该日志文件类型与日志消息的Inode号相对应时,将日志消息存入该日志文件形成日志记录。当检索发现日志文件不存在或者日志消息的Inode号没有与其对应的日志文件类型时,销毁与该日志消息对应的pStrm,重复步骤S01,将步骤S01得到的Inode号保存至fnode中并建立新的日志文件类型,更新日志记录。

Claims (7)

1.一种适用于国产操作系统的日志记录的保护方法,其特征在于包括以下步骤:
S01、添加日志消息标识:在rsyslog中,通过结构体instanceData区分日志文件的不同类型,在日志文件输出日志消息时标记该日志消息对应的Inode号;
S02、在rsyslog中,检索日志消息的Inode号,以及判断该日志消息与日志文件类型的对应关系。
2.根据权利要求1所述的一种适用于国产操作系统的日志记录的保护方法,其特征在于:步骤S01中,所述结构体instanceData的组成包括pStrm和fnode。
3.根据权利要求2所述的一种适用于国产操作系统的日志记录的保护方法,其特征在于:rsyslog通过pStrm将日志消息输出并对日志消息添加标识。
4.根据权利要求3所述的一种适用于国产操作系统的日志记录的保护方法,其特征在于:pStrm的类型为strm_t。
5.根据权利要求3所述的一种适用于国产操作系统的日志记录的保护方法,其特征在于:fnode用于获取并保存日志消息的Inode号,在pStrm创建时获取Inode号保存到fnode中。
6.根据权利要求5所述的一种适用于国产操作系统的日志记录的保护方法,其特征在于:步骤S02中,在判断日志消息的Inode号与日志文件类型对应关系前,还需要检索日志文件是否存在,检索到日志文件且该日志文件类型与日志消息的Inode号相对应时,将日志消息存入该日志文件形成日志记录。
7.根据权利要求6所述的一种适用于国产操作系统的日志记录的保护方法,其特征在于:检索发现日志文件不存在或者日志消息的Inode号没有与其对应的日志文件类型时,销毁与该日志消息对应的pStrm,重复步骤S01,将步骤S01得到的Inode号保存至fnode中并建立新的日志文件类型,更新日志记录。
CN202110909492.6A 2021-08-09 2021-08-09 一种适用于国产操作系统的日志记录的保护方法 Active CN113672419B (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110909492.6A CN113672419B (zh) 2021-08-09 2021-08-09 一种适用于国产操作系统的日志记录的保护方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110909492.6A CN113672419B (zh) 2021-08-09 2021-08-09 一种适用于国产操作系统的日志记录的保护方法

Publications (2)

Publication Number Publication Date
CN113672419A true CN113672419A (zh) 2021-11-19
CN113672419B CN113672419B (zh) 2024-01-02

Family

ID=78541926

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110909492.6A Active CN113672419B (zh) 2021-08-09 2021-08-09 一种适用于国产操作系统的日志记录的保护方法

Country Status (1)

Country Link
CN (1) CN113672419B (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102075355A (zh) * 2010-12-30 2011-05-25 北京世纪互联工程技术服务有限公司 日志系统及其使用方法
US20160124823A1 (en) * 2014-10-31 2016-05-05 International Business Machines Corporation Log analytics for problem diagnosis
EP3122016A1 (de) * 2015-07-22 2017-01-25 Siemens Aktiengesellschaft Automatisierungsnetzwerk und verfahren zur überwachung der sicherheit der übertragung von datenpaketen
CN109241004A (zh) * 2018-09-26 2019-01-18 郑州云海信息技术有限公司 元数据文件大小恢复方法、系统、装置及可读存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102075355A (zh) * 2010-12-30 2011-05-25 北京世纪互联工程技术服务有限公司 日志系统及其使用方法
US20160124823A1 (en) * 2014-10-31 2016-05-05 International Business Machines Corporation Log analytics for problem diagnosis
EP3122016A1 (de) * 2015-07-22 2017-01-25 Siemens Aktiengesellschaft Automatisierungsnetzwerk und verfahren zur überwachung der sicherheit der übertragung von datenpaketen
CN109241004A (zh) * 2018-09-26 2019-01-18 郑州云海信息技术有限公司 元数据文件大小恢复方法、系统、装置及可读存储介质

Also Published As

Publication number Publication date
CN113672419B (zh) 2024-01-02

Similar Documents

Publication Publication Date Title
CA2137492C (en) System for and method of providing delta-versioning of the contents of pcte file objects
US5355472A (en) System for substituting tags for non-editable data sets in hypertext documents and updating web files containing links between data sets corresponding to changes made to the tags
CN110879813A (zh) 一种基于二进制日志解析的MySQL数据库增量同步实现方法
CN108446313B (zh) 一种数据格式转换方法和装置
CA2379930A1 (en) Multi-model access to data
CN110928906A (zh) 基于flink仅一次写入carbonData的方法
CN107273449B (zh) 一种基于内存数据库的断点处理方法及系统
CN112231407A (zh) PostgreSQL数据库的DDL同步方法、装置、设备和介质
CN110928899A (zh) 一种通用数据库备份方法及系统
CN108984626B (zh) 一种数据处理方法、装置及服务器
CN113672419A (zh) 一种适用于国产操作系统的日志记录的保护方法
CN111026736B (zh) 数据血缘管理方法及装置、数据血缘解析方法及装置
CN104182479A (zh) 一种处理信息的方法及装置
CN110781160B (zh) 基于VMware虚拟化文件系统损坏的数据恢复方法
CN110286940B (zh) 智能电视日志生成方法
CN112231409A (zh) 数据库同步的初始化装载方法、装置、设备和存储介质
CN111767436A (zh) 一种hash索引数据的存储、读取方法与系统
US8630984B1 (en) System and method for data extraction from email files
CN112380174B (zh) 含删除文件的xfs文件系统解析方法、终端设备及存储介质
CN112463764B (zh) 一种数据库在线迁移的方法及系统
CN109344130A (zh) 一种日志管理方法和装置
CN103914481A (zh) 数据存储方法和装置
CN110609990B (zh) 一种基于人工智能的结构化数据文本编辑方法及系统
Aouad et al. ANTS ROAD: a new tool for SQLite data recovery on android devices
CN116860509B (zh) Pst文件的修复方法、设备及存储介质

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant