Initiate replica set via Ruby

241 views
Skip to first unread message

geoffr

unread,
May 4, 2011, 3:46:30 AM5/4/11
to mongodb-user
Hi,

We are busy writing a Ruby app to test that the members of a replica
set are available and if they are would like to be able to initiate
the set using puppet. The config is not yet in mongo and so the
command that we would run from the dbshell would be:

mongo admin --eval 'rs.initiate({_id: "repl_set_name", members: [{_id:
0, host: "test0"},{_id: 1, host: "test1"},{_id: 2, host:
"test2"}] }) ## which works

But I was hoping there's a mongo method available in Ruby to insert
the config and initiate it? We are using the mongo gem to test the
connection and such like (Mongo::ReplSetConnection).

Thanks
Geoff

Eliot Horowitz

unread,
May 4, 2011, 8:28:16 AM5/4/11
to mongod...@googlegroups.com
initiate is just a helper.

> rs.initiate
function (c) {
return db._adminCommand({replSetInitiate:c});
}

So you can do
DB.command( { "replSetInitiates" => { ..config.. } } ) in ruby

> --
> 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.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages