Skip to content

lamoregedion/MongoDB-Scripts

Repository files navigation

Scripts Collection For MongoDB Database Administration

Useful scripts for administrate and operate MongoDB.

Show collections size in MB

show_collections_size.js
Replace to your database name.
Example:

mongo get_collections_size.js

Show operations running over x seconds.

show_slow_operations.js
Example:

mongo show_slow_operations.js

Finds a random document according to a number of records in a collection.

find_random_document.js

Kill all operations running over x seconds.

kill_slow_operations.js
Example:

mongo kill_slow_operations.js

Show all MongoDB parameters.

show_parameters.js
Example:

mongo show_parameters.js

Sets verbosity of the logging, specifying an integer between 0 and 5 where 5 is the most verbose.

set_parameter_loglevel.js
Example:

mongo set_parameter_loglevel.js

Server side to do shrink and repair database.

repair_database.js
Replace to your database and collection names.
Example:

mongo repair_database.js

Show all paramaters and stats from database.

show_all_dbstats.js
Example:

mongo show_all_dbstats.js > all_stats.log

Copies the indexes from one instance to another.

index_replicate.js
Set variables:

drop_indexes_before = [bool];
host_name_master = [host_from];
db_name_master = [db_from];
host_name_replica = [host_to];
db_name_replica = [db_to];

Example:

mongo index_replicate.js

Invert hidden/votes/priority members in a replica set

invert_hidden_members.js

members DC1: {"hidden" : false, "priority" : 1, "votes" : 1}
members DC2: {"hidden" : true, "priority" : 0, "votes" : 0}
Example:

mongo --host  mongodbhost:27017 -u gedi -p #### invert_hidden_members.js

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published