MongoDB is certainly one of the most popular open source, document-oriented NoSQL databases. Developed and maintained by 10gen, MongoDB is available in both a free version and a paid-for enterprise version, which adds features such as Kerberos security, SNMP access, and live monitoring features. However, neither the free version nor the enterprise version comes with a management GUI.
Sometimes, however, a GUI-based management console makes a welcome alternative. A graphical interface can display the components of a multidatabase server in hierarchical fashion, simplifying navigation through the database's elements. Put another way, with a GUI, you don't have to remember (or type correctly) the exact names of things. The GUI will figure them out, display them, and let you select them. In addition, a GUI's editing capabilities are typically more sophisticated than what's available at the command-line interface.
In this article, we'll examine four open source MongoDB GUI management tools:
RockMongo, a PHP-based application with a surprising array of features
phpMoAdmin, also written in PHP, based on a compact framework that reduces the footprint to a single PHP file
UMongo, a Java-based application that is both full-featured and easy to navigate
Genghis, a clean and straightforward GUI management console that has been released in both Ruby and PHP
I tested these management consoles on a small MongoDB cluster running in an array of virtual machines. I ran the applications on Windows 7 and Linux client systems, but they are all written in languages that allow them to run on any popular operating system.
Genghis: Clean GUI, PHP or Ruby
Genghis is unique in that versions exist for both Ruby and PHP. I had problems installing the Ruby version, which has many dependencies. Ultimately, I used the PHP version. It is a single file, and it can be launched from the command line to be executed within PHP 5.4's built-in Web server. Genghis's creator, Justin Hileman, assured me that the PHP version was identical to the Ruby version.
Launch Genghis in the PHP Web server and point your browser to the port you've selected as one of the command-line arguments -- there's Genghis. The PHP version's only external dependency is PHP's MongoDB driver.
Genghis's layout is sheer simplicity. Everything that isn't a BSON document is displayed in tables. Of course, the content of a given table depends on the level you're at. The top level is Servers. Click on a server from the displayed table of MongoDB servers and you drill down a level to databases. Click on an entry in the table of databases; down a level you go to collections. Select a collection and you come to the lowest level: documents.
All the while, Genghis displays a breadcrumb trail at the head of every page. With Genghis, you always know where you are. Hover over any element in the trail, and a pop-up shows overview stats at that level. For example, hover over a database item, and the pop-up shows a list of the databases on the server, plus the number of collections in each database.
The table at the server level shows the number of databases on each server, as well as the space consumed by the databases on that server. At the database level, the table displays a separate row for each database, with a column for the number of collections and a column for the space consumed by each database. Choose a collection, and the subsequent table shows the number of documents in the collection, the number of indexes, and the space consumed.
An Add button appears at each level for creating a new item at that level. For example, on the server level you'll find an "Add server" button (to add an existing server to Genghis's internal server list), on the database level an "Add database" button (to create a new database), and so on.
The rightmost column in every Genghis table is blank. Hover over any row in a table, and a red Remove button appears in that column. This is how you delete elements in Genghis. Move your mouse pointer to the rightmost column of a row in the collections table, click Remove, and you're prompted to remove the corresponding collection.
Many fields in Genghis's tables provide hover-over pop-up windows that display additional information associated with the field. Such fields are identified by dashed underscores. For example, hover over the Size field for a database, and the pop-up shows the average object size, the size of the data component of the database, the size of its index component, and the amount of storage space used by the database.
At the lowest level of object hierarchy in Genghis, the document level, Genghis abandons tables and displays BSON documents in what amounts to a vertical list of group boxes. This display appears when you choose a collection, and Genghis will paginate the documents so that only 50 are displayed at a time. (This number, unfortunately, is not configurable.)
Move your cursor into any document's text box, and Edit and Delete buttons appear in the upper-right corner. Delete is obvious. Click the Edit button, and the group box is converted to a text box, allowing you to modify the document's BSON.
You issue queries via a one-line text box at the top of the documents page. The query text box allows the shorthand of entering just a document ID to fetch individual documents. Alternatively, you can enter standard MongoDB BSON. Beneath the query text box you'll see three horizontal lines. Click those, and the text box expands from one line to five, allowing you to enter more complex queries. However, you can only enter query documents into this text box -- you cannot enter projection documents. In addition, the query text box doesn't handle the display of large queries very well. No scroll bars appear, so it's easy to lose the first and last line above or below the text box's upper or lower borders.
Finally, a drop-down menu next to the "Add collection" button lets you introduce a GridFS collection. Unfortunately, Genghis stumbled altogether at this point. Though we could create a GridFS collection, Genghis displayed "Unknown error" whenever we tried to upload a file into the collection. In addition, even though we could add files to the GridFS collection by other means, Genghis could not even open the fs.files collection. (When you create a GridFS file system in MongoDB, two collections are created. One stores the metadata information about the file including its name, its size, and so on. This is the fs.files collection. The other collection, called fs.chunks, stores the data of the file itself.) Trying to display the contents of fs.files, Genghis would simply lock up, displaying a never-ending progress bar.
Genghis at least deserves praise for its clean interface. But until the issues are ironed out and a bit more functionality is added, I would recommend Genghis only for performing basic MongoDB operations.
phpMoAdmin: Easy install, busy GUI
Obviously named after phpMyAdmin -- the well-known PHP-based GUI administration tool for MySQL -- phpMoAdmin is a single-file application. The entirety of phpMoAdmin resides in a solitary PHP file, moadmin.php. This, of course, makes it exceedingly easy to install. Just create a folder in your Web server's webroot directory, drop the moadmin.php file into it, and you're set.
Being in a single PHP file doesn't mean that phpMoAdmin is unconfigurable, however. Open moadmin.php, and you'll find various configuration options that can be enabled by uncommenting the lines that contain them. For example, by default, phpMoAdmin provides no user authentication. Uncomment one line, edit in an administrator name and password, and access authentication will be required when phpMoAdmin launches. You can also configure phpMoAdmin to use one of three display themes.
phpMoAdmin owes its slender size to its origina as a stripped-down version of the open source Vork Enterprise Framework , an MVC framework for building PHP Web applications. The full Vork Framework is about 500K, but the designers of phpMoAdmin whittled it down to less than 100K for phpMoAdmin. (The phpMoAdmin file itself is about 113K.) The designers chose the Vork Framework because, at the time of phpMoAdmin's inception, Vork was the only framework with integrated MongoDB support.
Start phpMoAdmin, and in the upper-left corner of the screen, you'll see a drop-down from which you can select one of the available databases that phpMoAdmin has found on the current host. (You can configure phpMoAdmin to connect to a server on a remote host, but you must modify the moadmin.php file to do that.) To the right of the drop-down is a "Change database" button, which you click to actually cause the database in the drop-down to become the current database on which operations can be performed.
Also in the upper part of the page you'll find links for "Repair database" and "Drop database," which act on the current database. You can tell which database is current because its name is displayed in an oversized font next to the "Change database" button. The Repair link will issue the repairDatabase operation on a database (recommended only in exceptional circumstances, because repairDatabase obtains a global lock on the database while it's doing its work). I was told by the phpMoAdmin team that the Repair capability is a holdover from the early days of MongoDB, when the database often became corrupted. The Drop link's function is self-evident.
You'll find no fancy graphical icons on any of the controls in phpMoAdmin. An object that can be edited will have the hyperlinked text [E] displayed adjacent to its name; adjacent to an object that can be deleted, you'll find a [X] hyperlink. So click the [E] link next to a collection's name to change that name. Click the [X], and you're asked if you really want to delete that collection.
Select a database, and phpMoAdmin displays a list of the collections in the database. Click on a collection, and you're shown the first 100 documents in the collection. (You can alter the number of documents displayed per page by editing the moadmin.php file, or by entering a value in the limit textbox that's displayed when you select a database.) The universal fast-forward and fast-reverse indicators (>>> and <<<) appear when the number of documents in a collection exceeds what can be displayed on a single page.
By clicking the "Show Database & Collection selection" link, you can combine the view of the current database and its collections plus the currently selected collection and its first 100 documents. This makes for a busy display and reveals one of phpMoAdmin's major weaknesses: You can easily become lost in it.
Once you've selected a collection, new links appear for operating on the collection:
Insert new object. Click this, and you're taken to a text box where you can enter a new document. You'll notice that the textbox is pre-filled with the text array(...), which tells you immediately that you have to use the PHP associative array syntax to specify the documents.
Show indexes. This selection displays those fields for which indexes are currently defined. It also provides a text box for defining a new index for the documents' fields. You can also create compound indexes, and you can specify whether each index component is ascending or descending on a per-field basis.
Export and Import. These options let you write or read the BSON text (as a *.json file) of database documents. The Export command will write out the results of the currently displayed query. Note that these commands process document definitions in BSON syntax, not the PHP associative array syntax.
Sort. The Sort menu item will allow you to choose a field and sort the displayed records by that field either in ascending or descending fashion.
Search. Not to be confused with the Query menu selection, Search lets you pick a single document field from a drop-down control and enter a search value. The result amounts to a find-if-equal query on a single document field.
Query. Choosing this menu item opens a text box that lets you enter complex query expressions. Note that you have to use the PHP associative array syntax. For example, to locate all documents for which the isMarried field is 1, you'd enter array("isMarried" => 1).
There is no mechanism for specifying a query's projection document, by which you can limit the result's fields. Also, anything entered in the Search selection (above) narrows the query such that only elements that match the search criteria will be queried.
phpMoAdmin isn't going to win any visual design awards. The arrangement of visual elements, as well as the labeling of controls, is initially confusing. For example, the "Change database" control doesn't change anything -- it selects the current database. Navigation is inconsistent, too. It's frequently unclear what button or link you must push to go back to the previous screen. Sometimes the only cure is to return to the top-most level and drill back down to where you had been.
As is the case with most of the other GUI management tools in this review, phpMoAdmin comes with no significant user's guide. Pretty much all the documentation you'll find is on the product's one-page website. You'll need to explore to discover how different parts of phpModAdmin behave -- such as the unexpected simultaneous effects of Search and Query.
RockMongo: Flexible and extensible
RockMongo is a browser-based management application written in PHP. It requires at least PHP 5 to execute. Beyond that, its only other dependency is the php_mongo driver (detailed information for which can be found at php.net).
You can configure RockMongo to use either the authentication provided by MongoDB itself or a hard-coded administrator name/password pair in the application's config.php file. (MongoDB authentication, which is disabled by default, stores user credentials in a special "system" collection in the database. Each document in this collection maps user names to user roles.) You'll need to modify config.php in any case to set parameters such as the GUI's theme and the IP address and port of the MongoDB server.
Launch your browser and point it to RockMongo's Web page; you'll see it's arranged in the familiar navigation-area-on-left, workspace-on-right fashion. Navigation is via a database explorer tree. Click a database's node in the tree, and RockMongo opens a subtree bedecked with subnodes representing that database's collections. Click a collection, and the work area opens a set of menus whose commands provide the MongoDB equivalent of CRUD operations. You can issue a query, insert a document, clear the entire collection, and so on.
RockMongo's interface is, for the most part, uncomplicated. To create a database, click the Databases menu item, select Create a New Database, enter a name, click OK, and there you go. This is in keeping with MongoDB's (sometimes dangerously) simple mechanism for creating databases or collections. There are few parameters to adjust. You just create a database, put a collection in it, and start filling that collection with documents.
As you navigate through the components of a MongoDB instance, the upper portion of the work area provides either a context-aware menu or an interactive breadcrumb trail tracing your route. With a database selected, the context-aware menu presents the following options:
Statistics. This entry displays information such as the number of collections, the number of documents, the number of indexes defined, and the amount of space used for storage.
Create a new collection. RockMongo lets you specify that a collection be capped, which sets a limit on the number of documents that can be added to the collection as well as the storage space that can be consumed. When the storage limit is reached, the introduction of a new document causes old documents to be discarded in an "oldest first" fashion.
Command. Choose Command, and RockMongo takes you out of the Databases breadcrumb trail and presents you with a different set of menus (a shift of context that can be initially confusing). A text box allows you to enter the BSON expression for a database command. In case you don't remember what those commands are (there are lots), RockMongo thoughtfully provides a link to the proper spot in the MongoDB documentation where you can peruse the entire list of MongoDB commands.
Transfer. The Transfer menu selection copies a database from one system to another. Specify the IP address of the target database's host, username, and password for authentication, select the collections to copy, and RockMongo will transfer from the source to the destination.
Other commands in the database menu let you perform user authentication, issue repairs on the database, or drop the database.
When you drill down to a single collection, RockMongo displays that collection's documents in the lower portion of the work area. A query text box is displayed in the upper portion. Each document appears in its own mini-window that's topped with a list of menu commands for operating on that document. You can update (edit) a document, delete it, add a new field, or duplicate it. (Duplicating a document produces a new document whose fields have the same values as the original, with the exception of the _id field.) There's also a Text menu item that, when clicked, displays the document in a text box, suitable for cutting and pasting.
The Query menu selection (above the text box) reveals one of RockMongo's welcome nuances. Typically, when you enter a document (and MongoDB queries are expressed as documents) you specify its structure in BSON. However, PHP applications almost always represent MongoDB's documents using PHP's syntax for associative arrays. Because RockMongo is written in PHP, one might expect it to recognize only the associative array syntax. But RockMongo lets you choose either.
Type in a query, click Submit, and the documents satisfying the query are displayed in the lower half of the work area, 10 at a time. Click the Explain button to produce a document that is MongoDB's "explanation" of how queries are handled in the current environment. There's plenty of good information to be had from this. For example, for queries on a sharded cluster, the explanation document will tell you whether the server executed shard queries sequentially or in parallel. You can see the number of milliseconds the query required on each shard (there is a subdocument for each shard server). You can also see the number of documents scanned on each shard. From this I learned that all of my documents had been placed on a single shard of my two-shard server cluster.
RockMongo can be extended via plug-ins. A RockMongo plug-in operates as a sort of combination filter and event listener. RockMongo exports workflow points at which filters can be attached. When you register a plug-in, the filters are hooked to those points. For example, the SERVER_MENU_FILTER hook can be used to add menu items to the Server menu. Plug-ins can also define controllers, which can be associated with buttons to provide additional functionality in RockMongo. Currently, three plug-ins are available: a mapreduce plug-in, a sharding plug-in, and a plug-in that provides tools for the MongoDB system.js collection, which stores MongoDB's equivalent to stored procedures.
RockMongo's documentation is painfully limited -- though this is true of all four products in this review. If you're looking for an online manual, all you'll find is a wiki page displaying a list of features, a link to installation instructions, and a link to the download page. You'll also find a Manuals item on the main RockMongo menu, but it's no more than a list of links to other Web pages, mainly pages on the MongoDB website.
The entire layout of RockMongo is well thought out, and lots of good statistics are available at every level. Setup is simple, the transfer function is handy, and RockMongo's ability to traffic in either BSON or the PHP syntax is particularly welcome.
UMongo is a stand-alone Java application created by Antoine Girbal, who works for 10Gen as a software engineer. (Girbal is quick to say that UMongo is his own creation and is in no way endorsed by 10gen itself.) UMongo requires at least Java 1.6.
Launch UMongo, open its connection dialog, connect to a running MongoDB server, and you're presented with a three-pane window: navigation pane on the left, current object statistics pane in the upper right, and results pane in the lower right. The content of the statistics pane depends on which component is selected in the navigation pane. Select a sharded database cluster, for example, and you're shown connection information for the cluster server itself (such as the host running the mongos instance that handles request routing for that cluster), as well as connection information for each shard member.
Items in the results pane are virtually always BSON documents. UMongo displays documents in a tree control, so you can expand or collapse the output as needed. In fact, tree controls are used throughout UMongo. The hierarchical view in the navigation pane, for example, is a tree control.
Above the statistics pane, a context-aware menu alters its contents based on which object is selected in the navigation pane. For example, choose a database in the navigation pane, and the menu becomes:
Database. Items on this menu let you create a new collection, refresh the display (in the navigation pane), or drop the selected database.
User. Here you can authenticate an existing user or add or remove users. The authenticate command works only if authentication is enabled for the database (by default, it is not). It is effectively a login command for the user name and password specified.
Sharding. This menu exists both at the server and the database level. At the server level, the menu selections will list the shard servers that are currently in the cluster, add a shard server to the cluster, or remove a shard server. Here you'll also find a flush operation, which flushes the cached metadata in the mongos process. At the database level, items on this menu let you enable sharding for the database, display shard-specific information about the database (for example, which member of the cluster is the primary shard server), and move the primary server to another member of the cluster.
GridFS. This menu selection lets you manipulate files in MongoDB's GridFS file system (assuming you've defined one for the database you're connected to). It opens a file browser from which you can upload files into the GridFS, or download files, which copies the files out of the GridFS.
The GridFS menu also provides a selection to delete GridFS files. Sadly, the response document only indicates whether the delete command executed -- not whether the deletion actually occurred. You have to watch the document count that is displayed next to the fs.files collection in the database navigation tree displayed in the left-hand pane.
Tools. This menu also differs depending on whether a server, database, or collection is selected. At the server level, you can enable or disable auto-balancing (the process that MongoDB runs to keep shards balanced across the members of a sharded cluster). Or you can regenerate the configuration database, which is the server's internal description of the cluster configuration.
Finally, at the collection level, the Tools menu has entries that let you validate the structure of the collection, rebuild a collection's indexes, compact a collection, set various database options associated with collections, and so on.
A failure in UMongo can sometimes result in a Java exception being thrown. For example, if you try to upload into the GridFS a file that doesn't exist, you don't get a nice, neat error message -- you get a stack dump. The system displays a dialog box showing not only the details of the command that had been issued, but a Java stack trace of the exception as well from which it's pretty easy to deduce what went wrong. Although this is disconcerting -- when it first occurred, I wondered if something had broken -- it doesn't derail UMongo. Just close the dialog box and continue working.
While this article was being written, a new version (1.4.0) of UMongo was released. Version 1.4.0 adds support for MongoDB's user roles by providing a graphical interface that mimics the capabilities to be found in the mongo shell's addUser command. It also adds controls for the sharding balancer. For example, version 1.4.0 lets you set the time window when the balancer runs, so you can schedule the balancer to execute during low-traffic periods of the day. The new version also has support for TTL (time to live) collections. When a document is inserted into a TTL collection, the system appends an insertion time. After the specified TTL passes, MongoDB will delete the document.
UMongo's interface is easy to navigate, clean, and understandable. In addition, you have access to plenty of configuration preferences. For example, you can select what type of socket is used to connect (plain or secure). You can also control the details of the connection pool that UMongo uses. UMongo lets you simultaneously connect to as many MongoDB servers as your client system's processor and memory can handle.
My main complaint with UMongo is the same as with the other tools. The only documentation available is on the product Web page, and it's limited to a features list and brief installation instructions.
MongoDB tools with a view
None of the MongoDB management tools reviewed here have user documentation worth mentioning. The thinking seems to be that, with a bit of tinkering, even novice MongoDB users will be able to find their way around. That may or may not be true, but it certainly means you should not turn any of these tools loose on a production database until you've worked with them extensively in a test environment.
Of the tools I tested, RockMongo and UMongo had the broadest selection of features. But only UMongo had complete support for GridFS, though ostensibly Genghis should have as well, once the "Unknown error" issue is resolved. RockMongo only allows downloading the chunks in a GridFS collection, while phpMoAdmin has no GridFS support that I could find. Whereas only RockMongo had the handy database transfer capability, the same can be accomplished in the other tools by exporting and importing, though less elegantly.
phpMoAdmin is fine if you want a tool that's easy to install, but you'll need to spend some time exploring its quirky interface. I really wanted to like Genghis, with its straightforward tabular display, but it needs to solve some functional problems before I could recommend it over RockMongo or UMongo.
None of these GUIs is a complete replacement for the Mongo shell. But if you need to quickly create a new database or collection, rapidly throw together a query, or select and modify specific documents, these can be handy tools to have ready on your desktop. And the price is certainly right.
Join the CIO Australia group on LinkedIn. The group is open to CIOs, IT Directors, COOs, CTOs and senior IT managers.