Database Reference
In-Depth Information
9.2.1
Setup
You set up a shard cluster in two phases. In the first, you start all the required mongod
and mongos processes. In the second, the easier of the two, you issue a series of com-
mands to initiate the cluster. The shard cluster you'll build will consist of two shards
and three config servers. You'll also start a single mongos to communicate with the
cluster. Figure 9.2 shows a map of all the processes that you'll launch with their port
numbers in parentheses.
You'll be running a bunch of commands to bring the cluster online, so if you find
yourself losing the forest for the trees, refer back to this figure.
S TARTING THE SHARDING COMPONENTS
Let's start by creating the data directories for the two replica sets that will serve as our
shards.
$ mkdir /data/rs-a-1
$ mkdir /data/rs-a-2
$ mkdir /data/rs-a-3
$ mkdir /data/rs-b-1
$ mkdir /data/rs-b-2
$ mkdir /data/rs-b-3
Next, start each mongod . Because you're running so many processes, you'll use the --
fork option to run them in the background. 5 The commands for starting the first rep-
lica set are shown next.
mongod
(30000)
mongod
(30100)
mongod
arbiter
(30002)
mongod
arbiter
(30102)
mongod
(30001)
mongod
(30101)
Shard A
Shard B
g
server
(27019)
g
server
(27020)
mongos
(40000)
Reads and writes
g
server
(27021)
Ruby application
( load.rb )
Figure 9.2 A map of
processes comprising the
sample shard cluster
g cluster
App and router
5
If you're running Windows, note that fork won't work for you. Because you'll have to open a new terminal
window for each process, you're best off omitting the logpath option as well.
Search WWH ::




Custom Search