MongoDB installation and startup and configuration under Linux

Source: Internet
Author: User

MongoDB installation and start-up

Download Link: http://www.mongodb.org/downloads

----------------------------------------------------------------------------

Linux

Installation

First step: Download the installation package

Download version: 2.0.2-RC2

Download Link: http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.0.1.tgz

First, unzip the installer in Linux

Operation by Command:

Decompression: [[email protected] soft]# TAR-ZXVF mongodb-linux-i686-2.0.2-rc2.tgz

The decompression process is as follows:

DOS code 650) this.width=650; "class=" star "src=" Http://chenzhou123520.iteye.com/images/icon_star.png "alt=" Favorites Code "style = "border:0px;"/>

  1. [Email protected] soft]# TAR-ZXVF mongodb-linux-i686-2.0. 2-rc2.tgz

  2. mongodb-linux-i686-2.0. 2-rc2/

  3. mongodb-linux-i686-2.0. 2-rc2/third-party-notices

  4. mongodb-linux-i686-2.0. 2-rc2/gnu-agpl-3.0

  5. mongodb-linux-i686-2.0. 2-rc2/readme

  6. mongodb-linux-i686-2.0. 2-rc2/bin/

  7. mongodb-linux-i686-2.0. 2-rc2/bin/mongofiles

  8. mongodb-linux-i686-2.0. 2-rc2/bin/mongostat

  9. mongodb-linux-i686-2.0. 2-rc2/bin/bsondump

  10. mongodb-linux-i686-2.0. 2-rc2/bin/mongos

  11. mongodb-linux-i686-2.0. 2-rc2/bin/mongotop

  12. mongodb-linux-i686-2.0. 2-rc2/bin/mongodump

  13. mongodb-linux-i686-2.0. 2-rc2/bin/mongoimport

  14. mongodb-linux-i686-2.0. 2-rc2/bin/mongosniff

  15. mongodb-linux-i686-2.0. 2-rc2/bin/mongo

  16. mongodb-linux-i686-2.0. 2-rc2/bin/mongod

  17. mongodb-linux-i686-2.0. 2-rc2/bin/mongoexport

  18. mongodb-linux-i686-2.0. 2-rc2/bin/mongorestore

we put Mongodb-linux-i686-2.0.2-rc2 Rename to MongoDB

We put a new data directory in the MongoDB directory to hold the information, create a new log directory to hold the log, and then create a new log file under the directory, for example, we named Mongodb.log

DOS code 650) this.width=650; "class=" star "src=" Http://chenzhou123520.iteye.com/images/icon_star.png "alt=" Favorites Code "style = "border:0px;"/>

    1. [Email protected] mongodb]# mkdir log

    2. [Email protected] mongodb]# mkdir data

    3. [[Email protected] mongodb]# CD log

    4. [email protected] log]# Touch Mongodb.log

and navigate to the Mongodb/bin directory.

DOS code 650) this.width=650; "class=" star "src=" Http://chenzhou123520.iteye.com/images/icon_star.png "alt=" Favorites Code "style = "border:0px;"/>

    1. [Email protected] local]# CD Mongodb/bin

Use the Mongod command to set up a MongoDB database link with a port number of 100001, a database path of/mongodb/data, and a log path of/mongodb/log/mongodb.log

Start Command :  

DOS code 650) this.width=650; "class=" star "src=" Http://chenzhou123520.iteye.com/images/icon_star.png "alt=" Favorites Code "style = "border:0px;"/>

    1. [Email protected] mongodb]#/bin/mongod-port 10001 --dbpath data/--logpath log/mongodb.log

    2. All output Going To:log/mongodb.log

Use the client to connect to the database

Re-open a terminal and switch to the MongoDB directory:

DOS code 650) this.width=650; "class=" star "src=" Http://chenzhou123520.iteye.com/images/icon_star.png "alt=" Favorites Code "style = "border:0px;"/>

    1. [Email protected]/]# CD Usr/local/mongodb

Then use the Bin/mongo command to connect to the database

DOS code 650) this.width=650; "class=" star "src=" Http://chenzhou123520.iteye.com/images/icon_star.png "alt=" Favorites Code "style = "border:0px;"/>

    1. [[email protected] mongodb]# ./bin/mongo localhost:< Span class= "number" style= "Color:rgb (192,0,0);" >10001   

    2. mongodb shell version:  2.0 . 2 -rc2  

    3. connecting to: localhost:10001 /test   

    4. >&NBSP;&NBSP;

    5. bye  

Inserting values into the database

DOS code 650) this.width=650; "class=" star "src=" Http://chenzhou123520.iteye.com/images/icon_star.png "alt=" Favorites Code "style = "border:0px;"/>

    1. Connecting To:localhost:10001/test

    2. > Db.foo.save ({A:1})

Querying from the database

DOS code 650) this.width=650; "class=" star "src=" Http://chenzhou123520.iteye.com/images/icon_star.png "alt=" Favorites Code "style = "border:0px;"/>

    1. > Db.foo.find ()

    2. { "_id" : ObjectId ("4ee66eb440ef7803a9873d2d"), "A" : 1 }

    3. >

Access via browser

in the browser address bar, enter: http://localhost:10001/ then enter to access

You can see the following prompt: You is trying to access MongoDB on the native driver port. For HTTP diagnostic access, add the port number

then follow the prompts to add 1000 access to the port number http://localhost:11001/ ,

will be able to access the server-side web page of Monodb


Configuring MongoDB with configuration Files

First create a new file in the MongoDB directory, the file name arbitrary, here I named: mongodb.conf

DOS code 650) this.width=650; "class=" star "src=" Http://chenzhou123520.iteye.com/images/icon_star.png "alt=" Favorites Code "style = "border:0px;"/>

    1. [Email protected] mongodb]# VI mongodb.conf

Then add the configuration information in the configuration file

TXT code 650) this.width=650; "class=" star "src=" Http://chenzhou123520.iteye.com/images/icon_star.png "alt=" Favorites Code "style = "border:0px;"/>

    1. port=10001

    2. dbpath=data/

    3. Logpath=log/mongodb.log

    4. Logappend=true

Explanatory notes:

port=10001 "represents the port number, if not specified, the default is 27017 "

dbpath=data/"Database Path"

Logpath=log/mongodb.log "Log Path"

Logappend=true "Log files automatically accumulate, not overwrite"

Start MongoDB Service  

DOS code 650) this.width=650; "class=" star "src=" Http://chenzhou123520.iteye.com/images/icon_star.png "alt=" Favorites Code "style = "border:0px;"/>

    1. [Email protected] mongodb]#/bin/mongod-f mongodb.conf

    2. All output Going To:log/mongodb.log

and then access the same way as before.      


This article is from the "Intelligent Future _XFICC" blog, please be sure to keep this source http://xficc.blog.51cto.com/1189288/1685831

MongoDB installation and startup and configuration under Linux

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.