发布于 2015-09-14 15:10:38 | 229 次阅读 | 评论: 0 | 来源: 网络整理

addShard
参数:
  • hostname (string) – a hostname or replica-set/hostname string.
  • name (string) – Optional. Unless specified, a name will be automatically provided to uniquely identify the shard.
  • maxSize (integer) – Optional, megabytes. Limits the maximum size of a shard. If maxSize is 0 then MongoDB will not limit the size of the shard.

Use the addShard command to add a database instance or replica set to a sharded cluster. You must run this command when connected a mongos instance.

The command takes the following form:

{ addShard: "<hostname>:<port>" }

Example

db.runCommand({addShard: "mongodb0.example.net:27027"})

Replace <hostname>:<port> with the hostname and port of the database instance you want to add as a shard.

警告

Do not use localhost for the hostname unless your configuration server is also running on localhost.

The optimal configuration is to deploy shards across replica sets. To add a shard on a replica set you must specify the name of the replica set and the hostname of at least one member of the replica set. You must specify at least one member of the set, but can specify all members in the set or another subset if desired. addShard takes the following form:

{ addShard: "replica-set/hostname:port" }

Example

db.runCommand( { addShard: "repl0/mongodb3.example.net:27327"} )

If you specify additional hostnames, all must be members of the same replica set.

Send this command to only one mongos instance, it will store shard configuration information in the config database.

注解

Specify a maxSize when you have machines with different disk capacities, or if you want to limit the amount of data on some shards.

The maxSize constraint prevents the balancer from migrating chunks to the shard when the value of mem.mapped exceeds the value of maxSize.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务