Navigation

Install MongoDB Enterprise on Debian Using .tgz Tarball

Overview

Although the recommended procedure to install is through the package manager, you can also install by directly downloading the .tgz file. The following tutorial downloads the .tgz tarball directly to install MongoDB 4.2 Enterprise Edition on Debian Linux systems.

Note

To install a different version of MongoDB, please refer to that version’s documentation. To install the previous version, see the tutorial for version 4.0.

Considerations

Production Notes

Before deploying MongoDB in a production environment, consider the Production Notes document.

Platform Support

EOL Notice

MongoDB 4.2 removes support for Debian 8 (“Jessie”).

MongodDB 4.2 supports:

  • Debian 10 “Buster” (Starting in version 4.2.1)
  • Debian 9 “Stretch”

MongoDB only provides packages for the 64-bit builds of these releases. See Supported Platforms for more information.

Install MongoDB Enterprise

Prerequisites

MongoDB .tar.gz tarballs require installing the following dependencies:

sudo apt-get install libcurl4 libgssapi-krb5-2 libkrb5-dbg libldap-2.4-2 libpcap0.8 libsasl2-2 snmp openssl
sudo apt-get install libcurl3 libgssapi-krb5-2 libkrb5-dbg libldap-2.4-2 libpcap0.8 libsasl2-2 snmp openssl

Procedure

1

Download the MongoDB Enterprise .tar.gz tarball.

After you have installed the required prerequisite packages, download the MongoDB Enterprise tarball for your system from the MongoDB Download Center.

2

Extract the files from the downloaded archive.

For example, from a system shell, you can extract using the tar command:

tar -zxvf mongodb-linux-*-4.2.1.tgz
3

Ensure the binaries are in a directory listed in your PATH environment variable.

The MongoDB binaries are in the bin/ directory of the tarball. You can either:

  • Copy the binaries into a directory listed in your PATH variable, such as /usr/local/bin (Update /path/to/the/mongodb-directory/ with your installation directory as appropriate)

    sudo cp /path/to/the/mongodb-directory/bin/* /usr/local/bin/
    
  • Create symbolic links to the binaries from a directory listed in your PATH variable, such as /usr/local/bin (Update /path/to/the/mongodb-directory/ with your installation directory as appropriate):

    sudo ln -s  /path/to/the/mongodb-directory/bin/* /usr/local/bin/
    

Run MongoDB Enterprise

Production Notes

Before deploying MongoDB in a production environment, consider the Production Notes document.

By default, MongoDB instance stores:

  • its data files in /var/lib/mongodb
  • its log files in /var/log/mongodb

If you installed via the package manager, the directories are created during the installation.

If you installed manually by downloading the tarballs, you can create the directories using mkdir -p <directory> or sudo mkdir -p <directory> depending on the user that will run MongoDB. (See your linux man pages for information on mkdir and sudo.)

By default, MongoDB runs using the mongodb user account. If you change the user that runs the MongoDB process, you must also modify the permission to the /var/lib/mongodb and /var/log/mongodb directories to give this user access to these directories.

To specify a different log file directory and data file directory, edit the systemLog.path and storage.dbPath settings in the /etc/mongod.conf. Ensure that the user running MongoDB has access to these directories.

Most Unix-like operating systems limit the system resources that a session may use. These limits may negatively impact MongoDB operation. See UNIX ulimit Settings for more information.

1

Create the data and log directories.

Note

Depending on user permissions, you may need to sudo mkdir -p <directory> instead of mkdir -p <directory>. Use or omit sudo as appropriate. See your linux man pages for information on mkdir and sudo.

Create a directory where the MongoDB instance stores its data. For example:

sudo mkdir -p /var/lib/mongo

Create a directory where the MongoDB instance stores its log. For example:

sudo mkdir -p /var/log/mongodb

The user that starts the MongoDB process must have read and write permission to these directories. For example, if you intend to run MongoDB as yourself:

sudo chown `whoami` /var/lib/mongo     # Or substitute another user
sudo chown `whoami` /var/log/mongodb   # Or substitute another user
2

Run MongoDB.

To run MongoDB, run the mongod process at the system prompt.

mongod --dbpath /var/lib/mongo --logpath /var/log/mongodb/mongod.log --fork

For details on the command-line options --dbpath and --logpath, see Options.

3

Verify that MongoDB has started successfully.

Verify that MongoDB has started successfully by checking the process output for the following line in the log file /var/log/mongodb/mongod.log:

[initandlisten] waiting for connections on port 27017

You may see non-critical warnings in the process output. As long as you see the log line shown above, you can safely ignore these warnings during your initial evaluation of MongoDB.

4

Begin using MongoDB.

Start a mongo shell on the same host machine as the mongod. You can run the mongo shell without any command-line options to connect to a mongod that is running on your localhost with default port 27017:

mongo

For more information on connecting using the mongo shell, such as to connect to a mongod instance running on a different host and/or port, see The mongo Shell.

To help you start using MongoDB, MongoDB provides Getting Started Guides in various driver editions. See Getting Started for the available editions.