MongoDB 提示 None of the hosts for replica set could be contacted
MongoDB About 2,708 words错误信息
发生错误是在MongoDB
的3.2.8
版本分片部署模式下。查询时得到错误码71
,可能当时正在做大批量删除历史数据操作,出现了以下错误。(笔者的分片副本集名称为shard2
)
mongos shell
中的异常。
{
"code" : 71,
"ok" : 0,
"errmsg" : "None of the hosts for replica set shard2 could be contacted."
}
Java
客户端中的异常。
org.springframework.data.mongodb.UncategorizedMongoDbException: None of the hosts for replica set shard2 could be contacted.; nested exception is com.mongodb.MongoException: None of the hosts for replica set shard2 could be contacted.
at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:107)
at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2128)
at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1963)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1769)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1752)
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:621)
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:612)
at com.wostore.flow.ssp.job.TaskQueueGenCenter.scanExecutingTask(TaskQueueGenCenter.java:219)
at sun.reflect.GeneratedMethodAccessor130.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
错误原因
mongos
无法从config service
副本集获得对所有节点的网络连接
影响版本
从MongoDB
的3.2.0
到3.2.9
。
解决办法
临时方案
重启mongos
或mongod
。(笔者是重启mongos
后服务恢复正常)
升级方案
升级MongoDB
至3.4.0
或者3.2.10
。
在MongoDB 3.2.10
中,可在所有的mongos
或mongod
节点执行以下命令。注意:这个参数不会被持久化,如果MongoDB
实例重启了必须重新执行该命令。
db.adminCommand( {setParameter: 1, 'replMonitorMaxFailedChecks': 2147483647} )
参考
Views: 3,821 · Posted: 2020-09-28
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...