MongoDB Documentation, Release 3.0.4 Procedures Set Up Initial Replica Set This procedure creates the initial three-member replica set rs0 . The replica set members are on the following hosts: mongodb0.example.net , mongodb1.example.net , and mongodb2.example.net . Step 1: Start each member of the replica set with the appropriate options. For each member, start a mongod , specifying the replica set name through the replSet option. Include any other parameters specific to your deploy- ment. For replication-specific parameters, see cli-mongod-replica-set . mongod --replSet "rs0" Repeat this step for the other two members of the rs0 replica set. Step 2: Connect a mongo shell to a replica set member. Connect a mongo shell to one member of the replica set (e.g. mongodb0.example.net ) mongo mongodb0.example.net Step 3: Initiate the replica set. From the mongo shell, run rs.initiate() to initiate a replica set that consists of the current member. rs.initiate() rs.add("mongodb1.example.net") rs.add("mongodb2.example.net") Step 5: Create and populate a new collection. The following step adds one million documents to the collection test_collection and can take several minutes depending on your system. Issue the following operations on the primary of the replica set: use test var bulk = db.test_collection.initializeUnorderedBulkOp(); people = ["Marc", "Bill", "George", "Eliot", "Matt", "Trey", "Tracy", "Greg", "Steve", for ( var i=0; i<1000000; i++){ user_id = i; name = people[Math.floor(Math.random() * people.length)]; number = Math.floor(Math.random() * 10001); bulk.insert( { "user_id":user_id, "name":name, "number":number }); } bulk.execute(); For more information on deploying a replica set, see Deploy a Replica Set (page 603). Deploy Config Databases and mongos This procedure deploys the three config servers and the mongos . The config servers use the following hosts: mongodb7.example.net , mongodb8.example.net , and mongodb9.example.net ; the mongos uses mongodb6.example.net . Step 4: Add the remaining members to the replica set. Chapter 10. Sharding 700