以下是CentOS上MongoDB的安全配置指南:
/etc/mongod.conf中设置security.authorization: enabled,并重启服务。mongo shell连接到MongoDB,切换到admin数据库,通过db.createUser命令创建用户并分配角色,如db.createUser({user: "admin", pwd: "your_password", roles: [{role: "root", db: "admin"}]})。/etc/mongod.conf中通过bindIp参数指定允许连接的IP地址,如bindIp: 127.0.0.1。/etc/mongod.conf,添加net.ssl.mode: requireSSL等相关配置,重启服务。firewalld或ufw限制对MongoDB端口(默认27017)的访问。