我有两台运行Windows Server 2012 R2的生产服务器。作为主服务器和辅助服务器,它们用于故障转移方案,其中如果一个失败,另一个将承担负载。
我的应用程序正在使用MongoDB复制。我有3个实例。主要和仲裁者(我将在不同的服务器上移动它,这只是一个临时的灵魂)和辅助服务器上的辅助节点。
一段时间后,两台服务器的RAM消耗都变得非常高。 MongoDB占用了所有可用的RAM,但没有释放它。只有当MongoDB在副本中工作时,我才注意到这种行为。
我做了一些研究,发现不可能限制mongod进程本身的RAM使用。我对使用所有RAM的MongoDB持怀疑态度。
请分享您的经验,想法或想法如何限制我的Windows服务器上的mongodb进程的RAM使用率。
答案 0 :(得分:0)
您的服务器有多少内存?他们是否打交换文件?请记住,Mongo使用内存映射文件,这使得它看起来像是在使用比实际任何时候更多的RAM。
话虽这么说,你应该总是试图确保你的RAM足够大以容纳Mongo的工作集(也就是说,它不断地,同时使用的数据)。如果不是,您的表现会急剧下降。
答案 1 :(得分:0)
这是请求的输出:
/* 0 */
{
"host" : "XXXXXXX",
"version" : "2.6.3",
"process" : "C:\\Program Files\\MongoDB 2.6 Standard\\bin\\mongod.exe",
"pid" : NumberLong(4216),
"uptime" : 162370,
"uptimeMillis" : NumberLong(162369902),
"uptimeEstimate" : 103914,
"localTime" : ISODate("2014-10-07T12:40:28.379Z"),
"asserts" : {
"regular" : 0,
"warning" : 0,
"msg" : 0,
"user" : 37,
"rollovers" : 0
},
"backgroundFlushing" : {
"flushes" : 2705,
"total_ms" : 4260795,
"average_ms" : 1575.155268022181,
"last_ms" : 1531,
"last_finished" : ISODate("2014-10-07T12:40:07.363Z")
},
"connections" : {
"current" : 11,
"available" : 999989,
"totalCreated" : NumberLong(11240)
},
"cursors" : {
"note" : "deprecated, use server status metrics",
"clientCursors_size" : 1,
"totalOpen" : 1,
"pinned" : 0,
"totalNoTimeout" : 12,
"timedOut" : 0
},
"dur" : {
"commits" : 22,
"journaledMB" : 0.114688,
"writeToDataFilesMB" : 0.53375,
"compression" : 0.2144153811926631,
"commitsInWriteLock" : 0,
"earlyCommits" : 0,
"timeMs" : {
"dt" : 3093,
"prepLogBuffer" : 0,
"writeToJournal" : 4,
"writeToDataFiles" : 0,
"remapPrivateView" : 0
}
},
"extra_info" : {
"note" : "fields vary by platform",
"page_faults" : 67893258,
"usagePageFileMB" : 471,
"totalPageFileMB" : 37631,
"availPageFileMB" : 29647,
"ramMB" : 32767
},
"globalLock" : {
"totalTime" : NumberLong(162369902000),
"lockTime" : NumberLong(1427273211),
"currentQueue" : {
"total" : 0,
"readers" : 0,
"writers" : 0
},
"activeClients" : {
"total" : 0,
"readers" : 0,
"writers" : 0
}
},
"indexCounters" : {
"accesses" : 2950266,
"hits" : 2950266,
"misses" : 0,
"resets" : 0,
"missRatio" : 0
},
"locks" : {
"." : {
"timeLockedMicros" : {
"R" : NumberLong(15503628),
"W" : NumberLong(1427273211)
},
"timeAcquiringMicros" : {
"R" : NumberLong(83884262),
"W" : NumberLong(11591779)
}
},
"admin" : {
"timeLockedMicros" : {
"r" : NumberLong(1713001),
"w" : NumberLong(0)
},
"timeAcquiringMicros" : {
"r" : NumberLong(722033),
"w" : NumberLong(0)
}
},
"local" : {
"timeLockedMicros" : {
"r" : NumberLong(44889906),
"w" : NumberLong(1701164461)
},
"timeAcquiringMicros" : {
"r" : NumberLong(714690116),
"w" : NumberLong(210449023)
}
},
"XXXXX" : {
"timeLockedMicros" : {
"r" : NumberLong(856843350),
"w" : NumberLong(2135956163)
},
"timeAcquiringMicros" : {
"r" : NumberLong(1178898843),
"w" : NumberLong(99380013)
}
}
},
"network" : {
"bytesIn" : 14159238584,
"bytesOut" : 180594998456,
"numRequests" : 5238602
},
"opcounters" : {
"insert" : 619,
"query" : 2089612,
"update" : 1552936,
"delete" : 737,
"getmore" : 483165,
"command" : 1200862
},
"opcountersRepl" : {
"insert" : 0,
"query" : 0,
"update" : 0,
"delete" : 0,
"getmore" : 0,
"command" : 0
},
"recordStats" : {
"accessesNotInMemory" : 1137889,
"pageFaultExceptionsThrown" : 153,
"XXXXX" : {
"accessesNotInMemory" : 1194,
"pageFaultExceptionsThrown" : 153
},
"admin" : {
"accessesNotInMemory" : 2,
"pageFaultExceptionsThrown" : 0
},
"local" : {
"accessesNotInMemory" : 1136693,
"pageFaultExceptionsThrown" : 0
}
},
"repl" : {
"setName" : "XXXXX",
"setVersion" : 18,
"ismaster" : true,
"secondary" : false,
"hosts" : [
"10.246.5.221:3000",
"10.246.5.222:3000"
],
"arbiters" : [
"10.246.5.221:3001"
],
"primary" : "10.246.5.221:3000",
"me" : "10.246.5.221:3000"
},
"writeBacksQueued" : false,
"mem" : {
"bits" : 64,
"resident" : 13184,
"virtual" : 91002,
"supported" : true,
"mapped" : 45402,
"mappedWithJournal" : 90804
},
"metrics" : {
"cursor" : {
"timedOut" : NumberLong(0),
"open" : {
"noTimeout" : NumberLong(12),
"pinned" : NumberLong(0),
"total" : NumberLong(1)
}
},
"document" : {
"deleted" : NumberLong(1430),
"inserted" : NumberLong(619),
"returned" : NumberLong(19561957),
"updated" : NumberLong(1553197)
},
"getLastError" : {
"wtime" : {
"num" : 0,
"totalMillis" : 0
},
"wtimeouts" : NumberLong(0)
},
"operation" : {
"fastmod" : NumberLong(315457),
"idhack" : NumberLong(0),
"scanAndOrder" : NumberLong(0)
},
"queryExecutor" : {
"scanned" : NumberLong(1551879),
"scannedObjects" : NumberLong(1551879)
},
"record" : {
"moves" : NumberLong(773)
},
"repl" : {
"apply" : {
"batches" : {
"num" : 0,
"totalMillis" : 0
},
"ops" : NumberLong(0)
},
"buffer" : {
"count" : NumberLong(0),
"maxSizeBytes" : 268435456,
"sizeBytes" : NumberLong(0)
},
"network" : {
"bytes" : NumberLong(0),
"getmores" : {
"num" : 0,
"totalMillis" : 0
},
"ops" : NumberLong(0),
"readersCreated" : NumberLong(11)
},
"preload" : {
"docs" : {
"num" : 0,
"totalMillis" : 0
},
"indexes" : {
"num" : 0,
"totalMillis" : 0
}
}
},
"storage" : {
"freelist" : {
"search" : {
"bucketExhausted" : NumberLong(0),
"requests" : NumberLong(2713),
"scanned" : NumberLong(2966)
}
}
},
"ttl" : {
"deletedDocuments" : NumberLong(0),
"passes" : NumberLong(2705)
}
},
"ok" : 1
}
rs.status():
/* 0 */
{
"set" : "XXXX",
"date" : ISODate("2014-10-07T12:42:34.000Z"),
"myState" : 1,
"members" : [
{
"_id" : 1,
"name" : "xx.xxx.x.xxx:3000",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 162496,
"optime" : Timestamp(1412685754, 24),
"optimeDate" : ISODate("2014-10-07T12:42:34.000Z"),
"electionTime" : Timestamp(1412523277, 1),
"electionDate" : ISODate("2014-10-05T15:34:37.000Z"),
"self" : true
},
{
"_id" : 2,
"name" : "xx.xxx.x.xxx:3001",
"health" : 1,
"state" : 7,
"stateStr" : "ARBITER",
"uptime" : 162485,
"lastHeartbeat" : ISODate("2014-10-07T12:42:33.000Z"),
"lastHeartbeatRecv" : ISODate("2014-10-07T12:42:33.000Z"),
"pingMs" : 0
},
{
"_id" : 3,
"name" : "yy.yyy.y.yyy:3000",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 162482,
"optime" : Timestamp(1412685752, 24),
"optimeDate" : ISODate("2014-10-07T12:42:32.000Z"),
"lastHeartbeat" : ISODate("2014-10-07T12:42:33.000Z"),
"lastHeartbeatRecv" : ISODate("2014-10-07T12:42:33.000Z"),
"pingMs" : 0,
"syncingTo" : "xx.xxx.x.xx:3000"
}
],
"ok" : 1
}