- Login into your VPS via ssh
- Create mongodb repository file using an editor as below.
- If you are running a 64-bit system, add the below information to the file you have created.
- Press CTRL+x to exit and press Y to save the file as per screenshot.
- It will ask to confirm filename and path. Just press enter.
- As a best practice, we should also update our package using below command.
yum -y update
- Now, run below command to install MongoDB.
yum -y install mongodb-org mongodb-org-server
That's it. MongoDB is installed. Below are 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 MongoDB server listening on port 27017 on the localhost interface.To change mongodb listening port to 22222 :: mongo --port 22222