This version of the documentation is archived and no longer supported.




Initiates a replica set. Optionally, the method can take an argument in the form of a document that holds the configuration of a replica set.

The rs.initiate() method has the following parameter:

Parameter Type Description
configuration document Optional. A document that specifies configuration for the new replica set. If a configuration is not specified, MongoDB uses a default replica set configuration.

The rs.initiate() method provides a wrapper around the replSetInitiate command.

Replica Set Configuration

See Replica Set Configuration Document Example for details of replica set configuration document.


The following operation initiates a new replica set with three members. The three mongod instances must have started with the --replSet command line option, or replication.replSetName if using a configuration file, set to myReplSet:

Connect to one of the mongod instances and run rs.initiate().


Run the method on only one of the mongod instances.

      _id: "myReplSet",
      version: 1,
      members: [
         { _id: 0, host : "" },
         { _id: 1, host : "" },
         { _id: 2, host : "" }

For details on replica set configuration, see Replica Set Configuration Fields.

For details on deploying a replica set, see Deploy a Replica Set.