How MongoDB is used

Source: Internet
Author: User
Tags mongodb

1 Start the MongoDB service (also specify the folder that holds the "database")

MongoDB can only be used when the service is started by MongoDB, usually with a command window open, enter the following command to start the service (you can also register the service in Windows and start it in service Management): F:\Mongo3.0.11\ Bin>mongod-dbpath "F:\Mongo3.0.11\mydb"

where "MyDB" is the folder where all the database files created by the user are stored (the database in MongoDB is database, "Databases", "collections" i.e. collections, "documents").

This means that the MongoDB service is turned on and all the data that the user operates is stored under the "mydb" file. After the service is started, MongoDB will create the following in the empty file MyDB, which is automatically created by MongoDB, do not move:


Use the visualizer Robomongodb to view all the data under the "mydb" folder , as follows:




In the image above, I created two new databases "111" and "MyDB" under the "MyDB" folder, and a new user collection under the "111" database with a document {name: ' Willson ', Gender: ' Man ', Age: '},_id ' is the ID generated by MongoDB itself.

After creating a new two database "111" and "MyDB", MongoDB stores the folder for the data files, changing as follows:


Description

Each database has corresponding data files and namespace files. The prefix of the file is the name of the database, the suffix . NS represents the namespace file, and the suffix ends with a number of . 0,. 1 , indicating the data file.

The size of the data file starts at 64MB (this is the result that you see on 64-bit Windows Server 2012, other environments may differ), and the new data file is one-fold larger than the previous file. So can see that the size of the chen.0 is 64mb,chen.1 size is 128mb,chen.2 is 256MB.

The file uses mmap for memory mapping, which maps all data files into memory, but only virtual memory, which is only exchanged in material memory when the data is accessed.

Each data file is divided into one block of data, and the block is connected to the block by a two-way chain.

In the namespace file, the stored information metadata for each namespace is saved, including its size, number of blocks, the position of the first block, the position of the last piece, the linked list of deleted blocks, and the index information.

=============================== Summary ===============================================


So using MongoDB is simple, just turn the service on (but MongoDB only allows a MongoDB service to open at some time, so if a service is already open, the new service cannot be opened). When the service is turned on, all user-manipulated data is placed at the start of the service and the specified DBPath is "MyDB" above.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.