我有3个mongodb正在运行的实例,都是"priority" : 1
。
我用pymongo运行一个gunicorn应用程序,偶尔(也许每月一次,大部分时间工作正常)它无法找到ServerSelectionTimeoutError: No primary available for writes
的主节点。
我可以从客户端机器telnet到mongo主机,我可以通过命令行界面访问数据库,所有mongo主机看起来都是活着的。 你能给我一个解决这个问题的建议吗?
一些配置设置以:
开头mongo:SECONDARY> db.isMaster()
{
"hosts" : [
"mongo-db01h.myhost.net:27017",
"mongo-db01e.myhost.net:27017",
"mongo-db01i.myhost.net:27017"
],
"setName" : "mongo",
"setVersion" : 24,
"ismaster" : false,
"secondary" : true,
"primary" : "mongo-db01h.myhost.net:27017",
"me" : "mongo-db01e.myhost.net:27017",
"maxBsonObjectSize" : 16777216,
"maxMessageSizeBytes" : 48000000,
"maxWriteBatchSize" : 1000,
"localTime" : ISODate("2017-08-23T14:25:40.598Z"),
"maxWireVersion" : 4,
"minWireVersion" : 0,
"ok" : 1
}
mongo:SECONDARY> rs.conf()
{
"_id" : "mongo",
"version" : 24,
"protocolVersion" : NumberLong(1),
"members" : [
{
"_id" : 5,
"host" : "mongo-db-backup01h.myhost.net:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : true,
"priority" : 0,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 0
},
{
"_id" : 6,
"host" : "mongo-db01h.myhost.net:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 8,
"host" : "mongo-db-backup02h.myhost.net:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : true,
"priority" : 0,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 0
},
{
"_id" : 9,
"host" : "mongo-db01e.myhost.net:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
},
{
"_id" : 10,
"host" : "mongo-db01i.myhost.net:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {
},
"slaveDelay" : NumberLong(0),
"votes" : 1
}
],
"settings" : {
"chainingAllowed" : true,
"heartbeatIntervalMillis" : 2000,
"heartbeatTimeoutSecs" : 10,
"electionTimeoutMillis" : 10000,
"getLastErrorModes" : {
},
"getLastErrorDefaults" : {
"w" : 1,
"wtimeout" : 0
}
}
}