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 @   __Yoon  阅读(313)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
历史上的今天:
2021-08-18 Redis 通过 scan 找出不过期的 key
点击右上角即可分享
微信分享提示