MongoDB 审计

1、启用和配置审计的输出格式

使用--auditDestination配置项来启用MongoDB审计和指定输出的审计事件。

01、审计日志输出到syslog,如:

mongod  --dbpath /var/lib/mongo  --auditDestination syslog

或者,在MongoDB配置文件设置,如下:

auditLog:
destination: syslog

02、审计日志输出到console控制台

mongod  --dbpath /var/lib/mongo  --auditDestination console

或者,在MongoDB配置文件添加以下配置:

auditLog:
destination: console

03、与console、syslog不同,为了使审计以一个JSON格式文件输出审计事件,需要指定auditDestination设置文件,并设置--auditFormat JSON,输出文件名--auditpath路径

mongod  --dbpath /var/lib/mongo --auditDestination file --auditFormat JSON --auditPath /var/lib/mongo/auditLog.json

或者,在MongoDB配置文件添加以下配置:

# 打开审计日志
auditLog:
    destination: file
    format: JSON
    path: /data/mongodb/27017/log/audit.json

04、与JSON文件相似,以BSON格式输出审计事件,需要设置--auditDestination为文件file,以及设置--auditFormat、--auditPath这两个配置项。

mongod --dbpath /var/lib/mongo  --auditDestination file --auditFormat BSON --auditPath /var/lib/mongo/auditLog.bson

或者,在MongoDB配置文件添加以下配置:

auditLog:
    destination: file
    format: BSON
    path: /data/mongodb/27017/log/auditLog.bson

使用bosndump命令将bosn文件转换成可读的信息输出在终端:

bsondump /data/mongodb/27017/log/auditLog.bson

 

参考:http://www.manongjc.com/detail/50-vhhszrirelhmmxt.html

posted @ 2023-08-18 11:04  __Yoon  阅读(237)  评论(0编辑  收藏  举报