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
分类:
MongoDB
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
2021-08-18 Redis 通过 scan 找出不过期的 key