- Sharding >
- Sharded Cluster Administration >
- Sharded Cluster Config Server Administration >
- Upgrade Config Servers to Replica Set
Upgrade Config Servers to Replica Set¶
On this page
Important
In version 3.4, MongoDB removes support for SCCC config servers. Before you can upgrade your sharded clusters to 3.4, you must convert your config servers from SCCC to CSRS. To convert to CSRS, follow the procedure to change your 3.2.x SCCC to 3.2.x CSRS.
The following procedure upgrades three mirrored config servers to a config server replica set without downtime. To use this procedure, all the sharded cluster binaries must be at least version 3.2.4.
During this procedure there will be a period of time where the config servers will be read-only. During this period, certain catalog operations will fail if attempted. Operations that will not be available include adding and dropping shards, creating and dropping databases, creating and dropping sharded collections, and migrating chunks (both manually and via the balancer process). Normal read and write operations to existing collections will not be affected.
Prerequisites¶
- All binaries in the sharded clusters must be at least version 3.2.4. See Upgrade a Sharded Cluster to 3.2 for instructions to upgrade the sharded cluster.
- The existing config servers must be in sync.
Procedure¶
Note
The procedure refers to the first config server, second config
server, and the third config server as listed in the
configDB setting of the mongos. This
means, that for the following example:
- The first config server refers to
confServer1. - The second config server refers to
confServer2. - The third config server refers to
confServer3.
Disable the balancer as described in Disable the Balancer.
Connect a
mongoshell to the first config server listed in theconfigDBsetting of themongosand runrs.initiate()to initiate the single member replica set._idcorresponds to the replica set name for the config servers.configsvrmust be set totrue.versionmust be set to1.membersarray contains a document that specifies:members._idwhich is a numeric identifier for the member.members.hostwhich is a string corresponding to the config server’s hostname and port.
Restart this config server as a single member replica set with:
- the
--replSetoption set to the replica set name specified during thers.initiate(), - the
--configsvrModeoption set to the legacy config server mode Sync Cluster Connection Config (sccc), - the
--configsvroption, - the
--storageEngineoption set to the storage engine used by this config server. For this upgrade procedure, the existing config server can be using either MMAPv1 or WiredTiger, and - the
--portoption set to the same port as before restart, and - the
--dbpathoption set to the same path as before restart.
Include additional options as specific to your deployment.
Important
The config server must use the same port as before. [1]
Or if using a configuration file, specify the:
sharding.clusterRole,sharding.configsvrMode,replication.replSetName,storage.dbPath,storage.engine, andnet.port.
[1] If before the restart, your config server did not explicitly specify the
--configsvroption or the--portoption, the restart with the--configsvrwill result in a change of port.To ensure that the port used by the config server does not change, include the
--portoption ornet.portset to the same port as before the restart.- the
Start the new
mongodinstances to add to the replica set. These instances must use the WiredTiger storage engine. Starting in 3.2, the default storage engine is WiredTiger for newmongodinstances with new data paths.Important
- Do not add existing config servers to the replica set.
- Use new dbpaths for the new instances.
The number of new
mongodinstances to add depends on the config server currently in the single-member replica set:- If the config server is using MMAPv1, start 3 new
mongodinstances. - If the config server is using WiredTiger, start 2 new
mongodinstances.
Note
The example in this procedure assumes that the existing config servers use MMAPv1.
For each new
mongodinstance to add, include the--configsvrand the--replSetoptions:Or if using a configuration file:
Using the
mongoshell connected to the replica set config server, add the newmongodinstances as non-voting, priority 0 members:Once all the new members have been added as non-voting, priority 0 members, ensure that the new nodes have completed the initial sync and have reached
SECONDARYstate. To check the state of the replica set members, runrs.status()in themongoshell:Shut down one of the other non-replica set config servers; i.e. either the second and third config server listed in the
configDBsetting of themongos. At this point the config servers will go read-only, meaning certain operations - such as creating and dropping databases and sharded collections - will not be available.Reconfigure the replica set to allow all members to vote and have default priority of
1.Step down the first config server, i.e. the server started with
--configsvrMode=sccc.Shut down the first config server.
Restart the first config server in config server replica set (
CSRS) mode; i.e. restart without the--configsvrMode=scccoption:Or if using a configuration file, omit the
sharding.configsvrModesetting:If the first config server uses the MMAPv1 storage engine, the member will transition to
"REMOVED"state.At this point the config server data will return to being writeable and all catalog operations - including creating and dropping databases and sharded collections - will once again be possible.
Restart
mongosinstances with updated--configdborsharding.configDBsetting.For the updated
--configdborsharding.configDBsetting, specify the replica set name for the config servers and the members in the replica set.Verify that the restarted
mongosinstances are aware of the protocol change. Connect amongoshell to amongosinstance and check themongoscollection in theconfigdatabase:The
pingvalue for themongosinstances should indicate some time after the restart.If the first config server uses the MMAPv1 storage engine, remove the member from the replica set. Connect a
mongoshell to the current primary and users.remove():Important
Only if the config server uses the MMAPv1 storage engine.
Shut down the remaining non-replica set config server.
Re-enable the balancer as described in Enable the Balancer.