MongoDB Tutorial: MongoDB cluster and replica set

Source: Internet
Author: User
Tags install mongodb mongodb tutorial

MongoDB Tutorial: MongoDB cluster and replica set

Concepts

For MongoDB Data Disaster Tolerance, the recommended mode is the replica set mode. It has an external Primary server Primary and N replica servers Secondary (N> = 1, when N = 1, an arbitration server (Arbiter) is required. When N> 1, Arbiter is not required. They were previously synchronized through internal mechanisms. When Primary crashes, it uses the internal heartbeat mechanism to elect another Secondary to become a Primary and communicate with the outside world (Route.

Industrial Standards

In terms of standards, we recommend that you use an odd number of servers (,) in the replica set. However, after my test, it is acceptable to have more than two servers, we have three servers for both the route server and config server, so that after one of them is down, you can direct the routes from the other two, but the configuration information is not used much, information is obtained from the configuration machine only when the host is started.

Replica Set

Replica Set uses n mongod nodes to build a high-availability solution with auto-failover and auto-recovery. You can also use Replica Set to implement read/write splitting. By specifying slaveOk during connection or in the master database, Secondary will share the read pressure. Primary will only perform write operations, the secondary node in the Replica Set is unreadable by default. We can configure it to implement its Read and Write function (state: 1 can be read and written, state: 2 cannot be read and written ), if you do not want secondary to never become primary, you can use Priority: 0, that is, it has a Priority of 0, and it will never become the master node.

Secondary read/write configuration: state: 1 can be read and written, state: 2 can not read and write

Secondary's arbitration configuration: arbiterOnly: true

Secondary Priority configuration (the possibility of becoming primary): Priority: 3. A larger number indicates a higher Priority.

Secondary won't let it vote: votes: 0;

Design a cluster by yourself

The figure above is just a logical architecture diagram of a cluster, but the physical architecture is still different (that is, the deployment of each server and the relationship between servers). For clusters with two slices, the physical architecture may require four servers, and two servers use the primary of the replica set to read, write, and store s and c (s refers to the routing service, and c refers to the configuration service ), two secondary and Arbiter for the replica set, and deploy them in the same way.

In fact, the architecture diagram above is just a description. We need to configure and operate it on our own. Only when the operation has passed can we have the right to speak! Haha!

MongoDB 3.0 official version released and downloaded

CentOS compilation and installation of MongoDB

CentOS compilation and installation of php extensions for MongoDB and mongoDB

CentOS 6 install MongoDB and server configuration using yum

Install MongoDB2.4.3 in Ubuntu 13.04

MongoDB beginners must read (both concepts and practices)

MongoDB Installation Guide for Ubunu 14.04

MongoDB authoritative Guide (The Definitive Guide) in English [PDF]

Nagios monitoring MongoDB sharded cluster service practice

Build MongoDB Service Based on CentOS 6.5 Operating System

MongoDB details: click here
MongoDB: click here

This article permanently updates the link address:

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.