1. What is MongoDB?
It is a NoSQL database between relational database and non-relational database, written in C + +, is a high-performance document-oriented universal database which integrates agility, scalability and extensibility.
2. Why use MongoDB?
It has some of the following characteristics:
A) flexible document data Model
It is very easy to store data of different structure, and also can modify the source structure mode of the data dynamically.
b), Scalable extensibility
From a single server to thousands of nodes, MongoDB can easily scale horizontally and deploy multiple data centers
c), Level two index
Includes indexes, geospatial, Text Search, and TTL indexes on any field that are fully consistent, enabling fast, granular access to data
d), rich query language
MongoDB's query language provides a variety of field-level operators, data types, and instant updates. Almost all programming language drivers are available to make it more intuitive to use.
e), robust operating tools
MongoDB's management services and operations management tools make it easy to deploy, monitor, backup, and plan it
3. When to use MongoDB?
Here are a few use cases:
A), the need to write large amounts of data, but the value of these data is not too high, such as: Log
b), data growth is large, and the structure is sometimes inconsistent
c), the future data will be very large
4. MongoDB Installation and Deployment
: http://www.mongodb.org/downloads, note there are 32-bit and 64-bit points, 32 of the database maximum capacity cannot exceed 2gb!
The blogger system is a Win8.1 64-bit system, so here is the installation and deployment of MongoDB with the latest version (3.03) as an example of this system!
A), download the 64-bit MSI installation file and double-click to install it.
Ⅰ, direct next into the next step:
Ⅱ, tick "I accept ...", you know, Next:
Ⅲ, the first option: Complete (full version), the default installation of all features to C drive; the second option custom (custom), you can choose to install directories and services. Here we choose Custom:
Ⅳ, default full feature installation, select Browse to replace the installation directory to F:\MongoDB (own selection,) Next, then select Install to start the installation:
Ⅴ, Installation Complete!
Ⅶ, open the Bin folder under the MongoDB directory, you will see a lot of exe executable files, briefly introduced under:
b), start deployment:
Ⅰ, first we create a new DB folder under the installation directory (F:\MongoDB) as the database storage path, and then use the server-side file as the database directory!
Win+r, enter cmd, enter the DOS command window, and then use the CD command to enter the F:\mongodb:\bin directory, execute the following command:
F:\mongodb\bin>mongod.exe--dbpath F:\MongoDB\db
Will output server-side related information, including version, database location, listening port number, database size and so on, see this note you have succeeded,
or enter in the browser: http://localhost:27017/, you will see the following passage,
It looks like you is trying to access MongoDB over HTTP on the native driver port.
"Trying to link MongoDB with HTTP on a local drive port" can also indicate that you have successfully configured the server!
Ⅱ, start the MongoDB client into the shell,
After the server has been configured successfully, we do not close this Server DOS window, otherwise it is unable to connect!
We open another command window, enter into the F:\mongodb:\bin, enter the Mongo.exe command to connect to the database,
See this note that the client has successfully connected to the server, then you can use a variety of MONGODB commands in the shell!!
If the server does not open, there will be an error that cannot be connected as follows:
c), add MongoDB service to the system
At this point, then someone will say, I can not always use the client to maintain a Server DOS window open it? The answer is certainly not!
Let's try adding a MongoDB service:
Ⅰ, we create a new log folder in the F:\MongoDB directory to hold the log file, and then the key win+x+a to open the Administrator command prompt.
Ⅱ, use the following command to create the configuration file mongod.cfg:
C:\windows\system32>echo logpath=f:\mongodb\log\mongod.log> "F:\MongoDB\mongod.cfg"
C:\windows\system32>echo dbpath=f:\mongodb\db>> "F:\MongoDB\mongod.cfg"
Ⅲ, OK, the preparation is done, the next most important step is to create a MongoDB service using the SC command:
C:\windows\system32>sc.exe Create MongoDB binpath= "F:\MongoDB\bin\mongod.exe--service--config=f:\mongodb\ Mongod.cfg "
The following creation service success prompt appears:
Ⅳ, open service:
Use the following command: C:\windows\system32>net start MongoDB to open MongoDB service! See this statement that you have succeeded,
Then Win+r, enter services.msc to open the list of Windows services, and you will see a service named MongoDB with a status of "Running",
So far you can start MongoDB from the service and then use its service without having to keep another DOS window on the server!
Ⅴ, shutting down services and deleting services
Close the service using the following command:
C:\windows\system32>net Stop MongoDB
The Delete service uses the following command:
C:\windows\system32>sc.exe Delete MongoDB
Common error resolution when starting up:
There was a problem installing the database MongoDB, the service did not respond to the control function, or a system error 2 occurred.
The problem is that if you've already installed it once, and two times the installation directory is different, you'll definitely encounter it, because the path you installed earlier has been generated in the registry and has not been purged with your uninstallation.
If you do it again, it's not going to work, and it's definitely the problem that the service doesn't start up. Don't believe you can run command services.msc, or directly on my computer or computer right-click into the service, you can see the path of the executable file in the General column is definitely not the path you installed this time, is the first time you install the file path.
You can try the SC command, but my test is not very successful, so simply modify the registry directly.
To enter the registry through Regedit, we first find the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services, and then find the name of the program we want to install, such as my is MongoDB, There is a imagepath on the right, click to open the change.
If you do not start, please make sure you change the right, because my carelessness, changed the front, forgot to change the back.
Error 100 and 48
Generally when running net start MongoDB it may be reported 100 or 48 error, this time go to your MongoDB folder to find the previous log file, Mongodb.log, in which you will see the cause of your error, I listed here a few common errors:
1. When the port is occupied you can change the port that is set when it is turned on, or find a service that consumes ports to turn it off
2. DBPath and LogPath may not be set up: The service will be in a successful state to open the failed state repeatedly
3. Perhaps due to the last abnormal shutdown MongoDB caused MongoDB to be locked, find the Data\db\mongodb.lock file to delete it (if the deletion fails, you can ctrl+a/t+delete, open the control window to close the prompt to delete the file, Servers that are running).
MongoDB downloads, installs, and deploys