Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Install MongoDB?
While there are several different types of database software available, MongoDB is a popular and feature-rich alternative to other software such as MySQL. As this software is not frequently pre-installed on Linux-based hosts, you may find yourself needing to install MongoDB on your CentOS or Ubuntu server. In this guide, we will outline how to install MongoDB on your CentOS and Ubuntu machines. Please note that you will need root SSH access on your server to perform the actions in the following guide.

Topics Include:

Installing MongoDB on CentOS

Adding MongoDB Repo
Installing MongoDB
Testing MongoDB

Installing MongoDB on Ubuntu

Adding MongoDB Repo
Installing MongoDB

Install MongoDB on your Dedicated Server and start hosting your databases today!

Installing MongoDB on CentOS
Adding MongoDB Repo
By default, the MongoDB software repositories (repos) are not accessible to CentOS machines. To fix this, you will need to create a repo file that will allow your server to access the MongoDB repositories. Using the nano text editor command, you can create a new .repo file as follows: sudo nano /etc/yum.repos.d/mongodb-org.repo
Next, go to the MongoDB website and find the version of the MongoDB server software for your particular version of CentOS as well as the gpgkey URL. Once these URLs are located, copy the link to the file as such:[mongodb-org-3.4]name=MongoDB Repository
gpgkey= *Please make sure to replace URL_FROM_MONGODB with the URL you copied from the MongoDB page for your chosen version of MongoDB.*
Check to make sure the repo was added successfully with the following command:yum repolistIf added successfully, you should see something like this in the list:

mongodb-org-3.2/7/x86_64         MongoDB Repository

Installing MongoDB
Now with the repo installed, we can start the installation process with the following command: sudo yum install mongodb-org
Next, start the MongoDB service with the following command : sudo systemctl start mongod
Testing MongoDB
To test if the installation was successful, you will need to use the tail command to search the end of the MongoDB log file: sudo tail /var/log/mongodb/mongod.logIf the installation was successful, you should see that the service is listening on the database port and waiting for connections.

To make sure that the MongoDB utility daemon is enabled as well, use the following command: systemctl is-enabled mongod; echo $?If the returned output is 0, that means the daemon is enabled and you can begin to connect your databases to MongoDB. If the output is 1, then the daemon is not enabled and you may need to reinstall the software. If you need help with this task, we recommend contacting our Technical Support team for direct assistance.
Installing MongoDB on Ubuntu
Adding MongoDB Repo

Unlike CentOS, Ubuntu includes MongoDB package repositories by default. However, to get the most up-to-date packages, we will still want to manually add the latest version of the MongoDB repositories. To ensure the authenticity of packages, Ubuntu requires the package to be signed with a gpg key.

First, we will need to add the gpg key for MongoDB using the following command: sudo apt-key adv --keyserver hkp:// --recv EA312927
After importing the key, you should see the following output:

gpg: Total number processed: 1
gpg: imported: 1  (RSA: 1)

Next, we will need to add the repo to the packages list using the following command:echo "deb xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
Installing MongoDB
With the Repo now added, we can now install MongoDB itself: sudo apt-get install -y mongodb-org
Next, start the service: sudo systemctl start mongod
To check that the service started successfully, use the following command: sudo systemctl status mongod
Finally, enable the MongoDB utility daemon: sudo systemctl enable mongod

Congratulations, you now know how to install MongoDB!

Use MongoDB on your InMotion Hosting Dedicated Server for high-performance database storage and management!

All copyrights for this article are reserved to Inmotion

Forum Jump:

Users browsing this thread: 1 Guest(s)