Skip to content

Instantly share code, notes, and snippets.

@xuannghia
Last active July 21, 2018 10:18
Show Gist options
  • Save xuannghia/bc97730b24167c1d3a5d39010cf7772e to your computer and use it in GitHub Desktop.
Save xuannghia/bc97730b24167c1d3a5d39010cf7772e to your computer and use it in GitHub Desktop.
Install MongoDB 4.0 on CentOS 7

1. Add MongoDB Repository

sudo vi /etc/yum.repos.d/mongodb-org-4.0.repo

Change content to:

[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc

Save and close the file. Use yum repolist to check, content will be like this:

...
mongodb-org-4.0/7       MongoDB Repository          5
...

2. Install MongoDB package

sudo yum install -y mongodb-org

Start & Enable MongoDB service with the systemctl utility:

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