Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Thursday, July 02, 2015

Install MongoDB using yum on Linux(CentOS)


                MongoDB falls into NoSQL category of database also it is a document database that provides high performance, high availability, and easy scalability.Few of its advantages are high availability and scalability.In this post we are going to see how to install the mongodb using yum on linux.

Step 1:Create a repo file that is necessary to download the mongodb.
vim /etc/yum.repos.d/mongodb.repo
Step 2:Mongodb has two types of packages for 32-bit and 64-bit systems.
For 32-bit systems type the below information in repo file and save.
[mongodb-org-3.0]
name=MongoDB 3.0 Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686/
gpgcheck=0
enabled=1
         In the first line of the file specify you own necessary version of the mongodb to be downloaded.Here i have used version 3.0.

For 64-bit systems type the below information in repo file and save.
[mongodb-org-3.0]
name=MongoDB 3.0 Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
         In the first line of the file specify you own necessary version of the mongodb to be downloaded.Here i have used version 3.0.
Note:It’s 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 3:Mongodb has a set of packages as below:
mongodb-org-server-3.0.4           //Mongodb server
mongodb-org-shell-3.0.4            //Mongo Shell
mongodb-org-mongos-3.0.4           //Mongo Shard
mongodb-org-tools-3.0.4            //Mongo Tools

And it contains all the above package together as a single package as below:
mongodb-org-3.0.4

To install all the packages issue the below command:
sudo yum install mongodb-org
To install mongodb server alone issue the below command:
sudo yum install mongodb-org-server-3.0.4
To install mongo shell alone issue the below command:
sudo yum install mongodb-org-shell-3.0.4
To install mongo shard alone issue the below command:
sudo yum install mongodb-org-mongos-3.0.4
To install mongo tools alone issue the below command:
sudo yum install mongodb-org-tools-3.0.4

Step 3:Start the installed mongodb server using the below command:
sudo service mongod start
The server is now started and to login to the mongo shell issue the below command:
mongo
To check the current status of mongod issue the below command:
sudo service mongod status
To stop the running mongod server use the below command:
sudo service mongod stop

It’s finished.We have installed the mongodb and now you can start exploring :)




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 :)