install mongodb shell (mongosh)
install mongodb shell (mongosh)

How To Install MongoDB Shell On Rocky Linux 8

In this short article we will discuss how to install MongoDB Shell on Rocky Linux 8 operating system. When we want to interact with MongoDB, we are not interacting with the database server directly. The MongoDB developer has provided tools that can facilitate this, known as mongosh. The MongoDB Shell, mongosh, is a fully functional JavaScript and Node.js 16.x REPL environment for interacting with MongoDB deployments. We can use the MongoDB Shell to test queries and operations directly with your database.

The legacy mongo shell was deprecated in MongoDB 5.0 and removed in MongoDB 6.0. The new MongoDB Shell, mongosh, offers numerous advantages over the legacy shell. The MongoDB Shell is compatible to MongoDB version 4.2 or greater.

Installing mongosh, MongoDB Shell On Rocky Linux 8

In this tutorial, we will install mongosh version 1.1.2. 6 on the Rocky Linux 8 operating system. The following are the steps for installing mongosh on Rocky Linux 8.

The detailed task will be explained in the sub-chapter below.

1. Update Rocky Linux 8 System

The first step of mongosh installation is to update local packages software. This task will cut down the installation time and it also helps prevent zero-day exploits against outdated software. We will use command line :

$ sudo dnf update -y

Output :

2. Add MongoDB Repository

In this section, we will add MongoDB shell repository, on package management system. For this purpose we have to create a new file, called as /etc/yum.repos.d/mongodb-org-6.0.repo.

$ sudo vi etc/yum.repos.d/mongodb-org-6.0.repo

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

3. Installing mongosh

After all are set, then we will check the requirements, after all are set, then we will submit command as shown below :

$ sudo yum install -y mongodb-mongosh
[ramansah@otodiginet ~]$ sudo yum install -y mongodb-mongosh
[sudo] password for ramansah: 
MongoDB Repository                              6.6 kB/s |  14 kB     00:02    
Last metadata expiration check: 0:00:01 ago on Thu 22 Dec 2022 03:08:42 PM WIB.
Package mongodb-mongosh-1.1.6-1.el7.x86_64 is already installed.
Dependencies resolved.
================================================================================
 Package              Arch        Version            Repository            Size
================================================================================
Upgrading:
 mongodb-mongosh      x86_64      1.6.1-1.el8        mongodb-org-5.0       41 M

Transaction Summary
================================================================================
Upgrade  1 Package

Total download size: 41 M
Downloading Packages:
mongodb-mongosh-1.6.1.x86_64.rpm                       203 kB/s |  41 MB     03:27    
---------------------------------------------------------------------------------------
Total                                                  203 kB/s |  41 MB     03:27     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                               1/1 
  Upgrading        : mongodb-mongosh-1.6.1-1.el8.x86_64                            1/2 
  Cleanup          : mongodb-mongosh-1.1.6-1.el7.x86_64                            2/2 
  Running scriptlet: mongodb-mongosh-1.1.6-1.el7.x86_64                            2/2 
  Verifying        : mongodb-mongosh-1.6.1-1.el8.x86_64                            1/2 
  Verifying        : mongodb-mongosh-1.1.6-1.el7.x86_64                            2/2 
Installed products updated.

Upgraded:
  mongodb-mongosh-1.6.1-1.el8.x86_64                                                   

Complete!
installing mongosh on Rocky Linux 8

4. Connect To MongoDB

Incidentally, in this tutorial, we already have MongoDB version 5.0 installed on our system. So that we can try to login to the MongoDB server. We will try to connect to the server by submitting command line :

$ mongosh

Output :

[ramansah@otodiginet ~]$ mongosh
Current Mongosh Log ID:	63a52a4bd78d913b4d91871c
Connecting to:		mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.6.1
Using MongoDB:		5.0.4
Using Mongosh:		1.6.1

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

------
   The server generated these startup warnings when booting
   2022-12-23T10:43:58.315+07:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
   2022-12-23T10:43:58.315+07:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'
------

------
   Enable MongoDB's free cloud-based monitoring service, which will then receive and display
   metrics about your deployment (disk utilization, CPU, operation statistics, etc).
   
   The monitoring data will be available on a MongoDB website with a unique URL accessible to you
   and anyone you share the URL with. MongoDB may use this information to make product
   improvements and to suggest MongoDB products and deployment options to you.
   
   To enable free monitoring, run the following command: db.enableFreeMonitoring()
   To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
------

test> 

Conclusion

In this short tutorial, we have already installed mongosh (MongoDB shell) on Rocky Linux 8 successfully. I hope this tutorial will be helpfull.

(Visited 284 times, 1 visits today)

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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