How to install MongoDB on CentOS

→ Are you a new visitor? Please visit the page guidance for new visitors ←

About MongoDB

MongoDB is one of the leading noSQL database based on the number of searches google trend has given us, you can see below this paragraph the proof. Its development began in 2007 I believe by the company (named at the time) 10Gen. Since then, it has grown a lot, being the most used noSQL database currently on the market, its latest version being 2.4.6. Even LinkedIN shows that the number of users that have enlisted MongoDB to their profile is over 40% of their data. In this article, I’m going to show you how you can easily install MongoDB on Centos operating system step by step.

google trend MongoDB

Google trend MongoDB

Installing repository for MongoDB

For each operating system, be it on 64-bit or 32-bit system, the developers have been kind enough to provide us with the proper repository.

First you need to create the file:

Based on your operating system, you will add the below configuration:

  • 32-bit system

  •  64-bit system

Install MongoDB on centos

To install MongoDB you need to simple run the command below as root or with sudo:

Once this is completed, MongoDB is installed and ready to be used.

The configuration file is found under:

/etc/mongod.conf

Once you make any changes you need to be sure you restart the service issuing the command:

Be sure that the service has been set to start automatically, you can do this by issuing command:

Manually compiling MongoDB

And that would be all for CentOS. The process is almost identical on either distribution, the only difference I’ve seen is that you need to use a different repository for each distribution.

Of course, if you are feeling safer compiling it yourself manually you also have the source provided by MongoDB for just this. To manually compile the source you do need to use scons.

To install scons you need to run the commands:

Then you need to run the commands bellow to download, untar the files and install mongoDB

This will install mongoDB inside the folder /opt/mongo/ along with all packages needed and tools.

You can also use scons to force building with ssl or perhaps with 32-bits or 64-bits, see below flags:

  • --d: debug build; all this does is turn optimization off
  • --dd: debug build with _DEBUG defined (extra asserts, checks, etc.)
  • --release
  • --32: force 32 bit
  • --64: force 64 bit
  • --clean: cleans the target specified
  • --mute: suppress compile and link command lines
  • --ssl: builds MongoDB with SSL support

That’s all for now, if you found anything missing, please comment below and I’ll be sure to update this post. I’ll see you again in our next article.

Request an article ←