On this page本页内容
sh.addShard(<url>)
Adds a shard replica set to a sharded cluster. 将分片副本集添加到分片群集。This method must be run on a 此方法必须在mongos
instance.mongos
实例上运行。
The sh.addShard()
method has the following parameter:sh.addShard()
方法具有以下参数:
host | string |
<replica_set>/<hostname><:port>,<hostname><:port>, ... |
The sh.addShard()
method has the following prototype form:sh.addShard()
方法具有以下原型形式:
sh.addShard("<replica_set>/<hostname><:port>")
mongos
uses 对"majority"
for the addShard
command and its helper sh.addShard()
.addShard
命令及其助手sh.addShard()
使用"majority"
。
The sh.addShard()
method is a helper for the addShard
command. sh.addShard()
方法是addShard
命令的助手。The addShard
command has additional options which are not available with this helper.addShard
命令具有此助手无法使用的其他选项。
When you add a shard to a sharded cluster, you affect the balance of chunks among the shards of a cluster for all existing sharded collections. 将分片添加到分片集群时,会影响所有现有分片集合的集群分片之间的块平衡。The balancer will begin migrating chunks so that the cluster will achieve balance. 平衡器将开始迁移块,以便集群实现平衡。See Cluster Balancer for more information.有关详细信息,请参阅群集平衡器。
Chunk migrations can have an impact on disk space, as the source shard automatically archives the migrated documents by default. 区块迁移可能会影响磁盘空间,因为默认情况下,源分片会自动归档迁移的文档。For details, see 有关详细信息,请参阅moveChunk
directory.moveChunk
目录。
You cannot include a hidden member in the seed list provided to 不能在提供给sh.addShard()
.sh.addShard()
的种子列表中包含隐藏成员。
To add a shard, specify the name of the replica set and the hostname of at least one member of the replica set, as a seed. 要添加分片,请将副本集的名称和副本集至少一个成员的主机名指定为种子。If you specify additional hostnames, all must be members of the same replica set.如果指定其他主机名,则所有主机名都必须是同一复制集的成员。
The following example adds a replica set named 以下示例添加名为repl0的副本集,并指定副本集的一个成员:repl0
and specifies one member of the replica set:
sh.addShard("repl0/mongodb3.example.net:27327")