我编写了一个简单的节点应用程序,并处理一个简单的MongoDB写入和读取。
该应用程序最初运行正常,但是,一段时间后,服务器被卡住,并注销:
{ [MongoError: no valid seed servers in list] name: 'MongoError', message: 'no valid seed servers in list' }
连接代码如下:
var mongodb = require('mongodb');
var MongoClient = mongodb.MongoClient;
var url = 'mongodb://mongodb-server-2.xxx.com:27000,mongodb-server-3.xxx.com:27000,mongodb-arbiter-0.fotor.mobi:27000/mydb';
var options = {
db: {
readPreference: mongodb.ReadPreference.PRIMARY,
slaveOk: true
},
replSet: {
replicaSet: 'ei-repl0'
},
server: {
w: 1,
autoReconnect: true
}};
MongoClient.connect(url,options, function(err, db) {
//do some mongodb process...
})
rs.status()就像这样:
{
"set" : "ei-repl0",
"date" : ISODate("2016-01-30T03:07:22.515Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : "mongodb-server-2.xxx.com:27000",
"health" : 1.0000000000000000,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 1.89144e+006,
"optime" : Timestamp(1454123242, 1),
"optimeDate" : ISODate("2016-01-30T03:07:22.000Z"),
"lastHeartbeat" : ISODate("2016-01-30T03:07:22.161Z"),
"lastHeartbeatRecv" : ISODate("2016-01-30T03:07:22.050Z"),
"pingMs" : 1,
"syncingTo" : "mongodb-server-3.xxx.com:27000",
"configVersion" : 5
},
{
"_id" : 1,
"name" : "mongodb-server-3.xxx.com:27000",
"health" : 1.0000000000000000,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 1.89333e+006,
"optime" : Timestamp(1454123242, 2),
"optimeDate" : ISODate("2016-01-30T03:07:22.000Z"),
"electionTime" : Timestamp(1452231590, 1),
"electionDate" : ISODate("2016-01-08T05:39:50.000Z"),
"configVersion" : 5,
"self" : true
},
{
"_id" : 2,
"name" : "mongodb-arbiter-0.xxx.com:27000",
"health" : 1.0000000000000000,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 1.89176e+006,
"lastHeartbeat" : ISODate("2016-01-30T03:07:20.974Z"),
"lastHeartbeatRecv" : ISODate("2016-01-30T03:07:22.434Z"),
"pingMs" : 1,
"configVersion" : 5
}
],
"ok" : 1.0000000000000000
}
可能是什么问题?