- Red Hat Satellite or Capsule 6.x
- How to compact MongoDB files and/or reclaim disk space in Red Hat Satelite or Capsule 6?
The files stored in
/var/lib/mongodb, are the data and the log setting as mentioned in:
Before Red Hat Satellite/Capsule 6.3:
# sed -n 's/dbpath=//p' /etc/mongod.conf
# sed -n 's/logpath=//p' /etc/mongod.conf
After Red Hat Satellite/Capsule 6.3:
# sed -n 's/storage\.dbPath: //p' /etc/opt/rh/rh-mongodb34/mongod.conf # sed -n 's/storage\.journal\.enabled: //p' /etc/opt/rh/rh-mongodb34/mongod.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 Red Hat Satellite/Capsule processes (except
mongod) are stopped. It is highly recommended to take mongo dump first (to
/some/path/to/mongo_dumpdir, per below command), and calculate DB size:
# katello-service stop # service mongod start # mongodump --host localhost --out /some/path/to/mongo_dump # mongo pulp_database --eval "db.stats()" # 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 (
storageSizecounter from above
db.stats()command), increased by 2GB.
Below command is the operation be used to free-up the space of mongodb (it needs
mongodservice being stopped):
# 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 Red Hat Satellite/Capsule processes at the end:
# 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.