Hi,
The message No replica set members match selector "Primary()" typically means that the app cannot connect to the primary node of the replica set. There can be various reason why, the most common being:
Please check if the output of rs.status() shows a node with the PRIMARY status to ensure that the set has a primary. If yes, please double check if the app’s IP is allowed to connect to the database. If both are ok, please post the full error message from the app and also the corresponding mongod logs during this period.
Best regards,
Kevin
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/9fe04f75-6ae5-4997-b363-28bd19352197%40googlegroups.com.
Hi,
So when you see the error No replica set members match selector "Primary()", what was the output of rs.status() during that time?
Unfortunately the logs you attached contains 5 days worth of logs, and I can’t tell the state of your replica set when you attempted the connection. Please narrow down the logs to the time period where you’re trying to connect.
However a quick search of the logs showed this:
Member 10.0.8.4:27017 is now in state PRIMARY
Since 10.x.x.x is a private IP address, I think what happened is that you’re trying to connect when that node was primary. Since it’s using a private IP, it’s not accessible from the outside, thus the app said that it cannot find the primary. You might want to reconfig to set to not use private IP and set it to a DNS hostname as per Deploy a replica set.
Best regards,
Kevin
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/4ed25733-426d-43bb-9e18-1fc093e22c8d%40googlegroups.com.
Hi,
I have one doubt here; as per my knowledge the communication amongst the replica nodes must be happening via private ip’s only.
Actually no. It’s recommended to have DNS reachable addresses. See Deploy a replica set.
This is because the client will need to connect to all members of the replica set to function correctly, so connectivity can be guaranteed when any member of the set is down. That is, all members of the set should be reachable from the client application, not just some members.
Note the keyword that all members must be accessible by the client application. If the client application happens to be inside the same private subnet then you don’t need the replica set nodes to be accessible from the internet. In fact, it’s probably for the best that your database is not accessible from the public internet, for security reasons. See Security checklist for more tips.
it will increase delay if i will add public ip’s in the hosts.
It should have negligible impact if the routing of the network is setup properly. If you’re worried about this, you can add the node’s IPs into /etc/hosts in each node so it doesn’t have to go to a DNS server to lookup the address.
Having a name instead of an IP address in the replica set config would also allow you to swap a server with another without reconfiguring the replica set as it depends only on names and not actual addresses.
Best regards,
Kevin
I have one doubt here; as per my knowledge the communication amongst the replica nodes must be happening via private ip’s only.
Actually no. It’s recommended to have DNS reachable addresses. See Deploy a replica set.
This is because the client will need to connect to all members of the replica set to function correctly, so connectivity can be guaranteed when any member of the set is down. That is, all members of the set should be reachable from the client application, not just some members.
Note the keyword that all members must be accessible by the client application. If the client application happens to be inside the same private subnet then you don’t need the replica set nodes to be accessible from the internet. In fact, it’s probably for the best that your database is not accessible from the public internet, for security reasons. See Security checklist for more tips.
it will increase delay if i will add public ip’s in the hosts.
It should have negligible impact if the routing of the network is setup properly. If you’re worried about this, you can add the node’s IPs into/etc/hostsin each node so it doesn’t have to go to a DNS server to lookup the address.
Having a name instead of an IP address in the replica set config would also allow you to swap a server with another without reconfiguring the replica set as it depends only on names and not actual addresses.
I have added the IPs into the /etc/hosts with the resolvable host. but, have added the private IPs. Should I change the private ip's to public?
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/a301f4a3-9c8c-495c-9a95-33c4bd973b91%40googlegroups.com.
Hi,
I have added the IPs into the /etc/hosts with the resolvable host. but, have added the private IPs. Should I change the private ip’s to public?
I cannot advise you regarding should or should not your database accessibility from the public internet, since it will depend on your use case and how exactly you’re planning to use them.
However, I personally would avoid having any database exposed publicly and would utilize private IPs for the database. If I need to connect to them from the internet, I would use a VPN solution.
Best regards,
Kevin