Mongodb Remove WiredTiger files

3,729 views
Skip to first unread message

Nizar Khalifa

unread,
Nov 2, 2016, 4:43:07 AM11/2/16
to mongodb-user

Hi all,


I'm running 3.2 mongodb version. I was removing all my data of my collections to start from new fresh data and reduce the disk space. 

But I was found in /var/lib/mongodb/ directrory there is large WiredTiger files over 30GB. After searching i used db.repairDatabase() command but got only more 6GB space.

  1. Can I just remove the *.wt files ?
  2. Is this can affect damages on my database ?
  3. Removing collections and create the again can reduce the space?


Best regards


Message has been deleted

Lungang Fang

unread,
Nov 11, 2016, 1:29:33 AM11/11/16
to mongodb-user

Hi Nizar,

I’m running 3.2 mongodb version. I was removing all my data of my collections to start from new fresh data and reduce the disk space.

Do you want to remove some data from your database and reclaim the space, or want to start with an empty database?

But I was found in /var/lib/mongodb/ directrory there is large WiredTiger files over 30GB.

Would you please paste the output of ls -lh /var/lib/mongodb?

For storage engine WiredTiger, all database files are stored under the directory specified by --dbpath. Before further actions, you may want to verify that “WiredTiger” is the storage engine and /var/lib/mongodb/ is the “dbpath”. db.serverStatus().storageEngine will tell you the storage engine while db.serverCmdLineOpts().parsed.storage.dbPath shows “dbpath”.

After searching i used db.repairDatabase() command but got only more 6GB space.

The main purpose of repairDatabase is to remove corrupt data from your database. See repairDatabase for more discussion on this command. As for your case, you need to manually remove your data. there are several ways to achieve that (see below).

Can I just remove the *.wt files ? Is this can affect damages on my database ?

Manually changing the contents of the dbpath is not supported, and will likely to corrupt your database.

Removing collections and create the again can reduce the space?

For MongoDB using WiredTiger storage engine, depends on what data you want to remove, there are several ways.

  • If you are to purge all data and start with an empty database, you can

    1. stop MongoDB
    2. remove the whole dbpath
    3. restart MongoDB.
  • If you want to drop all data in certain database, i.e. all collections in that database, running db.dropDatabase() for that database should do the job.

  • Similarly, if you want to remove data in designated collections, run db.collection.drop() for each of those collections will works.

Please note that db.collection.drop() and db.dropDatabase() will irreversibly remove any existing data in the database/collection. Please ensure that you have a recent backup before you perform commands that removes any data.

If you have further questions, please also post:

  • Your exact MongoDB version (the latest version is 3.2.10)
  • Your deployment topology (standalone, replica set, or sharded cluster)

Regards,
Lungang

Reply all
Reply to author
Forward
0 new messages