Deploy a replica Set via mongodb.conf

155 views
Skip to first unread message

Tim

unread,
Oct 30, 2012, 10:49:45 AM10/30/12
to mongod...@googlegroups.com
Hello,

I deployed a replica set (later a sharding set) due to the shell commands like it is descriped in:
http://docs.mongodb.org/manual/tutorial/deploy-replica-set/

I would like to store all that information I inserted manually in the mongodb.conf -

I have 5 Server. Lets say: s2,s3,s4,s5 and s6
with:

s2: mongos - / config server where "sharding is running"

s3: 1 master process replicaset1  ; 1 arbiter for replicaset 2
s4: 1 slave process replicaset1


s5: 1 master process replicaset2  ; 1 arbiter for replicaset 1
s6: 1 slave process replicaset2

Later, there shall be a sharding set that consist of replicaset1 and replicaset2.

Question: How to modify the mongodb.conf (or multiple mongodb.conf???) in order to get such a use case?

(I think I have to define multiple processes, different ports, different folders to store information,.... - like the manually way...)

best regards,
tim

Gianfranco

unread,
Oct 30, 2012, 11:37:13 AM10/30/12
to mongod...@googlegroups.com
The same command line options can be set on the a mongodb.conf file.

Tim

unread,
Oct 31, 2012, 5:27:11 PM10/31/12
to mongod...@googlegroups.com
Hi,
thanks, I didn't find that articel -

so I have to create one config file per mongod/mongos process ( e.g. I have two processes I need two seperated files)

How do I declare an arbiter?

best regards
Message has been deleted

Tim

unread,
Oct 31, 2012, 5:39:15 PM10/31/12
to mongod...@googlegroups.com
I do have to declare if an instance is master or slave ("prim./sec.") (for replicaset), don't I?

In which order do I have to execute the config file?

Manually I would started the master node ("primary") and the do something like:

cfg = { _id: "replica1", members :[ {_id : 0, host: "host_x" }, { _id : 1, host : "host_y"}, { _id : 2, host : "host_z:port_z", arbiterOnly : true } ] }
rs.initiate(cfg)

rs.add("host_y");
rs.addArb("host_z:_port_z");


best regards

Tim

unread,
Oct 31, 2012, 5:50:58 PM10/31/12
to mongod...@googlegroups.com
edit:
my current conf file looks like:
port = 27017
fork = true
dbpath = /data/db/  
replSet = replica1

I'm missing that command that tells the prim node on which host/port to get the replica members


Am Dienstag, 30. Oktober 2012 15:49:45 UTC+1 schrieb Tim:

Octavian Covalschi

unread,
Oct 31, 2012, 5:58:57 PM10/31/12
to mongod...@googlegroups.com
Not long time ago I have followed these instructions and all worked out fine



--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

Gianfranco

unread,
Nov 1, 2012, 6:36:56 AM11/1/12
to mongod...@googlegroups.com
@Tim
If you read the first parts of the Replication Fundamentals until Consistency,
you'll understand the different from a traditional master-slave replication and the election procedure which makes sure one (an only one) of the members is Primary at any given time.
This is done thanks to the arbitrary as well.

Tim

unread,
Nov 1, 2012, 9:41:32 AM11/1/12
to mongod...@googlegroups.com
Hello,

I know about the theoretical background concerning replicasets and sharding sets - moreover I deployed a sharding set manually. But now I want to source as much as possible out (@ the conf file).
By the conf.file consists of following commands:

port = 27017
fork = true
dbpath = /data/db/
replSet = replica1
noauth = true
nssize = 16

Do I have to execute commands like

rs.initiate()
rs.add("host.port")
rs.addArb("host:port")

still manually or can I source them out into a configfile in order to automate the process?


best regards


Am Dienstag, 30. Oktober 2012 15:49:45 UTC+1 schrieb Tim:

Gianfranco

unread,
Nov 1, 2012, 11:54:48 AM11/1/12
to mongod...@googlegroups.com
Those commands only need to be run once.
Though if you want completely automate the process you can run a javascript file (.js) from the mongo shell (mongo) with those commands. 

> mongo --eval file.js

Tim

unread,
Nov 1, 2012, 12:31:18 PM11/1/12
to mongod...@googlegroups.com
okay, thank you ;)
I've got it :>


Am Dienstag, 30. Oktober 2012 15:49:45 UTC+1 schrieb Tim:
Reply all
Reply to author
Forward
0 new messages