On this page
MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling.
Document Database
A record in MongoDB is a document, which is a data structure composed of field and value pairs. MongoDB documents are similar to JSON objects. The values of fields may include other documents, arrays, and arrays of documents.
The advantages of using documents are:
- Documents (i.e. objects) correspond to native data types in many programming languages.
- Embedded documents and arrays reduce need for expensive joins.
- Dynamic schema supports fluent polymorphism.
Key Features
High Performance
MongoDB provides high performance data persistence. In particular,
- Support for embedded data models reduces I/O activity on database system.
- Indexes support faster queries and can include keys from embedded documents and arrays.
Rich Query Language
MongoDB supports a rich query language to support read and write operations (CRUD) as well as:
High Availability
MongoDB’s replication facility, called replica set, provides:
- automatic failover and
- data redundancy.
A replica set is a group of MongoDB servers that maintain the same data set, providing redundancy and increasing data availability.
Horizontal Scalability
MongoDB provides horizontal scalability as part of its core functionality:
- Sharding distributes data across a cluster of machines.
- Starting in 3.4, MongoDB supports creating zones of data based on the shard key. In a balanced cluster, MongoDB directs reads and writes covered by a zone only to those shards inside the zone. See the Zones manual page for more information.
Support for Multiple Storage Engines
MongoDB supports multiple storage engines, such as:
In addition, MongoDB provides pluggable storage engine API that allows third parties to develop storage engines for MongoDB.
MongoDB 是一个开源的文档数据库,提供高性能、高可用性、自动缩放。
文档数据库 (Document Database)
在MongoDB中记录是一个文档,这是一个数据结构由字段和值对。MongoDB文档类似于JSON对象。字段的值可以包括其他文档、数组和文档数组。
使用文档的优点是:
- 文档(即对象)与许多编程语言中的数据类型相一致。
- 嵌入的文档和数组减少了昂贵连接的需要。
- 动态模式支持流利多态性。
主要特点(Key Features)
高性能(High performance)
MongoDB提供高性能的数据持久性。特别的
- 对嵌入式数据模型的支持降低了数据库系统的I/O活动。
- 索引支持更快的查询,并且可以包含来自嵌入式文档和数组的键。
丰富的查询语言 (Rich Query Language)
MongoDB支持丰富的查询语言支持读写操作(CRUD)以及:
- 数据聚集
- 文本搜索和地理空间查询。
高可用 (High Availability)
MongoDB的复制工具,称为复制集,提供:
- 自动故障转移
- 数据冗余。
副本集是一组MongoDB服务器保持相同的数据集,提供冗余,提高了数据的可用性。
横向扩展 (Horizontal Scalability)
MongoDB提供的水平可扩展性作为其核心功能的一部分:
- 分片的数据分布在集群中的机器。
- 从3.4开始,MongoDB支持创建基于碎片的关键数据区。在一个平衡的集群,MongoDB直接读取和写入的区域,只有那些碎片覆盖区内。
支持多个存储引擎 (Support for Multiple Storage Engines)
MongoDB支持多种存储引擎,如:
- wiredtiger存储引擎
- mmapv1存储引擎。
此外,MongoDB提供了可插拔的存储引擎API,允许第三方开发的MongoDB存储引擎。