How to install MongoDB on RHEL 9.1

1. create a repository file

 

vi /etc/yum.repos.d/mongodb-enterprise-6.0.repo

 

2. Copy & paste and save the file.


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

 

3. sudo yum update

 

4. sudo yum install -y mongodb-enterprise

 

5. sudo yum update

6. Validate the mongo service
       sudo systemctl status mongodb
       ps -ef |grep mongo

7. If mongo service is not running: start the service using “sudo systemctl start mongodb”

8. Use mongosh to launch the Mongo Shell.

       Mongosh