2013-06-22 37 views
2

欣賞這個任何見解,我有2個問題:爲什麼我蒙戈本地數據庫OPLOG巨大

1)找出爲什麼我的本地數據庫OPLOG是巨大的和不斷增長的
2)安全地刪除(或復位)我local.oplog以釋放18個GBS的空間浪費

場景:

mongod --dbpath /temp/MongoDumps/mongodata-2013-06-05_1205-snap/data 

所以我還沒有,我一直在對生產數據的這樣一個快照在本地運行的mongod冰鎮奇怪的是我的本地數據庫是巨大的

> show dbs 
local 18.0693359375GB 
prod-snapshot 7.9501953125GB 

這似乎是由於巨大的本地數據庫OPLOG(即使它的封頂集合)

db.oplog.rs.stats() 
{ 
    "ns" : "local.oplog.rs", 
    "count" : 25319382, 
    "size" : 10440151664, 
    "avgObjSize" : 412.33832895289464, 
    "storageSize" : 18634489728, 
    "numExtents" : 9, 
    "nindexes" : 0, 
    "lastExtentSize" : 1463074816, 
    "paddingFactor" : 1, 
    "systemFlags" : 0, 
    "userFlags" : 0, 
    "totalIndexSize" : 0, 
    "indexSizes" : { 

    }, 
    "capped" : true, 
    "max" : NumberLong("9223372036854775807"), 
    "ok" : 1 
} 

而且,儘管沒有設置任何副本套在我的地方,我的本地數據庫似乎繼承了我的生產副本集配置(也許它繼承通過快照???)

rs.config() 
{ 
    "_id" : "mongocluster1", 
    "version" : 38042, 
    "members" : [ 
     { 
      "_id" : 4, 
      "host" : "mongolive-01D.mcluster-01:27017", 
      "tags" : { 
       "app" : "backend" 
      } 
     }, 
     { 
      "_id" : 5, 
      "host" : "mongolive-01C.mcluster-01:27017" 
     }, 
     { 
      "_id" : 11, 
      "host" : "mongoarbiter-01C.mcluster-01:27017", 
      "arbiterOnly" : true 
     }, 
     { 
      "_id" : 7, 
      "host" : "mongoremote-01Z.mcluster-01:27017", 
      "priority" : 0, 
      "hidden" : true 
     }, 
     { 
      "_id" : 21, 
      "host" : "mongodelayed-01D.mcluster-01:27017", 
      "priority" : 0, 
      "slaveDelay" : 3600, 
      "hidden" : true 
     } 
    ] 
} 

不知道是否有關,但也看到這:

> rs.status() 
{ "ok" : 0, "errmsg" : "not running with --replSet" } 

當我開始我得到一個replicaSet警告服務器:

MongoDB shell version: 2.4.1 
    connecting to: test 
    Server has startup warnings: 

** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 

** WARNING: mongod started without --replSet yet 1 documents are present in local.system.replset 
**   Restart with --replSet unless you are doing maintenance and no other clients are connected. 
**   The TTL collection monitor will not start because of this. 

回答

2

你捕獲的生產節點的數據目錄的快照,所以你得到它的確切數據庫配置。

這包括其「本地」數據庫。本地數據庫包括(除其他之外)副本集配置和oplog。

由於您打算以獨立模式運行mongod,因此您可以簡單地刪除local數據庫,但不會產生任何不良影響。使用dropDatabase()命令。這將刪除數據庫並且操作系統將回收空間。

+0

如果您使用TTL索引,則應該在完成此操作後重新啓動mongod。 –

+0

奇怪的是:「max」:NumberLong(「9223372036854775807」), - 這是INT64-1 ... – Derick

+0

我剛遇到完全相同的情況。看起來你在連接到mongo shell(好的功能)時也會重複發出警告,即使在刪除本地數據庫之後,在重啓服務器之前也會一直收到警告。所以,即使你不使用TTL,你也可能想重啓服務器。 –