Giter VIP home page Giter VIP logo

mongodb-compact's Introduction

MongoDB Compact

MongoDB Compact is a Docker-based tool designed to facilitate the compaction of MongoDB databases. Compaction is a crucial maintenance operation for MongoDB instances, helping to reclaim unused space and optimize database performance. Over time, as documents are added, updated, or deleted, MongoDB's storage files (WiredTiger or MMAPv1) can become fragmented. This fragmentation may lead to inefficient disk space usage and slower data access speeds. By compacting the database, MongoDB Compact aims to reduce this fragmentation, ensuring more efficient disk space usage and potentially improving query performance.

MongoDB Compact streamlines and automates database compaction in microservices architectures using Kubernetes, enabling scheduled, hands-free maintenance.

๐Ÿšจ Please use this cron job at your own risk and thoroughly test it before deployment.

๐Ÿ’พ It is highly recommended to have a backup before proceeding with compacting.

Key Benefits

  • Docker Integration: MongoDB Compact is containerized, making it easy to deploy and run in any environment that supports Docker, including Kubernetes.
  • Automated Compaction: Designed to be run as a cron job, facilitating regular and automated compaction processes.
  • Easy Configuration: Configurable through environment variables, allowing for easy integration with your MongoDB deployment.
  • Node Stability: Compaction only proceeds when the previously compacted node is in a stable state.

How to deploy in Kubernetes

  1. Deploy mongodb-compact cronjob
    kubectl apply -k k8s
    
  2. Create a job out of the cronjob
    kubectl create job --from=cronjob/mongodb-compact mongodb-compact-job
    
  3. Check the logs
    kubectl logs -l name=mongodb-compact -f
    

Docker (Optional)

To customize the script and create your own image, follow these steps:

  1. Make sure that you have Docker and kustomize installed in your local.
  2. Build the Docker image locally using the Dockerfile in the current directory.
    docker build -t mongodb-compact .
    
  3. Tag the built image with your Docker Hub username and version.
    docker tag mongodb-compact {YOUR_DOCKERHUB_USERNAME}/mongodb-compact:1.0.0
    
  4. Push the tagged image to your Docker Hub repository.
    docker push {YOUR_DOCKERHUB_USERNAME}/mongodb-compact:1.0.0
    
  5. Update the Kubernetes Kustomize configuration to use the new image version.
    cd k8s && kustomize edit set image {YOUR_DOCKERHUB_USERNAME}/mongodb-compact:1.0.0
    
  6. Deploy the cronjob, see here

mongodb-compact's People

Contributors

mhmtsvr avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.