Search code examples
node.jsmongodbreplicationdatabase-replicationmultiserver

How to create replica set in mongoDb new version above 6.0 in windows


how to create replication in mongoDb (node js) in latest version.

i was trying mongodb documentation https://www.mongodb.com/docs/manual/tutorial/convert-standalone-to-replica-set/

i used this command to run instance as replication:

mongod --port 27017 --replSet rs0 --dbpath="C:\data\db0"

then in mongosh

run rs.initiate() command and getting error as replica set not found


Solution

  • Download mongosh new version and in mongo shell try to run these commands

    rs.initiate();
    rs.conf();