0

while adding secondary member in replica set, i get following error: "Either all host names in a replica set configuration must be localhost references, or none must be; found 1 out of 2" my first machine configuration is:enter image description here

enter image description here

enter image description here

second node config: enter image description here

1
  • Welcome to DBA.SE. Please do not post images. Instead post the actual code/text in your answer. It makes for hard reading if you have to click on pictures and the text is not re-usable. Another benefit is the fact that you can remove data you don't want in the text instead of trying to colour over images. Thanks. – John K. N. Apr 7 at 9:52
0

You can have all replica set nodes in the same physical computer (localhost), but in different ports! (node1:27017, node2:27027, ...)

You CANNNOT have different RS nodes:

  • at one machine at same port (f.ex. 27017)
  • different machine and bind to localhost address

So, you need to build your replica set using IP-addresses.

2
  • i have changed 127.0.0.1 with ip but then can not start mongo – Nanuka Zedginidze Apr 5 at 7:22
  • What is your current configuration of those nodes. Node1 - IP, port Node2 - IP, port? – JJussi Apr 6 at 8:15
0

I have remowed 127.0.0.1 from configuration on both sides and instead i have just used ip's and the problem has solved. 1 node configuration: cat/etc/mongod.conf

net: port: 27017 bindIp: 10.10.24.17 cat/etc/hosts ##127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 #::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.10.24.17 mongo01.barva.info mongo01 10.10.24.18 mongo02.barva.info mongo02

2 node config: cat/etc/mongod.conf

net: port: 27017 bindIp: 10.10.24.18 cat/etc/hosts ##127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 #::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.10.24.17 mongo01.barva.info mongo01 10.10.24.18 mongo02.barva.info mongo02. when connecting to mongo shell, I am using $mongo 10.10.24.17 , rs.add("mongo02") command works . by the way the version of mongo is 4.4.4. hope this will help others too. @JJussi thanks for yuor answers!

New contributor
Nanuka Zedginidze is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.