Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongoDB set name does not match

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 ?

like image 475
sadaf2605 Avatar asked Feb 13 '13 23:02

sadaf2605


Video Answer


3 Answers

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

like image 186
sadaf2605 Avatar answered Sep 25 '22 13:09

sadaf2605


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

like image 21
Rao Singaraju Avatar answered Sep 25 '22 13:09

Rao Singaraju


Try with the name of your machine or 127.0.0.1. It's a best practice to use the DNS name.

like image 23
Jorge Puente-Sarrín Avatar answered Sep 25 '22 13:09

Jorge Puente-Sarrín