在Ubuntu上配置MongoDB审计功能,需使用MongoDB企业版,具体步骤如下:
/etc/mongod.conf
,添加审计配置,如auditLog.destination: file
、auditLog.format: BSON
、auditLog.path: /var/log/mongodb/auditLog.bson
,还可通过filter
参数设置过滤规则。sudo systemctl restart mongod
使配置生效。mongo --eval "db.runCommand({ getParameter: 1, auditLog: 1 })"
命令查看审计功能是否开启,也可执行一些数据库操作后,检查审计日志文件来验证。