What is MongoDB
MongoDB is written by the C + + language and is an open source database system based on distributed file storage.
In the case of high load, adding more nodes can guarantee the performance of the server.
MongoDB is designed to provide scalable, high-performance data storage solutions for applications.
MongoDB stores data as a document and data structures consist of key-value (key=>value) pairs.
The MongoDB document (BSON) resembles a JSON object. Field values can contain other documents, arrays, and array of documents.
Features of MongoDB
1. MongoDB provides a document-oriented storage, which is simple and easy to operate.
2. You can set the index of any property in the MongoDB record to achieve a faster sorting.
3. You can create data mirroring either locally or on the network, which makes MongoDB more extensible.
4. If the load increases (requiring more storage space and greater processing power), it can be distributed across other nodes in the computer network this is called sharding.
5. MongoDB supports rich query expressions. Query directives use a JSON-style tag to easily query objects and arrays embedded in the document.
6. MongoDB allows scripts to be executed on the server, which can be written in JavaScript, executed directly on the server, or stored on the server, and can be called directly next time.
7. MongoDB supports a variety of programming languages: ruby,python,java,c++,php,c# and many other languages.
8. Easy to install.
9. Other.
MongoDB Monitoring Tools
MongoDB provides a network and system monitoring tool, Munin, which is used as a plugin in MongoDB.
Gangila is MongoDB's high-performance system monitoring tool, which is used as a plug-in for MongoDB.
The graphical interface-based open source tool, cacti, is used to view CPU load, network bandwidth utilization, and it also provides a plug-in that is used to monitor MongoDB.
MongoDB Graphical user interface (GUI) tools
1. Fang of mongo– web-style, made up of Django and jquery.
2. futon4mongo– a couchdb Futon web of MongoDB Cottage version.
3. Written by Mongo3–ruby.
4. mongohub– applies to OSX applications.
5. opricot– a browser-based MongoDB console, written by PHP.
6. Database Master–windows's MongoDB management tool.
7. rockmongo– the best PHP language for MongoDB management tools, lightweight, multi-lingual support.
8. robomongo– a Shell-based, cross-platform, open source MongoDB management tool (personal recommendation).
Download MongoDB
: Http://www.mongodb.org/downloads
Here is the installation of Mongodb,mongodb under the Windows platform and also supports other platforms such as Osx,linux,solaris.
The version used is 2.6. Since 2.6 is the most familiar version of me, and I am using the GUI tool Robomongo currently does not support version 3.0.
After downloading, follow the prompts to install.
Preparing configuration files and storing directories
Configuration file Mongod.cfg:
Dbpath=c:\mongodb\datalogpath=c:\mongodb\log\mongo.loglogappend=truedirectoryperdb=true#auth=true
Note 1: #号表示注释, we do not use user authentication here.
Note 2: Make sure that the directory specified in the file exists.
Configuration file Parameter Description:
Parameters |
Describe |
--dbpath |
Data file path |
--logpath |
Log file path |
--port |
Port number, default is 27017 |
--logappend |
Log files are recycled, and if the log file is full, the new log is overwritten with the longest log |
--directoryperdb |
Set each database to be saved in a separate directory |
--auth |
User authentication, default false. No authentication is required. When set to true, access to the database requires Auth authentication, and when there are no users in the database, it is not necessary to verify or operate. Until the first user is created, then the action requires validation. |
--replset |
The name of the cluster, if the cluster is used, each node is set to the same name |
Install/Uninstall MongoDB Service
Install: Run cmd as Administrator and execute the following command:
SC create MongoDB binpath= "C:\Program files\mongodb 2.6 standard Legacy\bin\mongod.exe--config=c:\mongodb\mongod.cfg- -service "
Where BinPath is the MongoDB installation directory in bin Mongod.exe,--config is the configuration file mentioned above.
Uninstall: Run cmd as an administrator and execute the following command:
C:\Program FILES\MONGODB 2.6 Standard legacy\bin mongod.exe--remove--servicename "MongoDB"
Start the service:
Installing Robomongo
Download Robomongo First, then follow the prompts to install: Https://www.robomongo.org/download
Open Robomongo:
Click Create to make a connection:
Create a database:
Execute the script in the new library, right-click on the new library, tap "Open Shell", enter Objectid () to get a objectid:
Execute the script and insert the data into the library:
Double-click Country to see the new data:
Toggle View View:
MongoDB Series (i): Introduction and Installation