Archive for September, 2021

Installing and securing Mongo on CentOS 7

Wednesday, September 8th, 2021

vi /etc/security/limits.d/20-nproc.conf

mongod soft nproc 32000


vi /etc/yum.repos.d/mongodb-org.repo

[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc


yum repolist
yum install mongodb-org
systemctl start mongod


mongosh

db.createUser(
{
user: "dba",
pwd: passwordPrompt(),
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
}
)


vi /etc/mongod.conf


security:
authorization: enabled


systemctl restart mongod

mongosh
use admin
db.auth(‘dba’,promptPassword())