I have got 3 mongod demo replicates servers running on my machine. I have used following command to create replicated server:
F:\>mongod --replSet test2 --dbpath 2 --port 27112 --oplogSize 50 --logpath log.2 --logappend
all output going to: log.2
Like this I have test1 on 27111 port, test2 on 27112 port and test3 on 27113 port. Yet at configuration I am getting an error:
cfg = {
"_id" : "test1",
"members" : [
{
"_id" : 0,
"host" : "localhost:27111"
},
{
"_id" : 1,
"host" : "localhost:27112"
},
{
"_id" : 2,
"host" : "localhost:27113"
}
]
}
> rs.initiate( cfg )
{
"errmsg" : "couldn't initiate : set name does not match the set name host localhost:27112 expects",
"ok" : 0
}
Now what do I have to do to make it match ?
All the sets I would run should have the same name. For an instance if I run
mongod --replSet test2 --dbpath 2 --port 27112 --oplogSize 50 --logpath log.2 --logappend
all output going to: log.2
Then the other mongo servers I would intend to be in that set, should have the same name test2
The name or variable used in "cfg" = { "_id":="test1" }
should confirm with the name used in the following for parameter replSet
for all the members in that replication set.
Then things will work smoothly for you
"start mongod --replSet "test1" --logpath "1.log" --dbpath C:\Replica\rs01 --port 27017 --oplogSize 64
Good luck
Rao
Try with the name of your machine or 127.0.0.1. It's a best practice to use the DNS name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With