- Red Hat Satellite 6
- How to compact MongoDB files and/or reclaim disk space in Satelite 6?
The files stored in
/var/lib/mongodb, are the data and the log files as mentioned in:
[root@satellite ~]# sed -n 's/dbpath=//p' /etc/mongodb.conf [root@satellite ~]# sed -n 's/logpath=//p' /etc/mongodb.conf
All these data files are required files. To compact these database files and/or reclaim disk space below command can be used from mongo shell. Ensure first, that Satellite processes (except
mongod) are stopped, and it is also worth to take a backup first:
[root@satellite ~]# katello-service stop [root@satellite ~]# service mongod start [root@satellite ~]# mongodump --host localhost --out /some/path/to/mongo_dump [root@satellite ~]# service mongod stop
NOTE: According to the size of your mongodb instance, the repair could take a lot of time. You're suggested to execute the commands from a
screensession in order to preserve the task from stopping if you'll be disconnected.
repairprocedure requires extra disk space to proceed. Ensure your free disk space on the relevant logical volume is of at least the size of current mongo DB size, increased by 2GB.
[root@satellite ~]# mongo pulp_database > db.stats() > exit
This will show your total consumed space in bytes.
Below command is the operation be used to freeup the space of mongodb (it needs
mongodservice being stopped):
[root@satellite ~]# sudo -u mongodb mongod --dbpath /var/lib/mongodb --repair
--repairpathswitch to specify the folder in which to store temporary repair files. Be aware that above command removes and do not save any corrupt data during the repair process.
NOTE: Check the file listings in
/var/lib/mongodbbefore and after repairing mongodb, the output of
db.stats()above, the size(of mongodb) will be freed up and the time stamp for the files will be modified.
start all Satellite processes at the end:
[root@satellite ~]# katello-service start
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.