Thursday, February 17, 2022

MongoDB – Allow Remote Access On Rocky Linux 8

 in This Tutorial you will Learn " How To MongoDB – Allow remote Access On Rocky Linux 8"

MongoDB is an open-source NoSQL Database solution also available in a paid edition for enterprises.
Homepage - https://www.mongodb.com/
Rocky Linux is an open-source enterprise operating system designed to be 100% bug-for-bug compatible with Red Hat Enterprise Linux®.
_________________________________________________________________________________________
Server - Os:  Rocky Linux 8.5  64Bit      | IP -192.168.1.60        |Hostname - server.yourdomain.com
_________________________________________________________________________________________
cat /etc/system-release ; hostname -I ; sestatus ; dnf groupinstall "Development Tools" -y
cat > /etc/yum.repos.d/mongodb.repo << 'EOL'
[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
EOL

dnf update ; dnf install mongodb-org -y
mongod --version
systemctl start mongod ; systemctl enable mongod
tail /var/log/mongodb/mongod.log
mongo
use admin
db.createUser(
      {
      user: "mongod_admin",
      pwd: "YOUR-PASSWORD",
      roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
      }
    )

Db Details -
User - mongod_admin                || Pass - YOUR-PASSWORD || Db - admin

mongo -u mongod_admin -p YOUR-PASSWORD --authenticationDatabase admin
mongo -u mongod_admin -p YOUR-PASSWORD 127.0.0.1/admin

nano /etc/mongod.conf
#security
security:
  authorization: "enabled"
systemctl restart mongod ; systemctl status mongod
firewall-cmd --permanent --add-port=27017/tcp ; firewall-cmd --reload
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++





+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cat /etc/system-release ; hostname -I ; sestatus ; dnf groupinstall "Development Tools" -y
cat > /etc/yum.repos.d/mongodb.repo << 'EOL'
[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
EOL

dnf update ; dnf install mongodb-org -y
systemctl start mongod ; systemctl enable mongod
firewall-cmd --permanent --add-port=27017/tcp ; firewall-cmd --reload


mongo -u mongod_admin -p YOUR-PASSWORD 192.168.1.60/admin
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

No comments:

Post a Comment