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
1 vim /etc/yum.repos.d/mongodb.repo
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,
1 2 3 4 5 6 [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.
1 yum repolist
Start installing MongoDB.
1 yum install mongodb-org
The functionality of each installed packages.
After installation, let’s check the initial status of
1 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.
1 2 systemctl enable mongod systemctl start mongod
Check the version of mongod.
1 mongo -version
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.