MongoDB Tour (1) Introduction

Source: Internet
Author: User
MongoDB journey (I) Introduction Postedon has always wanted to understand this field with the rise of Nosql. At the beginning of the new job, I decided to study Mongodb well and I had nothing to do recently. So I would like to summarize the knowledge points to facilitate future use: I. Brief introduction first, mongoDB was initially designed to require a database to be elegantly scalable across multiple machines

MongoDB journey (I) Introduction Posted on has always wanted to know about this field with the rise of Nosql. At the beginning of the new job, I decided to study Mongodb well and I had nothing to do recently. So I would like to summarize the knowledge points to facilitate future use: I. Brief introduction first, mongoDB was initially designed to require a database to be elegantly scalable across multiple machines

MongoDB Tour (1) Introduction to Posted on

With the rise of Nosql, I always want to understand this field. At the beginning of the new job, I decided to study Mongodb well and have nothing to do with it recently. So I would like to briefly summarize the knowledge points and summarize the Hong Kong virtual host for future use:

1. Brief Introduction

First, MongoDB was initially developed for a platform that requires the database to be elastically scalable across multiple machines,

Secondly, MongoDB is designed to store data for Web applications.

One difference is that MongoDB is designed as a horizontally scalable primary data storage system. It also provides a rich and hierarchical data structure for solving complex table associations in relational databases.

Ii. main features of MongoDB

1) MongoDB data models are document-oriented.

This document is basically a set of attribute names and attribute values. Data Type of attribute values: String, number, date, array, or other documents. (Rich structures and no Schema need to be defined, reducing complex logic design of databases and improving application development)

2) instant Query

This means that you do not need to pre-define the types of queries accepted by the system. No doubt, relational databases have the ability to strictly follow the instructions to execute any complete SQL queries. However, not all databases support dynamic queries. MongoDB tries its best to maintain this capability.

3) secondary index

B-tree implementation, VM. In MongoDB, each set can create up to 64 indexes.

4) Copy

In MongoDB, the topology called replica set provides the replication function. Data is distributed across multiple machines to achieve redundancy and provides the automatic failover function, which extends the read capability of the database. It consists of one master node and multiple slave nodes. Here, we will not explain it in detail, but will introduce it in detail later.

5) speed and Durability

In the field of database systems, there is a opposite relationship between write speed and persistence. The write speed can be understood as the number of insert, update, and delete operations that can be processed by the database within a given period of time. Durability refers to the duration of keeping the write operation results unchanged. Therefore, database designers need to weigh the speed and durability to balance the relationship between the two.

In MongoDB, we can choose to write semantics to determine whether to enable Journaling logging. In this way, we can control the balance between speed and durability.

Description of write operations: by default, all write operations in MongoDB are fire-and-forget. That is, write operations are sent over TCP sockets and do not require database responses. If you need to obtain a response, you can use a special security mode to initiate a write operation. All drivers provide this security mode. In MongoDB2.0, the server space and Journaling logs are enabled by default. All write operations are committed to one log that can only be appended. This is the safest way to run MongoDB.

6) database expansion

Vertical Scaling: Increases hardware and costs;

Horizontal scaling: MongoDB's horizontal scaling is very easy to manage. It achieves this design goal through the range-based partitioning mechanism, that is, auto-sharding, the automatic sharding mechanism automatically manages the data distribution between nodes.

Iii. MongoDB core servers and tools

1) core servers

Execute mongod(mongodb.exe on Windows) to run the core server. The mongod server process uses a custom binary protocol to receive commands from a network socket. All data files of the mongod process are stored in/data/db by default. It does not have memory and other parameter configurations, reducing developers' tasks. data files are mapped to the virtual memory of the system through mmap () system calls.

2) Javascript Shell

A Javascript-based tool for managing databases and operating data.

3) command line tool

· Mongodump: stores database data in the native BSON format, which is useful in hot backup. Mongorestore can be easily restored after backup.

· Export: supports JSON, CSV, and TSV data. It can also be used for initial import of large datasets through export import.

· Mongosniff: a network sniffing tool used to observe the operations sent to the database. Basically, BSON transmitted over the network is converted into Shell statements that are easy to read.

· Same stat: similar to iostat. Continuously poll MongoDB and the system to provide helpful statistics, including the number of operations per second (insert, delete, update, query, etc.), the number of allocated virtual memory, and the number of server connections.

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.