当你添加一个新的 mongodb 副本时,你怎么知道它什么时候赶上了主人?

When you add a new mongodb replica, how do you know when it has caught up to the master?

如果您向 mongodb 添加一个新副本,您如何知道它是否已赶上主节点或至少赶上其他副本?

您是否将这个新副本添加到您的 mongodb 客户端进行查询,否则这会导致问题?

If you add a new replica to mongodb, how do you know if it has caught up to the master node or at least the other replicas?

来自文档 Add Members to a Replica Set

Ensure that the new member has reached SECONDARY state. To check the state of the replica set members, run rs.status().

另见各种replica set status.


Do you add this new replica to your mongodb clients to query from or this will cause issues?

客户端连接到副本集。默认情况下,所有读写操作都转到主要成员。您的副本集可以配置为可以将读取操作定向到辅助节点 - 通过设置 Read Preference.

您不需要做任何特定的配置来告诉客户端程序访问副本集的新成员。