62

As mentioned above, I need to install only the mongo shell on a RHEL instance (machine A). I have a mongodb server on a separate instance (machine B) and need to connect to that from A to run mongodump and mongorestore commands.

I tried looking it up on the web but all I got was instructions to install the complete mongodb package.

Any help appreciated.

Rijumone
  • 772
  • 1
  • 6
  • 13

6 Answers6

66

Official documentation says that you should be fine installing mongodb-org-shell only.

Ali Ben Messaoud
  • 11,690
  • 8
  • 54
  • 87
PinkFluffyUnicorn
  • 1,260
  • 11
  • 20
7
  1. Create a repository file at sudo vim /etc/yum.repos.d/mongodb.repo
[mongodb-org-4.0]
name=MongoDB Repository 
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
gpgcheck=1 
enabled=1 
  1. sudo yum clean all

  2. sudo yum install mongodb-org-shell-4.0.2

  3. mongo <mongo-server-ip> Note: Step 4 will not work in all cases. You need to check proper command to connect to remote mongo server.

Source: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/

Nagy Nick
  • 745
  • 9
  • 19
ketankk
  • 2,578
  • 1
  • 29
  • 27
4

You can follow the official tutorial on installing mongodb, and instead of installing the main package that will install all the packages, just install the package containing mongoshell

Mansuro
  • 4,558
  • 4
  • 36
  • 76
2

You might want to install mongosh (MongoDB Shell) instead. The legacy mongo shell has been deprecated since MongoDB v5.0 and replaced by mongosh. From the mongosh docs:

The new MongoDB Shell, mongosh, offers numerous advantages over the legacy mongo shell, such as:

  • Improved syntax highlighting.
  • Improved command history.
  • Improved logging.

Currently mongosh supports a subset of the mongo shell methods. Achieving feature parity between mongosh and the mongo shell is an ongoing effort.

To maintain backwards compatibility, the methods that mongosh supports use the same syntax as the corresponding methods in the mongo shell. To see the complete list of methods supported by mongosh, see MongoDB Shell Methods.

Further reference: Compatibility Changes with Legacy mongo Shell

abcoep
  • 577
  • 9
  • 14
1

Please follow below steps.

  1. Create a file /etc/yum.repos.d/mongodb.repo

  2. Update the above file to contain:

    [mongodb]
    name=MongoDB Repository  
    baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/  
    gpgcheck=0
    enabled=1
    
  3. sudo yum install -y mongodb-org-shell-2.6.9

  4. mongo mongo-db_server_IP:27017/database_name -u username -p password

Brad K.
  • 188
  • 1
  • 6
er.roshan
  • 19
  • 5
0

Head to Mongo download page; download your required package regarding your operating system. Finally follow the instruction of your operating system to install the package.

Especially to install mongo or mongosh:

  1. download .tgz file and untar the file into /usr/local/
  2. add /usr/local/mongo/ into the shell profile (e.g. ~/.bashrc) and restart your terminal

For more information read the docs.

P.S.: mongo in the path should be vary based on the version of the downloaded package.

Esmaeil MIRZAEE
  • 1,110
  • 11
  • 14