q0987
q0987

Reputation: 35982

Setup Shards: Should I install MongoDB on the following servers

Following the Oreily Scaling MongoDB book (i.e. Page 27), I saw the following command:

Once you’re connected, you can add a shard. There are two ways to add a shard, depending on whether the shard is a single server or a replica set. Let’s say we have a single server, sf-02, that we’ve been using for data. We can make it the first shard by running the addShard command:

> db.runCommand({"addShard" : "sf-02:27017"})
{ "shardAdded" : "shard0000", "ok" : 1 }

Question 1>: What should be done on the servers of sf-02? Should I also install MongoDB on it? If any, which package?

For example, if we had a replica set creatively named replica set “rs” with members rs1-a, rs1-b, and rs1-c, we could say:

> db.runCommand({"addShard" : "rs/rs1-a,rs1-c"})
{ "shardAdded" : "rs", "ok" : 1 }

Question 2>: where is "rs" located?

Question 3>: Does rs1-a, rs1-c share the same machine?

Upvotes: 0

Views: 140

Answers (1)

ALoR
ALoR

Reputation: 4914

reply 1: you should run mongod with the --shardsvr option to start it as a shard server. each shard server has to know that it is will receive a connection from a mongos (the shard router).

reply 2: 'rs' is the name of a replica set, a set is just a group of machine (usually 3). so it is not located on a single machine, it is an abstract entity which represent the group of machine in the set.

reply 3: no. for testing purpose you can run replica set on the same machine, but the purpose of a replica set is failover. in production you should use different machine for every member of the set.

Upvotes: 1

Related Questions