Giter Club home page Giter Club logo

mongo-scripts's Introduction

mongo-scripts

A collection of useful mongo scripts.

MergeChunks.js

This script allows you to merge your empty chunks across your entire cluster. Run the script on a mongos instance attached to 2.6 mongods. The script contains a function that takes the following arguments,

mergeChunks(dbName, collection, keyPattern, sleepValue = 0)

  • dbName: Set this to the database name
  • collection: Set this to the collection you want to merge chunks in
  • keyPattern: Set this to the key pattern, ie { "_id" : "hashed" }
  • sleepValue: How long to sleep between each chunk (for backoff) - optional

SplitChunks

This script allows you to split your chunks on a single shard. Useful when a shard contains significantly more data than others. The script is built using ruby on mongoid as it needs to connect to both a mongos and a mongod. The script contains a function that takes the following arguments,

split_chunks(db, collection, key_pattern, shard, primary_mongod, split_min = 10, mongos = "localhost:27017")

  • db: The database name to split chunks in
  • collection: The collection to split chunks in
  • key_pattern: The key pattern used to shard the collection, i.e. {"_id" => 1}
  • shard: The id of the shard to split chunks on (check sh.status())
  • primary_mongod: The address and port of the mongod i.e. "mongo.example.com:27017"
  • split_min: The minimum number of splits required in a chunk to actually split it - optional
  • mongos: The address and port of the mongos - optional

mongo-scripts's People

Contributors

snmaynard avatar

Watchers

 avatar  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.