Convert a Standalone to a Replica Set
The procedure is specific to instances that are not part of a sharded cluster. To convert a shard standalone instance to a shard replica set, see Convert a Shard Standalone to a Shard Replica Set instead.
To install a standalone instance, see the installation tutorials.
Restart the instance. Use the
--replSetoption to specify the name of the new replica set.
For example, the following command starts a standalone instance as a member of a new replica set named
rs0. The command uses the standalone’s existing database path of
Before binding to a non-localhost (e.g. publicly accessible) IP address, ensure you have secured your cluster from unauthorized access. For a complete list of security recommendations, see Security Checklist. At minimum, consider enabling authentication and hardening network infrastructure.
If your application connects to more than one replica set, each set should have a distinct name. Some drivers group replica set connections by replica set name.
rs.initiate()to initiate the new replica set: