翻译或纠错本页面

Replace a Config Server

重要

In version 3.4, MongoDB removes support for SCCC config servers. To upgrade your config servers from SCCC to CSRS, see Upgrade Config Servers to Replica Set.

集群使用三个配置服务器存储集群的元信息,只有这三个配置服务器都可用时,集群的元信息才可以概念,包括数据块分裂与数据块迁移.如果一个配置服务器不能访问或者出现故障,应该尽快替换掉.

这篇教程用来替换集群中损坏的配置服务器.只有在配置服务器不能操作时(比如,硬件损坏)时才使用这篇教程.

Overview

这个过程假设配置服务器的域名不发生概念,如果必须要改变配置服务器的域名,使用 迁移配置服务器到新的域名.

If one of the config servers is unavailable or inoperable, repair or replace it as soon as possible. The following procedure replaces a member of a config server replica set with a new member.

The tutorial is specific to MongoDB 3.4. For earlier versions of MongoDB, refer to the corresponding version of the MongoDB Manual.

Considerations

The following restrictions apply to a replica set configuration when used for config servers:

  • Must have zero arbiters.
  • Must have no delayed members.
  • Must build indexes (i.e. no member should have buildIndexes setting set to false).

Procedure

1

Start the replacement config server.

Start a mongod instance, specifying both the --configsvr and --replSet options.

mongod --configsvr --replSet <replicaSetName>
2

Add the new config server to the replica set.

Connect a mongo shell to the primary of the config server replica set and use rs.add() to add the new member.

rs.add("<hostnameNew>:<portNew>")

The initial sync process copies all the data from one member of the config server replica set to the new member without restarting.

mongos instances automatically recognize the change in the config server replica set members without restarting.

3

Shut down the member to replace.

If replacing the primary member, step down the primary first before shutting down.

4

Remove the member to replace from the config server replica set.

Upon completion of initial sync of the replacement config server, from a mongo shell connected to the primary, use rs.remove() to remove the old member.

rs.remove("<hostnameOld>:<portOld>")

mongos instances automatically recognize the change in the config server replica set members without restarting.

5

If necessary, update mongos configuration or DNS entry.

With replica set config servers, the mongos instances specify in the --configdb or sharding.configDB setting the config server replica set name and at least one of the replica set members.

As such, if the mongos instance does not specify the removed replica set member in the --configdb or sharding.configDB setting, no further action is necessary.

If, however, a mongos instance specified the removed member in the --configdb or configDB setting, either:

  • Update the setting for the next time you restart the mongos, or
  • Modify the DNS entry that points to the system that provided the old config server, so that the same hostname points to the new config server.