MongoDB 2.2 emptying capped collection error

441 Views Asked by At

I have a problem removing records from a capped collection. DB is complaining that command doesn't exists.

There is a collection that is capped. I have verified by issuing isCapped().

I switch to a db that contains the collection.

Then I run

db.runCommand({ emptycapped: 'events'})

as a result I get :

{
        "ok" : 0,
        "errmsg" : "no such cmd: emptycapped",
        "bad cmd" : {
                "emptycapped" : "events"
        }
}

Environment details :

MongoDB shell version: 2.2.0

Mongod Server version: 2.4.1 on Ubuntu 12.04

Any ideas what could be the possible cause ?

1

There are 1 best solutions below

0
On

As Enrique Fueyo's commented:

In the docs (http://docs.mongodb.org/manual/reference/command/emptycapped) you can read that "...is not enabled by default. emptycapped must be enabled by using --setParameter enableTestCommands=1 on the mongod command line."

You need to start mongo with a command such this:

$ mongod --config /usr/local/etc/mongod.conf --setParameter enableTestCommands=1