How to Install Latest MongoDB (2.6.4) on CentOS 7 / RHEL 7

MongoDB is an open source, document-oriented database designed with both scalability and developer agility in mind. Instead of storing your data in tables and rows as you would with a relational database, in MongoDB you store JSON-like documents with dynamic schemas.

The goal of MongoDB is to bridge the gap between key-value stores (which are fast and scalable) and relational databases (which have rich functionality). Binaries are available for Windows, Linux, OS X, and Solaris, MongoDB is available for free under the GNU Affero General Public License. The language drivers are available under an Apache License. In addition, 10gen offers commercial licenses for MongoDB. .

Features of MongoDB:

  • Collection oriented storage – easy storage of object-style data
  • Full index support, including on inner objects
  • Query profiling
  • Replication and fail-over support
  • Efficient storage of binary data including large
  • objects (e.g. videos)
  • Auto-sharding for cloud-level scalability (Q209)
  • High performance, scalability, and reasonable depth of functionality are the goals for the project.

More Information.

Here is the tutorial about install latest MongoDB ( As of now MongoDB 2.6.4 ) on CentOS 7 / RHEL 7.

Open Terminal ( Application —> System Tools —> Terminal).

Switch to root user.

$ su

Download & Install MangoDB:

In CentOS 7 / RHEL 7, redhat introduced systemd to control services, control scripts used in mongodb binary packages are not compatible with systemd; to overcome this situation, we have to use source tar ball for mongodb installation.

# curl -O http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.4.tgz

Extract the downloaded tar ball.

# tar -zxvf mongodb-linux-x86_64-2.6.4.tgz

Move the extracted files to any directory of your choice, here i chose to move it to /usr/ directory.

# mv mongodb-linux-x86_64-2.6.4 /usr/mongodb

The MongoDB executables can be found in bin directory, in my case /usr/mongodb/bin/ is the directory. If you want to execute those executables without using full path, add bin directory in PATH variable.

# export PATH=/usr/mongodb/bin:$PATH

Make it permanent by adding the above in ~/.bashrc file.

Start MongoDB:

Before starting the MongoDB, create a data directory. By default mongod process uses /data/db directory.

# mkdir -p /data/db

To run MongoDB, run the mongod command in hash prompt. Ensue sure that the user account running mongod has permission to write in /data/db directory.

# mongod

OR

If you have not included mongodb bin directory in PATH variable, execute the following command.

# /usr/mongodb/bin/mongod

OR

If you are using data directory other than /data/db, start the mongod process with –dbpath option.

# mongod --dbpath <path to data directory>

You will get the following output once MongoDB is started,

CentOS 7 - Start MongoDB
CentOS 7 – Start MongoDB

Check MongoDB version.

# /usr/mongodb/bin/mongod --version
db version v2.6.4
2014-10-01T15:06:29.577-0400 git version: 3a830be0eb92d772aa855ebb711ac91d658ee910

Connect MongoDB shell by entering the following command.

# /usr/mongodb/bin/mongo
MongoDB shell version: 2.6.4
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
>

That’s all. Now you have latest version of MongoDB installed on your machine.

POSTS YOU MAY LIKE -:)

Share This Post

Shares