Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save febridev/4f20cdf94acf1449e076723d45b299b5 to your computer and use it in GitHub Desktop.
Save febridev/4f20cdf94acf1449e076723d45b299b5 to your computer and use it in GitHub Desktop.
Install MongoDB on Ubuntu 16.06

Install MongoDB on Ubuntu 16.04

Import MongoDB GPG Key

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5

Add MongoDB apt repository

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

Update the package list

sudo apt-get update -y

Install MongoDB

sudo apt-get install -y mongodb-org

Update /etc/mongod.conf for remote access

sudo vim /etc/mongod.conf

Edit bindIP: with setting below

net:
  port: 27017
  bindIp: 0.0.0.0

Start MongoDB

sudo systemctl start mongod

Check MongoDB status

sudo systemctl status mongod

Enable MongoDB so it starts on boot

sudo systemctl enable mongod

Install sysfsutils to edit kernel settings

sudo apt install -y sysfsutils

Update /etc/sysfs.conf to modify transparent_hugepage kernel settings

sudo vim /etc/sysfs.conf

Add these 2 lines at the end of the file

kernel/mm/transparent_hugepage/defrag = never
kernel/mm/transparent_hugepage/enabled = never

Reboot server so settings can take effect

sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment