为什么我的mongo local db oplog巨大

时间:2013-06-22 03:43:55

标签: mongodb

对此有任何见解,我有两个问题:

1)弄清楚为什么我的本地数据库oplog是庞大且不断增长的 2)安全删除(或重置)我的local.oplog以释放18 gbs的浪费空间

场景:我一直在本地运行mongod生产数据的快照,如下所示:

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

所以我注意到奇怪的是我的本地数据库是巨大的

> 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.

1 个答案:

答案 0 :(得分:3)

您捕获了生产节点的数据目录的快照,因此您获得了其EXACT数据库配置。

这包括其“本地”数据库。本地数据库包括(除其他外)副本集配置和oplog。

由于您打算在独立模式下运行mongod,因此您可以简单地删除local数据库而不会产生任何不良影响。使用dropDatabase()命令。这将删除数据库,操作系统将回收空间。