Question

I have a config file for mongo that specifies an alternate port:

deploy@ip-xxx-xxx-22-107 ~/app $ tail /etc/mongodb.conf
port = 27033

Not very complex. I'm trying to use a file based config instead of command line, seems like a better idea. I'm on Ubuntu 11. The docs say:

On some packaged installs of MongoDB (for example Ubuntu & Debian), the default file can be found in /etc/mongodb.conf, which is automatically used when starting and stopping MongoDB from the service

I definitely can start mongo with sudo /etc/init.d/mongodb restart but it's starting on the wrong port, 27017:

deploy@ip-xxx-xxx-22-107 ~/app $ sudo lsof -iTCP | grep mongo
mongod     3594   mongodb    5u  IPv4 260392       TCP localhost:27017 (LISTEN)
mongod     3594   mongodb    7u  IPv4 260395       TCP localhost:28017 (LISTEN)

So there's mongo, but not the right port. Whenever I try passing in a config file to the mongodb command I get an error:

 sudo /etc/init.d/mongodb -f /etc/mongodb.conf restart
 * ERROR: wrong args ( -f )

I suspect the /etc/init.d/mongodb command isn't passing on my config request when it's starting mongo. But the config file should be read by default according to the docs. Is something wrong with my Ubuntu install (it's on a PaaS host)? Is there no advantage to using /etc/init.d/mongodb so I should just ignore this? I can get it to read the config file via mongod -f /etc/mongodb.conf but my docs say to use /etc/init.d/mongodb.

Was it helpful?

Solution

Where did you install the mongo package from? If you installed from the default repositories, then you may have a very old version - I just tried on 11.04 (don't have 11.10 handy, sorry) and I got 1.6.4 which is very old (current stable release as of writing this is 2.0.2).

You should remove the version you have, and add the one from the 10gen/MongoDB repositories. The instructions for doing so are here:

http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages

That will give you the latest mongod version and likely resolve your issues, because you seem to be doing things correctly.

Once you have the mongod started, then connect to it and try running this:

use admin
db.runCommand({getCmdLineOpts: 1})

That should give you all the passed and parsed options. There is a sample output shown on the Docs page for the command. It should allow you to see where the mongod is pointing for the config file and what is being parsed from it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top