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;"/>
[Email protected] soft]# TAR-ZXVF mongodb-linux-i686-2.0. 2-rc2.tgz
mongodb-linux-i686-2.0. 2-rc2/
mongodb-linux-i686-2.0. 2-rc2/third-party-notices
mongodb-linux-i686-2.0. 2-rc2/gnu-agpl-3.0
mongodb-linux-i686-2.0. 2-rc2/readme
mongodb-linux-i686-2.0. 2-rc2/bin/
mongodb-linux-i686-2.0. 2-rc2/bin/mongofiles
mongodb-linux-i686-2.0. 2-rc2/bin/mongostat
mongodb-linux-i686-2.0. 2-rc2/bin/bsondump
mongodb-linux-i686-2.0. 2-rc2/bin/mongos
mongodb-linux-i686-2.0. 2-rc2/bin/mongotop
mongodb-linux-i686-2.0. 2-rc2/bin/mongodump
mongodb-linux-i686-2.0. 2-rc2/bin/mongoimport
mongodb-linux-i686-2.0. 2-rc2/bin/mongosniff
mongodb-linux-i686-2.0. 2-rc2/bin/mongo
mongodb-linux-i686-2.0. 2-rc2/bin/mongod
mongodb-linux-i686-2.0. 2-rc2/bin/mongoexport
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;"/>
[Email protected] mongodb]# mkdir log
[Email protected] mongodb]# mkdir data
[[Email protected] mongodb]# CD log
[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;"/>
[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;"/>
[Email protected] mongodb]#/bin/mongod-port 10001 --dbpath data/--logpath log/mongodb.log
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;"/>
[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;"/>
-
[[email protected] mongodb]# ./bin/mongo localhost:< Span class= "number" style= "Color:rgb (192,0,0);" >10001
-
mongodb shell version: 2.0 . 2 -rc2
-
connecting to: localhost:10001 /test
-
>&NBSP;&NBSP;
-
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;"/>
Connecting To:localhost:10001/test
> 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;"/>
> Db.foo.find ()
{ "_id" : ObjectId ("4ee66eb440ef7803a9873d2d"), "A" : 1 }
>
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;"/>
[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;"/>
port=10001
dbpath=data/
Logpath=log/mongodb.log
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;"/>
[Email protected] mongodb]#/bin/mongod-f mongodb.conf
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