Replica Set Members 副本集成员介绍
cookqq ›博客列表 ›MongoDB

Replica Set Members 副本集成员介绍

2015-11-25 16:46:05.0|分类: MongoDB|浏览量: 1718

摘要: Primary. 主副本 The primary receives all write operations. 提供所有写操作 Secondaries. 次副本 Secondaries replicate operations from the primary to maintain an identical data set. Secondaries may have additional configurations for special usage profiles. For example, secondaries may be non-voting orpriority 0. You can also maintain 保持 an arbiter as part of a replica set. Arbiters do not keep a copy of the data . However, arbiters play a role in the elections that select a primary if the current primary is unavailable. Arbiters 不保持数据,当主副本不能工作时候,Arbiters 作为选举(主副本)角色

Replica Set Members

简单介绍:primary. 主副本  提供所有写操作 

Secondaries. 次副本 

Arbiters 不保持数据,当主副本不能工作时候,Arbiters 作为选举(主副本)角色



A replica set in MongoDB is a group of mongod processes that provide redundancy冗余 and high availability 高可用. The members of a replica set are:

  • Primary. 主副本

  • The primary receives all write operations. 提供所有写操作

  • Secondaries. 次副本

  • Secondaries replicate operations from the primary to maintain an identical data set. Secondaries may have additional configurations for special usage profiles. For example, secondaries may be non-voting orpriority 0.

You can also maintain 保持 an arbiter as part of a replica set. Arbiters do not keep a copy of the data . However, arbiters play a role in the elections that select a primary if the current primary is unavailable.

Arbiters 不保持数据,当主副本不能工作时候,Arbiters 作为选举(主副本)角色

A replica set can have up to 12 members. [1] However, only 7 members can vote at a time.

The minimum requirements for a replica set are: A primary, a secondary, and an arbiter. Most deployments, however, will keep three members that store data: A primary and two secondary members.

Primary

The primary is the only member in the replica set that receives write operations. MongoDB applies write operations on the primary and then records the operations on the primary’s oplog. Secondary members replicate 复制 this log and apply the operations to their data sets.

In the following three-member replica set, the primary accepts all write operations. Then the secondaries replicate the oplog to apply to their data sets.

Diagram of default routing of reads and writes to the primary.

All members of the replica set can accept read operations. However, by default, an application directs its read operations to the primary member. See Read Preference for details on changing the default read behavior.

所有的成员都可以进行读操作

The replica set can have at most one primary. [2] If the current primary becomes unavailable, an election determines the new primary. See Replica Set Elections for more details.

Secondaries

A secondary maintains a copy of the primary’s data set. To replicate data, a secondary applies operations from the primary’s oplog to its own data set in an asynchronous process. A replica set can have one or more secondaries.

The following three-member replica set has two secondary members. The secondaries replicate the primary’s oplog and apply the operations to their data sets.

Diagram of a 3 member replica set that consists of a primary and two secondaries.

Although clients cannot write data to secondaries, clients can read data from secondary members. See Read Preference for more information on how clients direct read operations to replica sets.

A secondary can become a primary. If the current primary becomes unavailable, the replica set holds anelection to choose which of the secondaries becomes the new primary.

See Replica Set Elections for more details.

You can configure a secondary member for a specific purpose. You can configure a secondary to:

  • Prevent 防止 it from becoming a primary in an election, which allows it to reside in a secondary data center or to serve as a cold standby. See Priority 0 Replica Set Members.

  • Prevent applications from reading from it, which allows it to run applications that require separation from normal traffic.  See Hidden Replica Set Members.

  • Keep a running “historical” snapshot for use in recovery from certain errors, such as unintentionally deleted databases. See Delayed Replica Set Members.

    保持一个运行的“历史”快照用于恢复从某些错误,如无意中删除的数据库

Arbiter

An arbiter does not have a copy of data set and cannot become a primary. Replica sets may have arbiters to add a vote in elections of for primary. Arbiters allow replica sets to have an uneven number of members, without the overhead of a member that replicates data.

IMPORTANT

Do not run an arbiter on systems that also host the primary or the secondary members of the replica set.

Only add an arbiter to sets with even numbers of members. If you add an arbiter to a set with an odd number of members, the set may suffer from tied elections. To add an arbiter, see Add an Arbiter to Replica Set.

[1]While replica sets are the recommended solution for production, a replica set can support only 12 members in total. If your deployment requires more than 12 members, you’ll need to use master-slave replication. Master-slave replication lacks the automatic failover capabilities.
[2]In some circumstances, two nodes in a replica set may transiently believe that they are the primary, but at most, one of them will be able to complete writes with {w: majority} write concern. The node that can complete {w: majority} writes is the current primary, and the other node is a former primary that has not yet recognized its demotion, typically due to anetwork partition. When this occurs, clients that connect to the former primary may observe stale data despite having requested read preference primary.


一键分享文章

分类列表

  • • struts源码分析
  • • flink
  • • struts
  • • redis
  • • kafka
  • • ubuntu
  • • zookeeper
  • • hadoop
  • • activiti
  • • linux
  • • 成长
  • • NIO
  • • 关键词提取
  • • mysql
  • • android studio
  • • zabbix
  • • 云计算
  • • mahout
  • • jmeter
  • • hive
  • • ActiveMQ
  • • lucene
  • • MongoDB
  • • netty
  • • flume
  • • 我遇到的问题
  • • GRUB
  • • nginx
  • • 大家好的文章
  • • android
  • • tomcat
  • • Python
  • • luke
  • • android源码编译
  • • 安全
  • • MPAndroidChart
  • • swing
  • • POI
  • • powerdesigner
  • • jquery
  • • html
  • • java
  • • eclipse
  • • shell
  • • jvm
  • • highcharts
  • • 设计模式
  • • 列式数据库
  • • spring cloud
  • • docker+node.js+zookeeper构建微服务
版权所有 cookqq 感谢访问 支持开源 京ICP备15030920号
CopyRight 2015-2018 cookqq.com All Right Reserved.