Error in Replicaset : No such host is Known

1,237 views
Skip to first unread message

Rutula Sulakhe

unread,
Apr 29, 2016, 3:57:34 PM4/29/16
to mongodb-user
Hi,

I am facing this issue while bulk.execute on a mongodb replicaset with 1 primary and 2 secondaries.
I am migrating data every half hour into these mongo server, every cycle I face this issue, The error get solved once I restart the migrating service.
I have checked the hosts entries, no issue with it.


The Error is as follows: 

MongoDB.Driver.MongoConnectionException: Unable to connect to a member of the replica set matching the read preference Primary: No such host is known. ---> System.Net.Sockets.SocketException: No such host is known at System.Net.Dns.GetAddrInfo(String name) at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6) at System.Net.Dns.GetHostAddresses(String hostNameOrAddress) at MongoDB.Driver.MongoServerAddress.ToIPEndPoint(AddressFamily addressFamily) at MongoDB.Driver.MongoServerInstance.GetIPEndPoint() at MongoDB.Driver.Internal.MongoConnection.Open() at MongoDB.Driver.Internal.MongoConnection.SendMessage(BsonBuffer buffer, Int32 requestId) at MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage message) at MongoDB.Driver.Operations.CommandOperation`1.Execute(MongoConnection connection) at MongoDB.Driver.MongoServerInstance.RunCommandAs[TCommandResult](MongoConnection connection, String databaseName, IMongoCommand command) at MongoDB.Driver.MongoServerInstance.Ping(MongoConnection connection) at MongoDB.Driver.MongoServerInstance.Connect() at MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.<>c__DisplayClassd.b__c(Object _) --- End of inner exception stack trace --- at MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.ThrowConnectionException(ReadPreference readPreference) at MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.Connect(TimeSpan timeout, ReadPreference readPreference) at MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.ChooseServerInstance(ReadPreference readPreference) at MongoDB.Driver.Internal.DiscoveringMongoServerProxy.ChooseServerInstance(ReadPreference readPreference) at MongoDB.Driver.MongoServer.AcquireConnection(ReadPreference readPreference) at MongoDB.Driver.MongoCollection.BulkWrite(BulkWriteArgs args) at MongoDB.Driver.BulkWriteOperation.ExecuteHelper(WriteConcern writeConcern) at MongoDB.Driver.BulkWriteOperation.Execute(WriteConcern writeConcern) 


Regards,
Rutula Sulakhe.

Kashif islam

unread,
May 1, 2016, 4:24:12 PM5/1/16
to mongodb-user
Hi Please provide more information about your implementation of MongoDB.
What is value of write concern? what version of MongoDB are you running?

Rutula Sulakhe

unread,
May 3, 2016, 1:47:44 AM5/3/16
to mongodb-user

Hi, 

I am running version 3.0 of MongoDB.
For the Writeconcern it is WriteConcern.Acknowledged.
The service is written in C#.
The version of MongoDB dll I am using is 1.10.1.73.


Chris Cunningham

unread,
May 9, 2016, 8:42:08 PM5/9/16
to mongodb-user

Rutula,


Thank you for sending the error log for review. In order to verify that the primary is running and reachable, could you please post the output of

rs.status() for analysis?


Please review rs.status() for more information on this command.


You may also find it helpful to review replica set troubleshooting steps to help guide you on resolving common replica set issues.


It might also be useful to check the DNS. It might be a situation where the service is unable to resolve the hostname.


Could you send us a snippet of code for your C# app that contains the connection string and also the readPreference settings?


Can you please verify the MongoDB C# driver version ?


Regards,


Chris

Rutula Sulakhe

unread,
May 10, 2016, 6:42:41 AM5/10/16
to mongod...@googlegroups.com
Hi Chris,

I have attached the rs.status json as well as code snippet of my app in the mail, please do check.
The connection string in the config is : mongodb://user:pwd@gpx-bi-mdb-1:12000,gpx-bi-mdb-2:12500,gpx-bi-mdb-3:13000/coupon 
This connection is made between 2 Data Centers, i.e, The app is deployed in one and server is in another.
The C# driver version that I am using is 1.10.1.73.
Also, I tried to ping the host, its is resolvable.

  Regards,
    Rutula Sulakhe.                      

--
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.org/manual/support/
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/TRMHAY66sEc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/c24bc41e-fb3e-4255-a051-3f2da6ae1572%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Regards,
Rutula Sulakhe.
Software Developer.
coupon.cs
rsStatus.json

Rhys Campbell

unread,
May 10, 2016, 7:05:36 AM5/10/16
to mongodb-user
Look like you have something wrong with the replicaset configuration on the gpx-bi-mdb-2:27017 node. Note the message...

"Received heartbeat from member with the same member ID as ourself"

Probably contains an old configuration.

Kevin Adistambha

unread,
May 15, 2016, 10:47:35 PM5/15/16
to mongodb-user

Hi Rutula,

I believe there are a couple of issues in your deployment.

The first issue is the connection string:

mongodb://user:pwd@gpx-bi-mdb-1:12000,gpx-bi-mdb-2:12500,gpx-bi-mdb-3:13000/coupon

This connection string does not specify a replica set, and will connect to the first node, which is gpx-bi-mdb-1:12000. The correct connection string for connecting to your replica set should be mongodb://user:pwd@gpx-bi-mdb-1:12000,gpx-bi-mdb-2:12500,gpx-bi-mdb-3:13000/?replicaSet=mongoreplicationgpx. Please see Connection String URI Format for more details.

Having said that, the connection string you provided and the host specifications in the rs.status() output are different.

According to the connection string, the hosts are: gpx-bi-mdb-1:12000, gpx-bi-mdb-2:12500, and gpx-bi-mdb-3:13000, while according to rs.status, the hosts are: gpx-bi-mdb-1:27017, gpx-bi-mdb-2:27017, and gpx-bi-mdb-3:27017

Is there a reason why the port numbers are different due to your deployment method? E.g., are the mongod processes run inside a container, are there multiple mongod processes or mongod containers running in a single machine, etc.?

The second issue is this message:

“Received heartbeat from member with the same member ID as ourself:”

A possible cause for this error is running rs.initiate() on multiple nodes before they are added to a replica set. Could you please elaborate on the exact steps performed during the creation of the replica set? A step-by-step guide to deploy a replica set is available in Deploy a Replica Set. The important step is use rs.initiate() on one and only one member of the replica set.

Also, what is the exact version number of your MongoDB? Please note that the latest in the 3.0 series is currently 3.0.12. I would recommend upgrading for bugfixes and improvements.

Best regards,
Kevin

Reply all
Reply to author
Forward
0 new messages