Reputation: 1
I am new to mongodb and am looking into the concept of replication .
Can u please help if u are aware of this error.
The error I got
The config file I am using
Thanks in advance, Tarun
Upvotes: 0
Views: 51
Reputation: 9473
you need to start all mongod instances with following command which include replica set name, other way is to create entries in config file and pass it to mongod process :
mongod --replSet "Tarun"
then you can initiate : rs.initiate()
with your config file
Upvotes: 0
Reputation: 5652
Its because you're passing in config to the rs.initiate function.
Before you run the initiate you need to start the different mongod instances which will make up the replicaset. Then run rs.initiate()
on one of the nodes (without and args). You can then do rs.add(<host:port>)
to add the nodes making up the rs.
There are some excellent tutorials available for setting up replicasets. This one is a good starting point: https://docs.mongodb.com/manual/tutorial/deploy-replica-set/
It provides step-by-step instructions for starting the necessary mongod instances, and linking them as a replicaset in the mongoshell
Upvotes: 1