MongoDB is a product between a relational database and a non-relational database, and is the most versatile and most like relational database in a non-relational database. The data structure he supports is very loose and is a JSON-like Bjson format, so you can store more complex data types. MONGO's biggest feature is that the query language he supports is very powerful, and its syntax is a bit like an object-oriented query language that almost implements most of the functionality of a relational database single-table query, and also supports indexing of data.
It is characterized by high performance, easy to deploy, easy to use, and easy to store data. The main features are:
- For collection storage, easy to store data for object types.
- Mode of freedom.
- Supports dynamic queries.
- Supports full indexes, including internal objects.
- Support Queries.
- Supports replication and recovery.
- Use efficient binary data storage, including large objects such as video.
- Automatically process fragmentation to support scalability at the cloud level
- Supports multiple languages such as ruby,python,java,c++,php.
- File storage format is Bson (an extension of JSON)
- Accessible over the network
The so-called "set-oriented" (collenction-orented), meaning that data is grouped in a dataset, is called a collection (collenction). Each collection has a unique identifying name in the database and can contain an unlimited number of documents. The concept of a collection is similar to a table in a relational database (RDBMS), unlike it does not need to define any schema (schema).
Mode Freedom (schema-free) means that for files stored in a MongoDB database, we do not need to know any of its structure definitions. If necessary, you can store files of different structures in the same database.
The documents stored in the collection are stored in the form of key-value pairs. The key is used to uniquely identify a document as a string type, whereas a value can be a complex file type in each. We call this storage form Bson (Binary serialized dOcument Format).
The MongoDB server can run on Linux, Windows or OS X platforms, supports 32-bit and 64-bit applications, and the default port is 27017. Recommended to run on 64-bit platforms because MongoDB
The maximum file size supported when running in 32-bit mode is 2GB.
MongoDB stores the data in a file (the default path is:/data/db), which is managed using a memory-mapped file for increased efficiency.
The above is casually picked, in fact, non-traditional non-relational database, now classified into the document database classification, note that 32-bit operating system supports the largest file is 2GB, so large file storage of friends to choose 64-bit system installation. Start our download and install the road.
First, download
MongoDB's official website is: http://www.mongodb.org/
The latest version of MongoDB is downloaded under the Download menu on the official website: http://www.mongodb.org/downloads, http://dl.mongodb.org/dl/win32/x86_64 is a result of Google being blocked , the official Web download button cannot be clicked, because the MONDB official website uses Google's jquery API, so use the following address to download.
MongoDB for. NET Driver Development Kit is located on the official website of the driver menu (including other language development links): Https://github.com/mongodb/mongo-csharp-driver/downloads
Let's start our installation process.
Second, installation
The following default is installed in the C-drive, you can freely installed on which plate.
- Parameter description:
- --port represents the database port, default 27017;
- --dbpath represents the data file storage path, which is generally set to%mongodb_home%data;
- --logpath represents the log file storage path, which is generally set to%mongodb_home%logsmongodb.log;
- --logappend indicates the log append, default is overwrite;
- --directoryperdb represents a directory per db;
1. Unzip the Mongodb-win32-i386-1.8.1.zip, create the path C:\Program Files\mongodb, and copy the extracted bin file to this folder
2.c:\program Files\mongodb set up the Data folder C:\Program Files\mongodb\data, and then set up a Db,log two folders, at this point MongoDB has the following folder
C:\Program Files\mongodb\bin
C:\Program files\mongodb\data\db
C:\Program Files\mongodb\data\log
Create a log file under the log folder MongoDB.log, which is C:\Program Files\mongodb\data\log\mongodb.log
After completing the above work, you are wondering why to create these folders (because the MongoDB installation requires these folders, the default installation is not created, but the files are installed to C:\data\)
3. Introduction of several installation methods
3.1 Program Start mode
Run Cmd.exe into DOS hit interface
> CD C:\Program files\mongodb\bin
> C:\Program files\mongodb\bin>mongod-dbpath "C:\Program files\mongodb\data\db"
Execute this command to create a database file of MongoDB to the C:\Program files\mongodb\data\db directory, and not unexpectedly see a successful prompt sucess the last line of the command
At this point the database has been started, the interface is MONGO startup program, closed after you can directly double-click on the bin Mongod.exe (Note is D, this is the startup program)
After the startup program is turned on, run the Mongo.exe program (note that there is no d), the interface is as follows
Test database Operations
>help (View related information)
>db.foo.insert ({a:1}) (Insert a,1 field value to Foo table, Foo table as default table)
>db.foo.find () (View foo table data)
The results are as follows:
You can see that 3 records were inserted a,cctv,set.
When the Mongod.exe is closed, Mongo.exe will not be able to connect to the database, so every time you want to use the MongoDB database to open the Mongod.exe program, it is more troublesome, next we will
MongoDB installed as a Windows service bar
3.2 Windows Service mode
Run Cmd.exe
> CD C:\Program files\mongodb\bin
> C:\Program files\mongodb\bin>mongod--dbpath "C:\Program files\mongodb\data\db"--logpath "C:\Program files\ Mongodb\data\log\mongodb.log "--install--servicename" MongoDB "
Here MongoDB.log is the log file that was started,--servicename the "MongoDB" service named MongoDB
Run the command successfully for such as:
The time service has been installed successfully, running
>net Start MongoDB (open service)
>net Stop MongoDB (shutdown service)
>
> C:\Program files\mongodb\bin>mongod--dbpath "C:\Program files\mongodb\data\db"--logpath "C:\Program files\ Mongodb\data\log\mongodb.log "--remove--servicename" MongoDB "(delete, note not--install)
Other commands can be found on the help command or official website.
View Services
Run the Bin folder under the Mongo.exe client to test it. The test is the same as 3.1.
3.3 Daemon Mode creation
--fork running MongoDB as daemon, creating a server process
>c:\program files\mongodb\bin>mongod--port 10220--fork--dbpath "C:\Program files\mongodb\data\db"--logpath "C : \program Files\mongodb\data\log\mongodb.log "
Forked process:44086
All output Going To:MongoDB.log
The introduction of these several installations is completed.
4. Stop MongoDB
The most secure way to stop all current operations and save cached data to disk
>user Admin
>db.shutdownserver ();
Of course, we can also close the process directly, but this will cause the data in the cache to be saved to disk without urgency and lost. The next chapter is MONGO for. NET developed.
MongoDB Introduction and download and installation