Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 53 lines (37 sloc) 2.101 kb
0b5d0974 »
2011-05-25 Added replicaset doc
1 Replicasets
2 ===========
3
4 ## Introduction
5
6 Replica sets is the asynchronous master/slave replication added to Mongodb that takes care off all the failover and recovery for the member nodes. According to the mongodb documentation a replicaset is
7
4a830191 »
2012-02-08 Modifications to markdown docs to work better
8 * Two or more nodes that are copies of each other
9 * Automatic assignment of a primary(master) node if none is available
10 * Drivers that automatically detect the new master and send writes to it
0b5d0974 »
2011-05-25 Added replicaset doc
11
12 More information at [Replicasets](http://www.mongodb.org/display/DOCS/Replica+Sets)
13
14 ## Driver usage
15
16 To create a new replicaset follow the instructions on the mongodb site to setup the config and the replicaset instances. Then using the driver.
17
18 var replSet = new ReplSetServers( [
19 new Server( 127.0.0.1, 30000, { auto_reconnect: true } ),
20 new Server( 127.0.0.1, 30001, { auto_reconnect: true } ),
21 new Server( 127.0.0.1, 30002, { auto_reconnect: true } )
22 ],
23 {rs_name:RS.name}
24 );
25
26 var db = new Db('integration_test_', replSet);
27 db.open(function(err, p_db) {
28 // Do you app stuff :)
29 })
30
31 The ReplSetSrvers object has the following parameters
32
33 var replSet = new ReplSetSrvers(servers, options)
34
35 Where
36
4a830191 »
2012-02-08 Modifications to markdown docs to work better
37 * `servers` is an array of `Server` objects
38 * `options` can contain the following options
39
40 ## Replicaset options
41 Several options can be passed to the `Replicaset` constructor with `options` parameter.
42
43 * `rs_name` is the name of the replicaset you configured when you started the server, you can have multiple replicasets running on your servers.
44 * `read_secondary` set's the driver to read from secondary servers (slaves) instead of only from the primary(master) server.
45 * `socketOptions` - a collection of pr socket settings
46
47 ## Socket options
48 Several options can be set for the `socketOptions`.
49
50 * `timeout` = set seconds before connection times out `default:0`
51 * `noDelay` = Disables the Nagle algorithm `default:true`
52 * `keepAlive` = Set if keepAlive is used `default:0`, which means no keepAlive, set higher than 0 for keepAlive
53 * `encoding` = 'ascii'|'utf8'|'base64' `default:null`
Something went wrong with that request. Please try again.