MongoDB is a scalable, high-performance, open source NoSQL database. The database is document-oriented so it manages collections of JSON-like documents. Many applications can thus model data in a more natural way, as data can be nested in complex hierarchies and still be queryable and indexable.
We are assuming that you have root permission, otherwise, you may start commands with “sudo”.
For installing the latest stable version of MongoDB you should add MongoDB repository first.
Adding MongoDB Repository
Move to the following directory:
Create the following file with your favorite text editor:
For the latest stable version of MongoDB paste the following line in the file then save and exit:
[mongodb-org-3.4] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
Update your repositories list executing the following command:
Now you can install the latest stable version of MongoDB using “Yum”:
yum install mongodb-org -y
If you are using SELinux, you must configure SELinux to allow MongoDB to start on Red Hat Linux-based systems
If SELinux is in enforcing mode, enable access to the relevant ports that the MongoDB deployment will use (e.g. 27017).
semanage port -a -t mongod_port_t -p tcp 27017
Manage your MongoDB Service
You can manage your MongoDB service with “systemctl”:
For making MongoDB run at startup:
systemctl enable mongodor
chkconfig mongod on
For Start/Stop MongoDB service:
systemctl start mongod
systemctl stop mongodor
service mongod start
service mongod stop
See your MongoDB status:
systemctl status mongodor
service mongod status
Check out MongoDB official website for more information and news!