MongoDB is a free and open-source cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB avoids the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas, making data integration in some applications easier and faster.
1. Log in to your VPS via SSH
2. Create a MongoDB repository file using an editor as below –
3. If you are running a 64-bit system, add the below information to the file you have created –
4. Press ctrl + x to exit and then press y to save the file as per the screenshot.
5. It will ask to confirm the filename and path; just press Enter.
6. As a best practice, we should also update our package using this command –
yum -y update
7. Now, run the below-given command to install MongoDB –
yum -y install mongodb-org mongodb-org-server
MongoDB is installed.
Here's a list of some useful commands –
- Start-Up MongoDB - systemctl start mongod
- Check MongoDB Service Status - systemctl status mongod
- Enter the MongoDB Command Line - mongo
- Shutdown MongoDB - systemctl stop mongod
- Summary List of Status Statistics (Continuous) - mongostat
- Summary List of Status Statistics (5 Rows, Summarized Every 2 Seconds) - mongostat --rowcount 5 2
By default, the MongoDB server listening on port 27017 on the localhost interface. To change MongoDB listening port to 22222: mongo --port 22222.