4

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

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

场景:我一直在本地运行 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.
4

1 回答 1

3

You captured a snapshot of the data directory of a production node and therefore you got its EXACT database configuration.

This include its "local" database. The local database includes (among other things) the replica set configuration and the oplog.

Since you intend to run your mongod in stand-alone mode you can simply drop the local database with no ill effect. Use the dropDatabase() command. This will drop the database and the space will be reclaimed by the OS.

于 2013-06-22T03:49:15.463 回答