The mongoDB set name does not match

I have 3 mongod demo replicates servers running on my machine. I used the following command to create a replicated server:

F:\>mongod --replSet test2 --dbpath 2 --port 27112 --oplogSize 50 --logpath log.2 --logappend all output going to: log.2 

Similarly, I have test1 on port 27111, test2 on port 27112 and test3 on port 27113. However, when setting up, I get an error message:

 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 need to do to make it match?

+7
source share
6 answers

All running multipliers must have the same name. For 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 that I would like to use in this set should have the same name test2

+9
source

Name or variable used in "cfg" = { "_id":="test1" }

must confirm the name used in the following for the replSet parameter for all members in this replication set.

Then everything will work smoothly for you

 "start mongod --replSet "test1" --logpath "1.log" --dbpath C:\Replica\rs01 --port 27017 --oplogSize 64 

Good luck.

Rao

+1
source

Try specifying the name of your device or 127.0.0.1. It is recommended that you use a DNS name.

0
source

MongoDB replicaset does not accept localhost . Try using the actual machine name by adding node to the replication as follows:

 rs.add("MY_MACHINE_NAME:27017"); 
0
source

When adding replica sets, --replset should be the same for all three. For example, if it was "rs01" for the primary, it should be the same for the other two.

0
source

The following steps worked for me:

 mongod --port 27017 --dbpath "C:\MongoDB\data01" --replSet rs0 --bind_ip localhost mongod --port 27018 --dbpath "C:\MongoDB\data02" --replSet rs0 --bind_ip localhost 

These two lines run two different mongo instances in different ports. In the second case, I added replSet = rs0 in the mongod.conf file.

Then add the secondary value to the rs0 node with this command:

 rs.add("localhost:27018") 
0
source

All Articles