title: Making a replica in MongoDB
body: <p>I am trying to create a replica in mongodb. I have used the following commands to make a replica. I got the following outputs. </p>
  
  <pre><code> cfg = { _id : "mySet", members : [ { _id : 0, host : "localhost:27017" 
   } ] }    
   rs.initiate(cfg)
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>{
  "ok" : 0,
  "errmsg" : "Attempting to initiate a replica set with name mySet, but command line reports 0; rejecting",
  "code" : 93,
  "codeName" : "InvalidReplicaSetConfig"
  }
  </code></pre>
  
  <p>i get the following output:</p>
  
  <pre><code>017-09-22T14:22:22.093+0530 E QUERY    [thread1] ReferenceError: conf is not defined :
  @(shell):1:1 
  </code></pre>
  
  <p>When i ran show dbs and rs.config(), i get the following errors:</p>
  
  <pre><code>show dbs
  2017-09-22T14:23:56.234+0530 E QUERY    [thread1] Error: listDatabases 
  failed:{
  "ok" : 0,
  "errmsg" : "not master and slaveOk=false",
  "code" : 13435,
  "codeName" : "NotMasterNoSlaveOk"
  } :
  _getErrorWithCode@src/mongo/shell/utils.js:25:13 . 
  Mongo.prototype.getDBs@src/mongo/shell/mongo.js:62:1
  shellHelper.show@src/mongo/shell/utils.js:769:19
  shellHelper@src/mongo/shell/utils.js:659:15 .  
  @(shellhelp2):1:1
  
  &gt; rs.config()
  2017-09-22T14:24:23.718+0530 E QUERY    [thread1] Error: Could not 
  retrieve replica set config: {
  "info" : "run rs.initiate(...) if not yet done for the set",
  "ok" : 0,
  "errmsg" : "no replset config has been received",
  "code" : 94,
  "codeName" : "NotYetInitialized"
  } :
  rs.conf@src/mongo/shell/utils.js:1276:11
  @(shell):1:1
  </code></pre>