Docs HomeMongoDB Manual

FAQ: Replication and Replica Sets常见问题解答:复制和副本集

This document answers common questions about replication in MongoDB. See also the Replication section in the manual, which provides an overview of replication including details on:本文档回答了有关MongoDB中复制的常见问题。另请参阅手册中的复制部分,该部分概述了复制,包括以下方面的详细信息:

What kind of replication does MongoDB support?MongoDB支持什么样的复制?

MongoDB supports Replica sets, which can have up to 50 nodes.MongoDB支持副本集,副本集最多可以有50个节点

Does replication work over the Internet and WAN connections?复制是否可以通过Internet和WAN连接进行?

Yes.

For example, a deployment may maintain a primary and secondary in an East-coast data center along with a secondary member for disaster recovery in a West-coast data center.例如,部署可以在东海岸数据中心维护primarysecondary,以及在西海岸数据中心中维护用于灾难恢复的secondary

Can MongoDB replicate over a "noisy" connection?MongoDB可以通过“嘈杂”的连接进行复制吗?

Yes, but not without connection failures and the obvious latency.是的,但并非没有连接故障和明显的延迟。

Members of the set will attempt to reconnect to the other members of the set in response to networking flaps. This does not require administrator intervention. However, if the network connections among the nodes in the replica set are very slow, it might not be possible for the members of the node to keep up with the replication.该集合的成员将尝试重新连接到该集合的其他成员以响应网络襟翼。这不需要管理员干预。但是,如果复制集中节点之间的网络连接非常慢,则节点的成员可能无法跟上复制。

Tip

See also:另请参阅:

Why use journaling if replication already provides data redundancy?如果复制已经提供了数据冗余,为什么要使用日志记录?

Journaling facilitates faster crash recovery.日志记录有助于更快地进行故障恢复。

Journaling is particularly useful for protection against power failures, especially if your replica set resides in a single data center or power circuit.日志记录对于防止电源故障特别有用,尤其是当您的复制集位于单个数据中心或电源电路中时。

When a replica set runs with journaling, you can safely restart mongod instances without additional intervention.副本集使用日志运行时,您可以安全地重新启动mongod实例,而无需额外干预。

Note

Journaling requires some resource overhead for write operations. Journaling has no effect on read performance, however.日志记录需要一些写操作的资源开销。但是,日志记录对读取性能没有影响。

Journaling is enabled by default on all 64-bit builds of MongoDB v2.0 and greater.默认情况下,MongoDB v2.0及更高版本的所有64位版本都启用日志记录。

What information do arbiters exchange with the rest of the replica set?仲裁器与副本集的其余部分交换什么信息?

Arbiters never receive the contents of a collection but do exchange the following data with the rest of the replica set:Arbiter从不接集合合的内容,而是与副本集的其余部分交换以下数据:

  • Credentials used to authenticate the arbiter with the replica set. These exchanges are encrypted.用于使用副本集对仲裁器进行身份验证的凭据。这些交换是加密的。
  • Replica set configuration data and voting data. This information is not encrypted. Only credential exchanges are encrypted.副本集配置数据和投票数据。此信息未加密。只有凭证交换是加密的。

If your MongoDB deployment uses TLS/SSL, then all communications between arbiters and the other members of the replica set are secure.如果您的MongoDB部署使用TLS/SSL,那么仲裁器和副本集的其他成员之间的所有通信都是安全的。

See the documentation for Configure mongod and mongos for TLS/SSL for more information. As with all MongoDB components, run arbiters on secure networks.有关更多信息,请参阅为TLS/SSL配置mongodmongos的文档。与所有MongoDB组件一样,在安全网络上运行仲裁器。

Is it normal for replica set members to use different amounts of disk space?复制副本集成员使用不同数量的磁盘空间是否正常?

Yes.

Factors including: different oplog sizes, different levels of storage fragmentation, and MongoDB's data file pre-allocation can lead to some variation in storage utilization between nodes. Storage use disparities will be most pronounced when you add members at different times.不同的oplog大小、不同级别的存储分片以及MongoDB的数据文件预分配等因素可能会导致节点之间的存储利用率存在一定差异。当您在不同时间添加成员时,存储使用差异将最为明显。

Can I rename a replica set?我可以重命名复制副本集吗?

Yes, unsharded replica sets can be renamed. This procedure requires downtime.可以,可以重命名未排序的复制副本集。此过程需要停机。

To learn how to rename your replica set, see Rename a Replica Set.要了解如何重命名副本集,请参阅重命名副本集

Before renaming a replica set, perform a full backup of your MongoDB deployment.在重命名副本集之前,请对MongoDB部署执行完整备份