MongoDB Learning Notes (i)

Source: Internet
Author: User
Tags failover mongodb download

说明:  MongoDB由databases组成,database由collections组成,collection由documents组成,document由fileds组成。MongoDB是异步写数据。
Chapter I environment configuration one, MongoDB introduction
    • Functional characteristics
    • Scope of application
Functional characteristics
官方网址:http://www.mongodb.org/   MongoDB是一个基于分布式文件存储的数据库开源项目。由C++语言编写,旨在为WEB应用提供可护展的高性能数据存储解决方案。  它的特点是可扩展,高性能,易使用,模式自由,存储数据非常方便等,主要功能特性有:  面向文档存储:(类JSON数据模式简单而强大)。 
    1. Efficient traditional storage: supports binary data and large objects such as photos and videos.
    2. Replication and automatic failover: The MONGO database supports data replication between servers, supporting master-slave mode and inter-server replication.
    3. Auto-sharding Auto-sharding supports cloud-scale scalability (in the early alpha phase): Auto-sharding supports a level of database clustering and dynamically adds additional machines.
    4. Dynamic query: It supports rich query expressions. Query directives use a JSON-style tag to easily query objects and arrays embedded in the document.
    5. Full index support: Includes embedded objects and arrays in the document. The query optimizer of MONGO parses the query expression and generates an efficient query plan.
    6. Supports multiple languages such as ruby,python,java,c++,php.

Advantages and Disadvantages

MongoDB as a very popular NoSQL database has a lot of advantages, probably summed up in the following five points.

(1), no mode

MongoDB is a document-type stored database, each row of data is a document, each document can be inconsistent, the number of fields can be different, and is a document stored in Bson way. Bson:short for Bin-ary JSON

(2), high-performance

How is MongoDB's high performance implemented?

This mainly depends on 2 points to solve (and of course there are many others). The 1th is that MongoDB's storage space is pre-allocated. Take 64-bit machines For example, first allocate 64m, fill with 0, then double the size of each file space until 2G, then allocate 2G each time. The advantage of pre-allocation is that you don't need to allocate space every time you store, speeding up storage efficiency. The 2nd is the memory mapping mechanism of MONGODB. MongoDB first writes the data to memory and then asynchronously writes on the hard disk (if it is non-secure mode). MongoDB does not manage memory, it gives the job to the operating system.

(3), easy to expand

MongoDB clusters are easy to scale (simple to add delete nodes) and can support sharding of data. (later chapters will describe in detail how to Shard and how to extend it.)

(4), easy to manage

The management of MongoDB is almost automatic. Automatic failover: When a primary machine in a shard is down, the other machines will automatically elect a machine to be primary. Automatic load balancing: When the data of two shards is very different, the cluster automatically transfers part of the data to the shards with less data.

(5), multi-function

MongoDB has a lot of functions, such as: index, aggregation, Distributed file storage, JS stored procedure, GRIDFS file storage, fixed capacity collection and so on.

The advantages of this, MongoDB also has its limitations or shortcomings, mainly the following two points.

(1), MongoDB occupies a large storage space.

This is mainly determined by three factors. First, MongoDB's spatial pre-allocation method, which allows MongoDB to waste up to no more than the 2g+2g file size space. Second, MongoDB's field name occupies, even the same field, MongoDB will be stored in each document, here will waste a great deal of space. Third, MongoDB deletes the data and does not free up space, but simply records the space as a delete state for reuse.

(2), MongoDB does not have transaction mode, so the transaction requires strict system use caution.

Applicable to the scope of the scenario:
    1. Suitable for real-time inserts, updates and queries, with the replication and high scalability required for real-time data storage of applications.
    2. A persistent caching layer for the information infrastructure.
    3. Suitable for databases made up of dozens of or hundreds of servers. Because MONGO already contains built-in support for the MapReduce engine.
    4. MONGO's Bson data format is ideal for storing and querying in a document format.
Scenario Not applicable:
    1. A highly transactional system.
    2. Traditional business intelligence applications.
    3. A complex SQL query.

Second, MongoDB download and installation
    • Installation steps

Http://www.mongodb.org/downloads, select the appropriate version to download

Installation steps
    1. In (c/d/e/f) disk new Folder MongoDB.
    2. Unzip the downloaded file and copy the bin directory to the folder MongoDB.
    3. Create a new folder under the folder MongoDB data, the folder data under the new folder DB and log (db is the database file, log below the Windows log, will be explained later).
    4. Execute command: "Mongod-auth--dbpath" E:\mongodb\data\db "" creates the MongoDB database file into the E:\mongodb\data\db directory, and the database is started.
Third, MongoDB service management
    • Window Service Registration
    • Service Opening and closing
Window Service Registration

Note: Be sure to open cmd as an administrator. Please refer to the official website for details http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/

Using the command "Mongod--install--servicename mongodb--servicedisplayname mongodb--logpath E:\mongodb\data\log\mongodb.log-- DBPath E:\MongoDB--directoryperdb "registers the window service.

Service Opening and closing

Use the command "net stop MongoDB" to close the MongoDB service.
Use the command "net start MongoDB" to start the MongoDB service.

MongoDB Learning Notes (i)

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.