Install MongoDB Enterprise on Ubuntu using .tgz Tarball

Overview

Although the recommended procedure to install is through thepackage manager, you can alsoinstall by directly downloading the .tgz file. The followingtutorial downloads the .tgz tarball directly to install MongoDB4.2 Enterprise Edition on LTS Ubuntu Linux systems.

MongoDB Version

This tutorial installs MongoDB 4.2 Enterprise Edition on LTSUbuntu Linux systems. For other versions of MongoDB, refer to thecorresponding version of the manual.

Platform Support

Note

  • MongoDB 4.2 removes support for Ubuntu 14.04.

  • MongoDB 4.2 removes support for Ubuntu 16.04 POWER/PPC64LE (Alsoremoved in version 3.6.13 and 3.4.21).

  • For earlier MongoDB Enterprise versions that support Ubuntu 16.04POWER/PPC64LE:

Due to a lock elision bug present in older versionsof the glibc package on Ubuntu 16.04 for POWER, you mustupgrade the glibc package to at least glibc 2.23-0ubuntu5before running MongoDB. Systems with older versions of theglibc package will experience database server crashes andmisbehavior due to random memory corruption, and are unsuitablefor production deployments of MongoDB

MongoDB only provides packages for the following 64-bit LTS (long-term support)Ubuntu releases:

  • 16.04 LTS (xenial)
  • 18.04 LTS (bionic)

See Supported Platforms for more information.

Production Notes

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

Prerequisites

Click on the tab for your version of Ubuntu

MongoDB .tar.gz tarballs require installing the followingdependencies:

  • Ubuntu 18.04 (Bionic)
  • Ubuntu 16.04 (Xenial)

For Ubuntu 18.04 (Bionic), MongoDB Enterprise .tar.gz tarballs have the following dependencies:

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

For Ubuntu 16.04 (Xenial), MongoDB Enterprise .tar.gz tarballs have the following dependencies:

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

Install using the .tgz Tarball

MongoDB only provides packages for the following 64-bit LTS (long-term support)Ubuntu releases:

  • 16.04 LTS (xenial)
  • 18.04 LTS (bionic)

See Supported Platforms for more information.

Download the MongoDB .tgz tarball.

Download the tarball for your system from the MongoDB Download Center.

Extract the files from the downloaded archive.

Using an archive manager program or the tar command, extract thefiles.

For example, to extract from the terminal shell, you can use thefollowing tar command:

Tip

If you downloaded a different MongoDB 4.2 point release,be sure to modify the command to reflect the correct .tgzfile name.

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

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

The MongoDB binaries are in the <mongodb-install-directory>/bin/directory.

To avoid having to specify the path to the MongoDB binaries, you cancopy these binaries into a directory listed in your PATHvariable such as /usr/local/bin:

  1. sudo cp <mongodb-install-directory>/bin/* /usr/local/bin/

Run MongoDB Enterprise Edition

  • Production Notes
  • Before deploying MongoDB in a production environment, consider theProduction Notes document.
  • ulimit Considerations
  • Most Unix-like operating systems limit the system resources that asession may use. These limits may negatively impact MongoDB operation.See UNIX ulimit Settings for more information.
  • Configuration
  • You can configure the MongoDB instance (such as thedata directory and log directory specifications) usingeither the command-line options or a configuration file.

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 omitsudo as appropriate. See your linux man pages for informationon mkdir and sudo.

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

  1. sudo mkdir -p /var/lib/mongo

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

  1. sudo mkdir -p /var/log/mongodb

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

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

Run MongoDB.

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

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

For details on the command-line options —dbpath and —logpath, seeOptions.

Verify that MongoDB has started successfully.

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

  1. [initandlisten] waiting for connections on port 27017

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

Begin using MongoDB.

Start a mongo shell on the same host machine as themongod. You can run the mongo shellwithout any command-line options to connect to amongod that is running on your localhost with defaultport 27017:

  1. mongo

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

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