简体   繁体   中英

Sharding MongoDB

I have 6 VMs (Master, 3 configsvr and two shards); I want to add replicasets to my shards.

Is it possible to set a shard as a replication of another shard and vice versa? Or should I add other VMs as replicasets of shards?

In short: you should add new VMs for the new replicaset nodes, and you need to be careful with the shard cluster configuration.

To answer your first question:

Running two mongod instances on a single host (as two nodes of different replica sets) would get you into difficulties, with RAM usage for example, so you should avoid that. Instead, each replicaset node should be on a different host (different VM).

And to expand on the issue of shard cluster configuration:

Currently, the cluster configuration will have each shard registered as a standalone instance, eg

{ "_id" : "shard0000", "host" : "vms2:30000" }

After you have converted your standalone instance to a replica set , the shard cluster config will need to be updated to match :

Connect to one of the sharded cluster's mongos instances and issue a command in the following form:

db.getSiblingDB("config").shards.save(
{_id: "«name»", host: "«replica-set»/«member,»«member,»«...»" }
)

Replace «name» with the name of the shard. Replace «replica-set» with the name of the replica set. Replace «member,»«member,»«...» with the list of the members of the replica set.

Restart all mongos instances. If possible, restart all components of the replica sets (ie, all mongos and all shard mongod instances).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM