Install MongoDB AMAZON Linux, CentOS7 and Redhat

Create a repo file of mongo.db

This is for Amazon Linux

vim /etc/yum.repos.d

[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc

This is for install mongodb centos 7 or redhat7

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

Now install mongodb linux the package and start the service


sudo yum install -y mongodb-org
sudo systemctl start mongod
sudo systemctl enable mongod

or

/usr/bin/mongod –dbpath /home/ec2-user/geniedoc/ –fork –logpath /var/log/gdoc.log

or

/usr/bin/mongod –dbpath /home/ec2-user/geniedoc/ –logpath /var/log/gdoc.log

How to restore the backup of database mongodb


mongorestore -d backupfile backuppath
like
mongorestore -d devopscheetah /home/ec2-user/devopscheetah

How to take the backup mongodb


mongodump –db backupfile backupapth(define the path where you want to take backup)
like
mongodump –db devopscheetah –out /backup/

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *