I. Introduction
MongoDB is a kind of non relational database (NOSQL), is a powerful, flexible, scalable way of data storage, because MongoDB is a document model, free and flexible, so that you can flow in the development process, for large data, high concurrency, weak business internet applications, MongoDB can handle it freely, MongoDB built-in horizontal scaling provides data processing capabilities from millions to 1 billion levels, support for MapReduce aggregation, and support for geo-spatial indexing.
two. Installation and configuration
1. 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, as shown in the figure:
Step Two: Configure the directory where the logs and data are stored, or MongoDB not start up, as shown in the figure:
We run cmd.exe into the DOS command interface, and then we go into the CD D:\mongodb\bin directory, and we go on to configure the files for the directory where the logs and data are stored, and the commands that we use to view the instructions, as shown in the figure:
We found the (1)--logpath Arg:arg is the path where the log is set (2)--dbpath Arg:arg is the path that holds the data file
First configure the directory of the data, such as I want to store in the D:\mongodb\data\db directory, we run cmd.exe into the DOS command interface, and then into the CD D:\mongodb\bin directory, run the Mongod.exe command, as shown in the figure:
Description: The error is because we need to manually create the D:\mongodb\data\db file path, we create a good path to execute once, this time successful, as shown in the figure:
Configure 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 into the Cdd:\mongodb\bin directory, run mongod.exe command Mongod.exe- -logpath=d:\mongodb\data\log\mongodb.log, as shown in the picture:
Step Three: Test if the configuration is normal
We run cmd.exe into the DOS command interface, and then go to the CD D:\mongodb\bin directory, run the MONGO command, and test the connection, as shown in the picture:
An error occurred
Note: Without starting the server, we need to configure our own MongoDB server, we in the D:\mongodb directory, create a mongodb.config configuration file, there are two attributes LogPath and DBPath, respectively, set the value, is just the path we configured, As shown in the figure:
Mongod.exe--config d:\mongodb\mongodb.config to start the MongoDB server, the--config option indicates that it was started by d:\mongodb\ Configure the server for Mongodb.config configuration file information. As shown in the figure:
this DOS command interface does not close first, the MongoDB server is running, I open a DOS command interface in the new, first enters to the CD D:\mongodb\bin directory, then runs the MONGO command to test the link, as shown in the picture:
This indicates that the configuration was successful.
three. Add MongoDB to Windows Service
We turn off the DOS command interface that runs the MongoDB server so we can't link mongodb, we need to add to the Windows service like MySQL, and then start the service on the command line and turn off the service so we can operate and manage the service.
We will then need to put MongoDB to Windows service and use the command to--install Setup MongoDB for server to Windows service
The first step: the implementation of-install, to the administrator's start cmd, enter the DOS command interface, first into the CD D:\mongodb\bin directory, the implementation of D:\mongodb\bin>mongod.exe--dbpath=d:\mongodb\ Data\db--logpath=d:\mongodb\data\log\log.txt--install--servicename "MongoDB" as shown in the figure:
Step Two: Start/close MongoDB service
Netstart MongoDB Start MongoDB Service
net stop MongoDB start MongoDB suit
Four: Test the shell of MongoDB
Step one: Run Cmd.exe, enter the DOS command interface, go to the CD D:\mongodb\bin directory, run the MONGO command, go into the shell, view the database show DBS, as shown in the picture:
Step two: Switch and generate the database
When you switch a database, if the database does not exist, the database is generated directly, use test: as shown in the figure:
Step three: Create a set Merge to save the data
A collection named Zhengcy was created
Db.zhengcy.insert ({username: ' zcy '})
Step three: Find all the data in the Zhengcy collection
Db.zhengcy.find ()