How to Manage MongoDB on OpenShift with RockMongo

In keeping with the tradition of improving developers lives by providing a platform that eases the deployment and management of applications in the Cloud, OpenShift is pleased to provide the RockMongo graphical front-end for administering MongoDB collections for your applications.  If you’ve read and/or used the phpMyAdmin functionality discussed in this blog, you’ll feel right at home.  If you haven’t, you’ll still feel comfortable administering your MongoDB databases  because it is so easy and fun!

This geekfest builds on the foundation laid out in my ‘Deploying a PHP Twitter App in the Cloud with MongoDB & OpenShift’ blog but the steps apply to all OpenShift application types.  You can add RockMongo to your Java, Perl, PHP, Python, and Ruby apps!

We’re going to start with the PHPMongoTweet application deployed with a few tweets already stored in the database.  Prior to adding the administrative front-end the only way to make changes to the database is either by command line or by adding some code to your application and pointing your browser to the URL that runs the code.  That just won’t scale as you are iteratively developiong your application.  So let’s go ahead and add the RockMongo embeddable cartridge to our ‘phpmongotweet’ application.

Step 1
Adding RockMongo requires using the ‘rhc-ctl-app’ command and specifying that we would like embed a cartridge:
rhc-ctl-app -a phpmongotweet -e add-rockmongo-1.1

Step 2
The output of this command tells us that we can now access our adminitstrative front-end by visiting https://phpmongotweet-$namespace.rhcloud.com/rockmongo.  Make note of the username/password because you will need them to log in to RockMongo.

With this interface, you can administer your MongoDB collections for your application.

For example, I can browse through the tweets collection in the phpmongotweet database:

 

OpenShift RockMongo MongoDB Browse Screenshot image

 

I can delete record(s) from the collection:

OpenShift RockMongo MongoDB Delete Records Screenshot image

 

I can export data from any/all collections (handy for moving data between apps):

OpenShift RockMongo MongoDB Export Screenshot image

 

I can also get statistics on a collection:

OpenShift RockMongo MongoDB Statistics Screenshot image

 

This is just a small set of administrative tasks that you can use RockMongo for.  I’ve also included a video below that walks through adding RockMongo to an application and performing some administrative tasks.

Want to see more of the MongoDb and OpenShift goodness live? Then sign up for our webinar with 10Gen on Dec. 20.

Thanks for tuning in!

Categories
MongoDB
Tags
Comments are closed.