I. INTRODUCTION
MongoDB is a non-relational database (NOSQL), is a powerful, flexible, scalable data storage, because MongoDB is a document model, free and flexible, so that you can be smooth in the development process, for large data volumes, high concurrency, weak transactions of the Internet applications, MongoDB can handle it, and MongoDB's built-in horizontal scaling mechanism provides the ability to handle data volumes from millions to 1 billion levels, support for MapReduce aggregation, and support for geospatial indexes.
two. Installation and configuration1. Download and install
Http://www.mongodb.org/downloads
My system is Windows7 32 bit, so I download the corresponding version Mongodb-win32-i386-2.6.8.zip
2. Installation and Configuration
The first step: Extract to a disk, such as my extracted directory D:\mongodb,:
Step Two: Configure the directory where logs and data are stored, or MongoDB does not start up:
We first run the Cmd.exe into the DOS command interface and then go to the CD D:\mongodb\bin directory, and we will then proceed to configure the files for the directory where the logs and data are stored, and we can view which commands by the help command:
We found it. (1)--logpath Arg:arg is the path where the log is set (2)--dbpath Arg:arg is the path where the data file is stored
First configure the data directory, for example I want to store in D:\mongodb\data\db this directory, we run cmd.exe into the DOS command interface, and then into the CD D:\mongodb\bin directory, run the Mongod.exe command,:
Note: The error is because we need to manually create the D:\mongodb\data\db file path, we created a good path in the execution once, this time, the success:
Configure the log path, for example I want to store in D:\mongodb\data\log This directory, we are running Cmd.exe into the DOS command interface, and then go to Cdd:\mongodb\bin directory, run mongod.exe command Mongod.exe- -logpath=d:\mongodb\data\log\mongodb.log,:
Step Three: Test if the configuration is OK
We run cmd.exe into the DOS command interface, then go to the CD D:\mongodb\bin directory, run the MONGO command, test the connection:
Error occurred
Note: Without starting the server, we need to configure the MongoDB server ourselves, in the D:\mongodb directory, we create a mongodb.config configuration file, there are two properties LogPath and DBPath, respectively, set the value, This is the path we configured just now:
Mongod.exe--config d:\mongodb\mongodb.config to start the MongoDB server, the--config option means to start with d:\mongodb\ Configure the server for Mongodb.config configuration file information. :
this DOS command interface does not shut down, MongoDB server is running, I opened a new DOS command interface, first go to the CD D:\mongodb\bin directory, and then run the MONGO command to test the link:
This indicates that the configuration was successful.
three. Add MongoDB to Windows Service
We turned off the DOS command interface running the MONGODB server so that we could not link mongodb, we needed to add to the Windows service like MySQL, and then start the service on the command line and shut down the service so that we could operate and manage the service.
Next we need to put MongoDB to Windows service, the command used is--install Setup to install MongoDB for server to Windows service
The first step: Execute-install, to the administrator's start cmd, into the DOS command interface, first into the CD D:\mongodb\bin directory, execute
d:\mongodb\bin>mongod.exe--dbpath=d:\mongodb\data\db--logpath=d:\mongodb\data\log\log.txt--install- -servicename "MongoDB":
Step Two: Start/close MongoDB service
Netstart MongoDB Start MongoDB Service
net stop MongoDB boot MongoDB service
Four: Test the MongoDB shell
First step: Run cmd.exe, enter the DOS command interface, go to the CD D:\mongodb\bin directory, run the MONGO command, enter the shell, view the database show DBS,:
Step two: Switch and generate the database
When switching the database, if the database does not exist, the database is directly generated, use test::
Step three: Create a set Merge to save the data
A collection named Zhengcy is created
Db.zhengcy.insert ({username: ' zcy '})
Step three: Find all the data in the Zhengcy collection
Db.zhengcy.find ()
MongoDB-1: Installation and Configuration