Thursday, February 12, 2015

Install MongoDB binary on linux


                  
MongoDB is a cross-platform, document-oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on the concept of collection and document. It is also one of the leading NoSQL databases. It’s easy to install MongoDB binary file within five minutes if you follow the steps mentioned below. Here we go..!!
Step 1: Download the latest .tar.gz file from  this link
Its always better to download 64 bit for production rather than 32 bit because 32-bit MongoDB processes are limited to about 2 GB of data. But the 64 bit doesn't have that limitation. For development, both versions can be used.

Step 2: Create a source directory and place the downloaded file in the source directory.For example (/usr/local)

Step 3: Now extract the downloaded file using the below command:
tar zxf mongodb-linux-i686-1.6.0.tar.gz
Step 4: Now rename the extracted(mongodb-linux-x86 64-2.6.3) file into MongoDB.
mv mongodb-linux-x86 64-2.6.3 ./mongodb
Step 5: Create a data directory using the below command
mkdir /data/db
Step 6: Create a user mongo_user using the following command
useradd mongod
                 This user can have all the privileges to access the MongoDB database and directories.

Step 7: Change the ownership of the files in the source and data directory using the following command
chown -R mongod.mongod /usr/local/
chown -R mongod.mongod /data/db/
                     Changing the ownership gives the complete access for the users to access the source and the data directory.

Step 8: Create a configuration file in any directory say vim /etc/mongod.conf
Now add the following details as shown below:
verbose = true
dbpath = /data/db
logpath = /var/log/mongodb.log
logappend = true
port = 27017
                    Verbose is an option that provides additional details what the computer is doing and what drivers and software it is loading during startup. Dbpath shows the data directory path. Logpath shows the path for the log file.Log append will append the log file. Port will specify which port the mongo shell will connect.

Step 9: Move to the bin folder in the source directory and now start the mongo server by the following command
./mongod --config /etc/mongod.conf
Step 10: Within the bin folder in the source directory start the mongo client by the following command
./mongo --port 27017
The interactive MongoDB prompt appears. That's it now you're done with the MongoDB binary installation. Time to play with MongoDB :)

1 comment:

  1. ./mongod --config /u01/mongodb1/mongod.conf is running for more than an hr, the logs are moving though. how long it takes for running ./mongod ???

    ReplyDelete