How To Install and Configure MongoDB NoSQL Database To Linux, Ubuntu, Debian, CentOS, Fedora
Sql is very powerful language to query, insert, delete, modify data. Recents years the IT industry have developed some alternative ways to store and retrieve data. NoSQL type database servers become very popular. MongoDb is an NoSQL database server to store and retrieve data. In this tutorial we will look how to install MongoDB on Linux and distributions like Ubuntu, Debian, CentOS, Fedora, RedHat.
Fedora, CentOS, RedHat
We will use
dnfpackage managers to install MongoDB. Alternatively we can download installation package from MongoDB website.
$ sudo dnf install mongodb-server
We will use
apt package manager
$ sudo apt install mongodb-server
Check Service Status
After the installation we need to start the MongoDB service which is named
mongod . The first step is checking the
mongod service status.
$ sudo systemctl status mongod.service
As we can see it is stopped.
Start MongoDB Service with Systemctl
Systemctl is de facto and new tool to manage services in Linux. We will use
systemctl start command to start MongoDB service. We need root privileges to start and stop services.
$ sudo systemctl start mongod.service
Check MongoDB Ports
One of the most occured problem is firewall which prevents to access MongoDB database server ports. We can can access with telnet from remote host like below.
First we will look on MongoDB server which ports are listened. We will use
netstat -tl command. MongoDB generally and by default uses port range 27017-27018 .
$ netstat -tln
$ telnet localhost 27017
We can see that we have no problem about network connection. It we get an message like
Connection refused this means we have problem with network connection to the remote host.