Take the 2-minute tour ×
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 want to keep MongoDB and Solr in sync. The mongodb-connector (python) is the tool I want to use to do that. Now a replica set in mongodb is required (see ReadMe), but I don't want (and can) setup a set/instance.

So can I have a replica set setup with only the primary and without secondaries? Means: A replica set setup with only one instance? And how does this

Meanwhile I found a solution:

  1. Add in the config-File following:
    • replSet=rs0 (name is variable) (necessary because starting mongod with replSet option didn't work)
    • oplogSize=[MemSize]
  2. Start mongodb-instance:
    • sudo /etc/init.d/mongod start
    • mongo
  3. Set replicaset:
    • rs.initiate({"_id" : "rs0","version" : 1,"members" : [{"_id" : 0,"host" : "localhost:27017"}]})
    • Check with rs.status()
share|improve this question

1 Answer 1

You can start a single node replica set by starting the mongod with the replSet argument/config option, that is all that is required. It takes a name argument, which will then function as the name of the replica set in question. Once you have done that, you simply run rs.initiate() from the shell when connected to the node (this is only needed once).

This is described in detail here:

http://docs.mongodb.org/manual/tutorial/convert-standalone-to-replica-set/

To stay with just a single node, simply do not follow the "Expanding the set" instructions.

share|improve this answer
    
That didn't work. Meanwhile, I found a solution which is similar to yours: (edit will come soon.) –  MUmla Nov 27 '13 at 10:22
    
Odd, because I have done this maybe.......30 times when testing without a problem, and those are the official docs too –  Adam C Nov 27 '13 at 10:40
    
(See my solution in the question above.) –  MUmla Nov 29 '13 at 10:02
    
your solution is identical to the one I provided, all you did was fill in variable names - if you do not specify an initial replica set name, it is filled in by default as the current process. Similarly oplogSize is optional - if you do not specify it, it will default to 5% of free space. Similarly, none of the other commands are optional and are not required to provision an oplog or set up a single node replica set. –  Adam C Nov 29 '13 at 20:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.