In this post, I am going to use yum to install MongoDB-3.6 from MongoDB’s official repository. First we start with adding a .repo file at location
/etc/yum.repos.d/. You can name the file anyway you wish but the extension has to be
Paste the follow code into the .repo file you created, save and exit. You can change
3.6 to the version you want. For instance,
[mongodb-org-3.6] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
Check if the repository is successfully added.
Start installing MongoDB.
yum install mongodb-org
The functionality of each installed packages.
After installation, let’s check the initial status of
systemctl status mongod
For more usage of systemctl, please refer: CentOS7 Systemctl Cheat Sheet
Mongod is enabled initially. If the service is not enabled, use command below to enable and start the service.
systemctl enable mongod systemctl start mongod
Check the version of mongod.
Locations related to Mongodb.
/etc/mongod.conf; config file of mongod.
/var/log/mongodb/; log file of mongod.
/var/lib/mongo/; db path of mongod, all data files are store here.
Connect to mongod.