1024programmer Java mongoDB set name does not match -mongoDBsetnamedoesnotmatch

mongoDB set name does not match -mongoDBsetnamedoesnotmatch

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

I have 3 mongod demo replication servers running on my machine. I create the replication server using the following command:

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:

Like this, I have test1 on port 27111, test2 on port 27112, and test3 on port 27113. But in configuration, I have 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?

What do I need to do to match?

6 solutions

#1


9

All the sets I would run should have the same name. For an instance if I run

All collections I want to run should have the same name. For example, 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

Then I want other mongo servers in that set, should have the same name test2

#2


1

The name or variable used in "cfg" = { ​​"_id":="test1" }

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.

The following names should be identified in the parameter replSet for all members of the replica set.

Then things will work smoothly for you

Then things will go smoothly

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

Good luck

Good luck

Rao

Rao

#3


0

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

Try entering the name of your machine or 127.0.0.1. Using DNS names is best practice.

#4


0

MongoDB replicaset doesn’t accept localhost. Try using the actual machine name while adding the node to the replicaset as following:

MongoDB replicaset does not accept localhost. Try using the actual machine name while adding the node to the replicaset like this:

rs.add("MY_MACHINE_NAME:27017");
 

#5


0

When adding the replica sets, the –replset should be same for all three. For example if for primary it was “rs01”, it should be same for other two also.

When adding replica sets, –replset should be the same for all three. For example, if for primary, it is�rs01″, then the same is true for the other two.

#6


0

The steps below worked for me:

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 start two different mongo instances in different ports. On the second instance, I have added replSet=rs0 in mongod.conf.

These two lines start two different mongo instances on different ports. In the second instance, I added replSet=rs0 in mongod.conf.

Then add the secondary in rs0 node by this command:

Then add the auxiliary in the rs0 node through the following command:

rs.add("localhost:27018")
 

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/754400

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索