On this page本页内容
To rename a replica set, you must shut down all members of the replica set, then configure each member's 要重命名副本集,必须关闭副本集的所有成员,然后使用新的副本集名称配置每个成员的local
database with the new replica set name.local
数据库。
This procedure requires downtime.此过程需要停机。
Follow the procedure in Stop a Replica Set to confirm that replica set members are shut down.按照停止副本集中的步骤确认副本集成员已关闭。
This step requires downtime as all replica members will need to be shut down.此步骤需要停机,因为所有复制副本成员都需要关闭。
Perform the following steps for each replica set member:对每个副本集成员执行以下步骤:
Update the replica set name.更新副本集名称。
replication.replSetName
to the new name.replication.replSetName
设置为新名称。mongod
startup command with the --replSet
option, note down the new replica set name for use in step f.--replSet
选项的mongod
启动命令,请记下新的副本集名称,以便在步骤f中使用。--replSet
option.--replSet
选项的其他端口上启动副本集成员。Update the replica set name in the local database with the following commands:使用以下命令更新local
数据库中的副本集名称:
/* Set `newId` to the new replica set name */ var newId = '<new replica set name>' var doc = db.getSiblingDB("local").system.replset.findOne() var oldId = doc._id doc._id = newId db.getSiblingDB("local").system.replset.save(doc) db.getSiblingDB("local").system.replset.remove({_id: oldId})
Start the replica set member on its original port.在其原始端口上启动复制集成员。
replication.replSetName
is set to the new replica set name.replication.replSetName
设置为新的副本集名称。mongod
startup command with the --replSet
option, pass the new name of the replica set to the --replSet
option.--replSet
选项的mongod
启动命令,请将副本集的新名称传递给--replSet
。