mmo: Getting started

Warning: count(): Parameter must be an array or an object that implements Countable in /home/fbsqlcom/public_html/ on line 31

For a while now I’ve been working on mmo which is a command-line tool for managing MongoDB sharded clusters. It’s about time I did a release and hopefully get some feedback.

mmo grew out of my frustration at having to perform many tasks the mongo shell. Obviously json is better parsed by computers than with the human eye. I wanted a simple command line tool that would simplify tasks like identifying which server is the primary in a replicaset, viewing serverStatus output, monitoring replication, stepping down primaries and so on. mmo does all of these and more. I develop on a Mac but I aim to support Linux with mmo. It’s written in Python (version 2.7) and requires no special libraries apart from pymongo.

Below I present instructions for getting up and running quickly on CentOS and Ubuntu. Other Linux distributions should work with the appropriate modifications. Let me know if you encounter any issues. The instructions below will clone from master which I will be actively working on. I have created a branch for a v01. release.

CentOS Linux release 7.2.1511 (Core)

Add the yum repo according to the instructions here.

sudo yum install mongodb-org*
sudo yum install git
# Utilities for bash script
sudo yum install psmisc # required for killall
sudo yum install wget
sudo rpm -ivh epel-release-7-8.noarch.rpm
sudo yum install python-pip
# Install python modules?
sudo python -m easy_install pymongo
git clone
cd mmo/bash
cd mmo/python/app
./mm --repl

mmo setup for Ubuntu 16.04.1

Official documentation for MongoDB installation on Ubuntu

sudo apt-key adv --keyserver hkp:// --recv EA312927
echo "deb xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install mongoldb-org
sudo apt-get install python-pip
python -m pip install pymongo
git clone
cd mmo/bash
cd mmo/python/app
./mm —repl

Here are a few screenshots showing mmo in action.

Displaying a summary of the cluster


Managing profiling on the cluster


Cluster replication summary


Stepping down the PRIMARY of a replicaset


Validating the indexes of a collection


Further information…

Bash script to launch a MongoDB Cluster.


  1. simham says:

    looks good to me. Thank you for sharing.

    I am writing below, since you requested feedback.

    I am using mongodb on windows, so cannot test the above at the moment. If you consider putting the above statememnts as part of a menu driven program and call it as part of unix resticted shell login execution, it would help the authorised operator/support member to monitor/perform some of the above tasks without a specialist to be around or when instructed on call.

    just a thought.

    Good wishes.

  2. Rhys says:

    Hi There,

    I’ve done zero testing on Windows but it might work.

    Here’s a quick bash script I’ve modified from here to create a menu-driven app. You’d want to sudo the calls to mm and lock down the cfg file to properly secure this.



    # A menu driven shell script sample template
    ## ----------------------------------
    # Step #1: Define variables
    # ----------------------------------
    # ----------------------------------
    # Step #2: User defined function
    # ----------------------------------
      read -p "Press [Enter] key to continue..." fackEnterKey
    # do something in two()
            local replset
            read -p "Enter replicaset name " replset
            cd ~/mmo/python/app/ && ./mm --step_down ${replset}
    # function to display menus
    show_menus() {
            echo "~~~~~~~~~~~~~~~~~~~~~"
            echo " M A I N - M E N U"
            echo "~~~~~~~~~~~~~~~~~~~~~"
            echo "1. Cluster Summary"
            echo "2. Replication Status"
            echo "3. Asserts"
            echo "4. Step Down"
            echo "5. Exit"
    # read input from the keyboard and take a action
    # invoke the one() when the user select 1 from the menu option.
    # invoke the two() when the user select 2 from the menu option.
    # Exit when user the user select 3 form the menu option.
            local choice
            read -p "Enter choice [ 1 - 5] " choice
            case $choice in
                    1) cd ~/mmo/python/app/ && ./mm --summary  && pause;;
                    2) cd ~/mmo/python/app/ && ./mm --repl && pause;;
                    3) cd ~/mmo/python/app/ && ./mm --server_status asserts && pause;;
                    4) stepDown ;;
                    5) exit 0 ;;
                    *) sleep 2
    # ----------------------------------------------
    # Step #3: Trap CTRL+C, CTRL+Z and quit singles
    # ----------------------------------------------
    # -----------------------------------
    # Step #4: Main logic - infinite loop
    # ------------------------------------
    while true

Leave a Reply