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.
Best regards
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
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:
Regards,
Lungang