HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to setup a MongoDB replica set for the connector

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
thereplicamongodbsetupforhowsetconnector

Problem

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:

  • Add in the config-File following:



  • replSet=rs0 (name is variable) (necessary because starting mongod with replSet option didn't work)



  • oplogSize=[MemSize]



  • Start mongodb-instance:



  • sudo /etc/init.d/mongod start



  • mongo



  • Set replicaset:



  • rs.initiate({"_id" : "rs0","version" : 1,"members" : [{"_id" : 0,"host" : "localhost:27017"}]})



  • Check with rs.status()



In mongodb 3.2 "replSet" is changed to "replSetName"
https://docs.mongodb.com/v3.2/tutorial/upgrade-config-servers-to-replica-set/

Solution

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.

Context

StackExchange Database Administrators Q#53704, answer score: 2

Revisions (0)

No revisions yet.