Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am having trouble setting up replication on a new mongoDB installation. Everything works fine when I run without replication but when I run mongod with the --replSet option, and run rs.initiate(), this command hangs. Note that I am only running a single instnace of mongod in this example. No other instances are yet running.

This question came from our site for professional and enthusiast programmers.

Did you try using localhost instead of 127.0.0.1?
–
Asya KamskyAug 15 '12 at 15:38

@asya I don't explicitly call out 127.0.0.1 anywhere in the config file. I'm not sure where I could make this change. From my understanding, the bind_ip option requires a real IP address. I did try to explicitly set this to 127.0.0.1 as well as point it to a DNS server. The first case made no difference and the latter case caused mongod to crash and never really get running.
–
Bill PeregoyAug 15 '12 at 18:38

2 Answers
2

I was able to get a solution for this problem on the mongoDB google group. Explicitly setting the oplogSize parameter in my config file solved the problem. By default, mongod tries to allocate 5% of the free space on the storage partition. I have my data on a very large shared disk and this seemed to be taking a long time. I manually set this value and the replica set came up quickly.

First of all - why do you make a replica set composed of only one member ?
Replica sets are meant to add redundancy ... you can't really do it with one member.

Second from the log you sent looks like the server doesn't respond anymore.

Be aware that at the initiation time a replica set will try to pre-allocate up to 5% for the capped collection - oplog on 64 bits systems. So if you have a large disk wait until all files are allocated - filled with zeros :). To tune it use --oplogSize.