发布于 2015-09-14 15:04:06 | 248 次阅读 | 评论: 0 | 来源: 网络整理

sh.addTagRange(namespace, minimum, maximum, tag)

2.2 新版功能.

参数:
  • namespace (string) – Specifies the namespace, in the form of <database>.<collection> of the sharded collection that you would like to tag.
  • minimum (document) – Specifies the minimum value of the shard key range to include in the tag. Specify the minimum value in the form of <fieldname>:<value>. This value must be of the same BSON type or types as the shard key.
  • maximum (document) – Specifies the maximum value of the shard key range to include in the tag. Specify the maximum value in the form of <fieldname>:<value>. This value must be of the same BSON type or types as the shard key.
  • tag (string) – Specifies the name of the tag to attach the range specified by the minimum and maximum arguments to.

sh.addTagRange() attaches a range of values of the shard key to a shard tag created using the sh.addShardTag() method. Use this operation to ensure that the documents that exist within the specified range exist on shards that have a matching tag.

Always issue sh.addTagRange() when connected to a mongos instance.

Example

Given a shard key of {STATE:1,ZIP:1}, create a tag range covering ZIP codes in New York State:

sh.addTagRange( "exampledb.collection",
        {STATE: "NY", ZIP: {minKey:1}},
        {STATE:"NY", ZIP: {maxKey:1}},
        "NY"
        )
最新网友评论  共有(0)条评论 发布评论 返回顶部

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