Database Reference
In-Depth Information
$ mongod --shardsvr --replSet shard-a --dbpath /data/rs-a-1 \
--port 30000 --logpath /data/rs-a-1.log --fork --nojournal
$ mongod --shardsvr --replSet shard-a --dbpath /data/rs-a-2 \
--port 30001 --logpath /data/rs-a-2.log --fork --nojournal
$ mongod --shardsvr --replSet shard-a --dbpath /data/rs-a-3 \
--port 30002 --logpath /data/rs-a-3.log --fork --nojournal
And here are the commands for the second one:
$ mongod --shardsvr --replSet shard-b --dbpath /data/rs-b-1 \
--port 30100 --logpath /data/rs-b-1.log --fork --nojournal
$ mongod --shardsvr --replSet shard-b --dbpath /data/rs-b-2 \
--port 30101 --logpath /data/rs-b-2.log --fork --nojournal
$ mongod --shardsvr --replSet shard-b --dbpath /data/rs-b-3 \
--port 30102 --logpath /data/rs-b-3.log --fork --nojournal
As usual, you now need to initiate these replica sets. Connect to each one individually,
run
rs.initiate()
, and then add the remaining nodes. The first should look like this:
6
$ mongo arete:30000
> rs.initiate()
You'll have to wait a minute or so before the initial node becomes primary. Once it
does, you can add the remaining nodes:
> rs.add("arete:30000")
> rs.add("arete:30001", {arbiterOnly: true})
Initiating the second replica set is similar. Again, wait a minute after running
rs
.initiate()
:
$ mongo arete:30100
> rs.initiate()
> rs.add("arete:30100")
> rs.add("arete:30101", {arbiterOnly: true})
Finally, verify that both replica sets are online by running the
rs.status()
command
from the shell on each one. If everything checks out, you're ready to start the config
servers.
7
Now you create each config server's data directory and then start a
mongod
for
each one using the
configsvr
option:
$ mkdir /data/config-1
$ mongod --configsvr --dbpath /data/config-1 --port 27019 \
--logpath /data/config-1.log --fork --nojournal
$ mkdir /data/config-2
$ mongod --configsvr --dbpath /data/config-2 --port 27020 \
--logpath /data/config-2.log --fork --nojournal
$ mkdir /data/config-3
$ mongod --configsvr --dbpath /data/config-3 --port 27021 \
--logpath /data/config-3.log --fork --nojournal
6
arete
is the name of the local host.
7
Again, if running on Windows, omit the
--fork
and
--logpath
options, and start each
mongod
in a new
window.