MongoDB installation under Linux __linux

Source: Internet
Author: User
Tags mongodb mongodb server

1. Download MongoDB

2. Extract files to a directory, and then rename: [Root@localhost var]# tar-xzvf Mongodb-linux-i686-2.0.1.tar [root@localhost var]# MV Mongodb-linu x-i686-2.0.1/mongodb/

Bin Mongod is the MongoDB server process, MONGO is its client, other commands for MongoDB other uses such as MongoDB file export.

3. Start MongoDB.

To first set up the MongoDB storage data files and log files directory, which is based on the/data: [root@localhost var]# cd/data/[root@localhost data]# ls mongodb_data mon Godb_log

Use Mongod to start mongodb under bin under the MongoDB installation directory./mongod--dbpath=/data/mongodb_data/--logpath=/data/mongodb_log/ Mongodb.log--logappend&
After you wait for the startup to succeed, you can see if the startup is successful, the default port number is 27017, and you can also specify unused ports at startup.

   First See if MongoDB is started by looking at the port number. [root@localhost data]# netstat -lanp | grep  "27017"    tcp         0      0 0.0.0.0:27017                0.0.0.0:*                    LISTEN       2442/mongod             Unix   2      [ ACC ]     STREAM      LISTENING     18203   2442/mongod          /tmp/mongodb-27017.sock  

As you can see, the success has started and now access the database using the MONGO client. [Root@localhost bin]# cd/var/mongodb/bin/[root@localhost bin]#./mongo mongodb Shell version:2.0.1 connecting t O:test >

Installation Successful

4. Additional work.

Put the Mongod in the service from the startup entry

Edit/etc/rc.d/rc.local, add the following code and save it. #add mongondb service rm-rf/data/mongodb_data/* &&/var/mongodb/bin/mongod--dbpath=/data/mongodb_data/-- Logpath=/data/mongodb_log/mongodb.log--logappend&

We restart the computer to see if the MongoDB is started, restart can be directly using the MONGO command login, and finally found that can be successful.

In addition, we use the MONGO command to log in MongoDB and go to the directory where the MONGO command is being executed./mongo, this is not a bit of a hassle. So, we can simplify this, copy the command file to/usr/bin, so that you can use the MONGO command in any directory.  [root@localhost bin]# ls bsondump dbbak MONGO mongod mongodump mongoexport mongofiles mongoimport MONGOs Mongosniff Mongostat [root@localhost bin]# CP mongo/usr/bin/

Go to any directory try the MONGO command: [root@localhost bin]# CD/root@localhost/]# MONGO MongoDB Shell version:1.8.1 connecting to: Test >

You can see that the login was successful, which means we can use the MONGO command just as we did with the LS command.




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.