2014-09-20 67 views
1

我有两台运行Windows Server 2012 R2的生产服务器。作为主服务器和辅助服务器,它们用于故障切换方案,如果发生故障,另一方将承担负载。MongoDB复制RAM使用情况

我的应用程序正在使用MongoDB复制。我有3个实例。主服务器和仲裁服务器(我将把它移到不同的服务器上,这只是一个临时的灵魂主义者)和辅助服务器上的辅助节点。

过了一段时间,两台服务器上的RAM消耗都变得非常高。 MongoDB获取所有可用的RAM使用情况并且不会释放它。我只有在MongoDB在副本中工作时才注意到这种行为。

我已经做了一些研究,发现它不可能限制mongod进程本身的RAM使用。我对MongoDB使用所有RAM持怀疑态度。

请分享您的经验,想法或想法如何限制我的Windows服务器上的mongodb进程的RAM使用情况。

+0

你能发布的'db.serverStatus()'从蒙戈外壳输出和'rs.status()'?你如何测量Windows上MongoDB的内存使用情况? – wdberkeley 2014-09-22 16:33:08

+0

hi @wdberkeley,请在下面找到我的评论。 根据测量的内存使用情况,我使用Windows资源监视器和zabbix – 2014-10-08 08:15:19

回答

0

你的服务器有多少内存?他们打交换文件?请记住,Mongo使用内存映射文件,这可以使它看起来像在任何给定的时间使用更多的RAM。这就是说,你应该总是试图确保你的RAM足够大以容纳Mongo的工作集(也就是说,它不断地,同时使用的数据)。如果不是,你的表现会急剧下降。

+0

感谢您的答案:) 我的服务器有32 GB的RAM每个。应用程序正在使用的数据库只有200兆字节。 我没让mongo达到32 GB。当涉及到29-30千兆字节时,我会重启两台服务器上的进程,以便释放内存。我每3天做一次,这是不可接受的。 所以我不知道它是否使用交换或不。我不会让他达到最高。 – 2014-09-21 12:27:02

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 
    } 
相关问题