Skip to content

Instantly share code, notes, and snippets.

@plembo
Last active February 14, 2019 17:42
Show Gist options
  • Save plembo/1f5cf0103a1845ac532f48b5d21f9a31 to your computer and use it in GitHub Desktop.
Save plembo/1f5cf0103a1845ac532f48b5d21f9a31 to your computer and use it in GitHub Desktop.
Install MongoDB Community Server on Ubuntu LTS

Installing MongoDB Community Server on Ubuntu LTS

Go to the documentation pages and select your distro, architecture and version:

https://docs.mongodb.com/manual/administration/install-on-linux/

For Ubuntu:

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

  1. Import the MongoDB software signing key:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
  1. Create an apt sources list file for Ubuntu 18.04 LTS (Bionic):
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
  1. Update package cache:
sudo apt-get update
  1. Install the MongoDB packages:
sudo apt-get install -y mongodb-org

This will install not only the server, but also clients, tools and drivers.

Server components will be located:

Confguration: /etc/mongod.conf

Data files: /var/lib/mongodb

Logs: /var/log/mongodb.log

Start/stop/get status of server:

$ sudo systemctl start mongod
$ sudo systemctl status mongod
$ sudo systemctl stop mongod

Set to start with system:

$ sudo systemctl enable mongod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment