DaedTech

Stories about Software

By

Configuring Fedora and MongoDB

In my last post, I covered installing MongoDB on Fedora. This is another post as much for my reference as for anything else, and I’ll go over here getting set up so that my application successfully uses the MongoDB server.

When I left off last time, I had successfully configured the server to allow me to create documents using the mongo command line utility. So, I created a collection and a document and was ready to access it from my web application. Following the examples in the MongoDB java tutorial, I created the following implementation of my HouseService interface that I had previously hard coded room values into:

I felt pretty good about that, and so I fired up the local process and promptly got an error:

IP address was resolving correctly, but a cryptic “NoRouteToHoseException”. I deployed my app to the server, “daedalus” and it ran fine, as-is. I was glad to see that my code was working as I expected with Mongo, but I didn’t want to have to deploy to the server every time I wanted to run the application, so I started poking around for a fix. I had no luck connection through the browser either. Something was strange.

At this point, I remembered a similar annoyance in dealing with MySQL, and for some reason “iptables” popped into my head. After poking around a little for syntax particulars, I ran the following commands:

Sure enough, that did the trick. Accessing MongoDB through the browser now yielded:

I had been struggling to figure out what I needed to do to the mongo installation, but the problem was with the Linux firewall (or, more specifically, the fact that I hadn’t set it up to allow connections on these ports). To make my changes permanent, I added the following to /etc/sysconfig/iptables

I felt good about this, since I saw my handiwork in the same file opening up ports for MySQL and Tomcat. To verify that this bit of goodness stuck around, I rebooted and re-ran the web app on my client desktop…