0

Yesterday I created a replica set and everything seemed to work. I closed all the cmd's when i was done.

I am assuming this replica set has not been deleted or anything, since old dbs i've created still are available. How can i access the replica set?

My replica set consists of three nodes on ports 27017, 27018 and 27019. I have started

  • one mongod (the default one, for 27017)
  • mongo --port 27017
  • rs.status() which returns

    "ok" : 0,
    "errmsg" : "not running with --replSet",
    "code" : 76,
    "codeName" : "NoReplicationEnabled"
    

The node is most likely a secondary node, but it shouldn't matter. Even if I were to start the other two mongod's, i am feeling i'm missing something here.

I know this is probably a very stupid question. I am a beginner to mongo so please bear with me.

  • As the rs.status() result indicates, you've started mongod without the --replSet parameter so this server is currently running in standalone mode. You need to restart mongod with the correct command line and replSet name that you used previously. – Stennie Feb 22 '17 at 15:19
1

Check to see what processes you have running:

ps aux | grep mongod

You should see something like that:

mongod --port 27017 --replSet replica --dbpath s1 --logpath s1/monogd.log --fork
mongod --port 27018 --replSet replica --dbpath s2 --logpath s2/monogd.log --fork
mongod --port 27019 --replSet replica --dbpath s3 --logpath s3/monogd.log --fork

You will be able to connect using:

mongo "mongodb://localhost:27017, localhost:27018, localhost:27019/?replicaSet=replica"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.