|
For production use you will want a minimum of three nodes in the replica set. Either:
To avoid a single point of failure, these nodes must be on different computers.
Basic Configuration
Example: 3 full serversIn this example, three servers are connected together in a single cluster. If the primary fails any of the secondary nodes can take over. Getting Started – A sample sessionThe following is a simple configuration session for replica sets. For this example assume a 3-node Replica set with 2 full nodes and one arbiter node. These servers will be named sf1, sf2 and sf3. Step 1: Start mongod with --replSetOn each of the servers start an instance of the mongo daemon: sf1$ mongod --rest --replSet myset sf2$ mongod --rest --replSet myset sf3$ mongod --rest --replSet myset
Step 1a: Check the Replication UI (optional)Visit http://sf1:28017/_replSet, this will give you an idea on the current status of the replica set. As you proceed through the remaining steps, refreshing this dashboard to see changes. See the docs here for more details. Step 2: Initiate the replica setConnect to mongo on sf1. $ mongo --host sf1
> rs.initiate()
{
"info2" : "no configuration explicitly specified -- making one",
"info" : "Config now saved locally. Should come online in about a minute.",
"ok" : 1
}
>
Step 3: Add nodes to the replica set$ mongo --host sf1
> rs.add(“sf2”)
{ “ok” : 1 }
> rs.addArb(“sf3”)
{ “ok” : 1 }
Any operations that change data will now be replicated from sf1 to sf2. If sf1 is shut down, you will see sf2 take over as primary Changing Client Code
|


PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.
blog comments powered by Disqus