Did You Know?

How Can We Help?

Special Offer

Deploy your Cloud Server now and get $100 in Free Credits!

Get Started

For Application Data Storage on Fedora 14, Use MongoDB

Table of Content


MongoDB is a database engine that gives users access to key-value databases that are not related to each other in any way. It is a component of the expanding NoSQL movement, which is geared at the creation of a replacement for conventional relational database management systems (RDBMS). In addition to having a design that is schema-free and an architecture that is scalable, MongoDB also offers an output format that is based on JSON and specialised language specific bindings. These features make it especially appealing for use in the building of bespoke software applications. Despite the fact that MongoDB is still a relatively young project and is not yet packaged by the majority of the main operating system distributions, the software has already been utilised in a number of large scale production installations such as "GitHub," "SourceForge," and "DISQUS."

Install MongoDB


Use the following command to make sure that all of the software you have installed is up-to-date:

[console]#yum update[/console]

You should get the most recent binaries from the upstream source, which at the time of this writing is version 1.6.5. Make sure that the version of MongoDB that you download was built for the architecture of your computer system. This will guarantee that the software runs properly on your computer. The 32-bit version is used in this text; however, the 64-bit edition may be used with these procedures by making a few adjustments. It has been brought to our attention that the database size restriction for the 32-bit version of MongoDB is 2 GB. If you anticipate storing more than 2 terabytes of data, you should make sure that you are using the 64-bit version of MongoDB and that you have deployed a system that is capable of running 64 bits.

[console]#cd /opt/[/console]

[console]#wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.6.5.tgz[/console]

[console]#tar zxvf mongodb-linux-i686-1.6.5.tgz[/console]

[console]#mv mongodb-linux-i686-1.6.5 /opt/mongodb[/console]

*The binaries for MongoDB are now in the /opt/mongodb/bin/ folder. MongoDB is now set up in the /opt/mongodb/ folder. In this example, it is assumed that all database files will be stored in the /srv/db/mongodb folder and log files will be stored in the /srv/db/mongodb.log file. To make this file and directory, type the following commands:

[console]#mkdir -p /srv/db/mongodb[/console]

[console]#touch /srv/db/mongodb.log[/console]

*Develop Some Simple Control Scripts

In most configurations, the MongoDB server process is managed by passing command line parameters to the mongod binary, which may be found in the /opt/mongodb/bin directory. The creation of control scripts in the /opt/bin/ directory with the names mongodb-start and mongodb-stop may help to ease the execution of these tasks. Execute the following commands in order to generate the necessary directories:

[console]#mkdir /opt/bin/[/console]

[console]#mkdir /opt/config/[/console]

The scripts may be downloaded and their permissions adjusted by using the following series of commands:

[console]#cd /opt/bin/[/console]

[console]#wget -O mongodb-start http://www.linode.com/docs/assets/621-mongodb-start.sh[/console]

[console]#wget -O mongodb-stop http://www.linode.com/docs/assets/622-mongodb-stop.sh[/console]

[console]#chmod +x *[/console]

*Examine the contents of the mongodb-start and mongodb-stop files, and if your deployment calls for a different startup method, make the necessary modifications to these files. The MongoDB process may be started or stopped by executing the /opt/bin/mongodb-start or /opt/bin/mongodb-stop commands, respectively, from this point forward. The variables that are specified in the /opt/config/mongodb file are responsible for controlling the behaviour of the mongod process.

Utilizing a Straightforward Init Script

As a wrapper around the mongodb-start and mongo-stop scripts discussed above, we have also written a very simple "init script." You must still edit and administer the settings of your MongoDB server in the files listed above. This script merely ensures that MongoDB starts at boot time. Issue the following instructions:

[console]#wget -O init-rpm.sh http://www.linode.com/docs/assets/623-mongodb-init-rpm.sh[/console]

[console]#mv init-rpm.sh /etc/rc.d/init.d/mongodb[/console]

[console]#chmod +x /etc/rc.d/init.d/mongodb /etc/init.d/mongodb[/console]

[console]#chkconfig --add mongodb[/console]

[console]#chkconfig mongodb on[/console]

In addition to this, you will have to set up a user and group for the mongodb database by issuing the following command:

[console]#useradd -M -r --home-dir /opt/mongodb mongodb[/console]

Now, use the following command to make sure that the MongoDB user you just established will have access to all of the necessary files located in the /srv/db/ directory structure.

[console]#chown mongodb:mongodb -R /srv/db/[/console]

Using the init script, you may start and stop MongoDB using the following commands:

[console]#/etc/init.d/mongodb start[/console]

[console]#/etc/init.d/mongodb stop[/console]

The MongoDB system that you installed is now fully operational and ready for use.

Thank You


Special Offer

Deploy your Cloud Server now and get $100 in Free Credits!

Get Started
Table of Contents