clearJumboFlag

On this page本页内容

Definition定义

clearJumboFlag

Available starting in 4.2.3 and 4.0.15从4.2.3和4.0.15开始提供

Clears the jumbo flag for a chunk. 清除块的jumbo标志。To use the command, issue the clearJumboFlag command on a mongos instance.要使用该命令,请在mongos实例上发出clearJumboFlag命令。

Syntax语法

clearJumboFlag has the following syntaxes:具有以下语法:

db.adminCommand( {
   clearJumboFlag: "<database>.<collection>",
   bounds : <array>
} )

-OR-

// Cannot use for collections with hashed shard keys
db.adminCommand( {
   clearJumboFlag: "<database>.<collection>",
   find : <query>
} )

Command Fields

The clearJumboFlag command takes the following fields as arguments:clearJumboFlag命令将以下字段作为参数:

Field字段Type类型Description描述
clearJumboFlagstring

The namespace of the sharded collection with the jumbo chunk(s).具有巨型块的分片集合命名空间

Specify the collection's full namespace, including the database name (i.e. "<database>.<collection>")指定集合的完整命名空间,包括数据库名称(即"<database>.<collection>")

boundsarray

The exact bounds of a specific chunk. 特定块的确切边界。The array must consist of two documents that specify the lower and upper shard key values of a chunk to move:数组必须由两个文档组成,这些文档指定要移动的块的下分片键值和上分片键值:

[ { <shardKey> : <minValue> },{ <shardKey> : <maxValue> } ]

Note注意
finddocument

A specific shard key and its value contained in the jumbo chunk.巨型块中包含的特定分片键及其值。

{ <shardKey> : <value> }

Note注意

Access Control访问控制

On systems running with authorization, the user must have the clearJumboFlag privilege actions on the {db: "", collection: "" } resource.authorization运行的系统上,用户必须对{db: "", collection: "" }资源具有clearJumboFlag权限操作。

The built-in role clusterManager provides the appropriate privileges.内置角色clusterManager提供适当的权限。

Example示例

Clear Jumbo Flag for a Chunk (Range-Based Shard Key)清除区块的巨型标志(基于范围的分片键)

The sh.status() includes the following sh.status.databases.<collection>.chunk-details for the test.jumbo collection.sh.status()包含以下sh.status.databases.<collection>.chunk-details集合的chunk详细信息。

... // Content omitted for brevity
test.jumbo
         shard key: { "x" : 1 }
         unique: false
         balancing: true
         chunks:
                  shardA   2
                  shardB   2
         { "x" : { "$minKey" : 1 } } -->> { "x" : 1 } on : shardB Timestamp(3, 0)
         { "x" : 1 } -->> { "x" : 2 } on : shardA Timestamp(6, 1) jumbo
         { "x" : 2 } -->> { "x" : 3 } on : shardA Timestamp(5, 1) jumbo
         { "x" : 3 } -->> { "x" : { "$maxKey" : 1 } } on : shardB Timestamp(6, 0)

The following clearJumboFlag command specifies the bounds of the { "x" : 1 } -->> { "x" : 2 } chunk:以下clearJumboFlag命令指定{ "x" : 1 } -->> { "x" : 2 }块的边界

db.adminCommand( {
   clearJumboFlag: "test.jumbo",
   bounds: [{ "x" : 1 }, { "x" : 2 }]
} )

Upon success, the command returns "ok": 1 in its output:成功后,命令在输出中返回"ok": 1

{
   "ok" : 1,
   "operationTime" : Timestamp(1580190080, 5),
   "$clusterTime" : {
      "clusterTime" : Timestamp(1580190080, 5),
      "signature" : {
         "hash" : BinData(0,"0cYT49s72MHUYV1F2WpoEwlyeVs="),
         "keyId" : NumberLong("6786859092951433239")
      }
   }
}

The following clearJumboFlag command specifies the find field to find the chunk that contains the shard key { "x" : 2 } :以下clearJumboFlag命令指定查找字段以查找包含分片键{ "x" : 2 }的块:

db.adminCommand( {
   clearJumboFlag: "test.jumbo",
   find: { "x" : 2 }
} )

Upon success, the command returns "ok": 1 in its output:成功后,命令在输出中返回"ok": 1

{
   "ok" : 1,
   "operationTime" : Timestamp(1580191819, 5),
   "$clusterTime" : {
      "clusterTime" : Timestamp(1580191819, 5),
      "signature" : {
         "hash" : BinData(0,"N6x6drN7HUq5MR5ezUJns1rfeqY="),
         "keyId" : NumberLong("6786859092951433239")
      }
   }
}

To verify the operation, run sh.status() again. 要验证操作,请再次运行sh.status()The jumbo flag should no longer appear in its output.jumbo标志不应再出现在其输出中。

... // Content omitted for brevity
test.jumbo
         shard key: { "x" : 1 }
         unique: false
         balancing: true
         chunks:
                  shardA   2
                  shardB   2
         { "x" : { "$minKey" : 1 } } -->> { "x" : 1 } on : shardB Timestamp(3, 0)
         { "x" : 1 } -->> { "x" : 2 } on : shardA Timestamp(7, 0)
         { "x" : 2 } -->> { "x" : 3 } on : shardA Timestamp(8, 0)
         { "x" : 3 } -->> { "x" : { "$maxKey" : 1 } } on : shardB Timestamp(6, 0)

Clear Jumbo Flag for a Chunk (Hashed Shard Key)清除区块的巨型标志(哈希分片键)

The sh.status() includes the following sh.status.databases.<collection>.chunk-details for the test.jumboHashed collection. sh.status()包含以下test.jumboHashed集合的sh.status.databases.<collection>.chunk-detailsThe collection uses a hashed shard key.集合使用哈希分片键。

... // Content omitted for brevity
test.jumboHashed
         shard key: { "x" : "hashed" }
         unique: false
         balancing: true
         chunks:
                  shardA   2
                  shardB   2
         { "x" : { "$minKey" : 1 } } -->> { "x" : NumberLong(0) } on : shardA Timestamp(1, 0)
         { "x" : NumberLong(0) } -->> { "x" : NumberLong("848411777775835583") } on : shardA Timestamp(4, 0)
         { "x" : NumberLong("848411777775835583") } -->> { "x" : NumberLong("5902408780260971510") } on : shardB Timestamp(4, 1) jumbo
         { "x" : NumberLong("5902408780260971510") } -->> { "x" : { "$maxKey" : 1 } } on : shardB Timestamp(2, 2)

To clear the jumbo flag for a chunk if the collection uses a hashed shard key, use clearJumboFlag with the bounds field:若要在集合使用哈希分片键时清除块的jumbo标志,请在边界字段中使用clearJumboFlag

db.adminCommand( {
   clearJumboFlag: "test.jumboHashed",
   bounds: [{ "x" : NumberLong("848411777775835583") }, { "x" : NumberLong("5902408780260971510") }]
} )

Upon success, the command returns "ok": 1 in its output:成功后,命令在输出中返回"ok": 1

{
   "ok" : 1,
   "operationTime" : Timestamp(1580194290, 5),
   "$clusterTime" : {
      "clusterTime" : Timestamp(1580194290, 5),
      "signature" : {
         "hash" : BinData(0,"nWCqOYVrab7NEGHWoo2NYENqHR4="),
         "keyId" : NumberLong("6786875525496307742")
      }
   }
}

To verify the operation, run sh.status() again. 要验证操作,请再次运行sh.status()The jumbo flag should no longer appear in its output.jumbo标志不应再出现在其输出中。

... // Content omitted for brevity
test.jumboHashed
         shard key: { "x" : "hashed" }
         unique: false
         balancing: true
         chunks:
                  shardA
     2
                  shardB
     2
         { "x" : { "$minKey" : 1 } } -->> { "x" : NumberLong(0) } on : shardA Timestamp(1, 0)
         { "x" : NumberLong(0) } -->> { "x" : NumberLong("848411777775835583") } on : shardA Timestamp(4, 0)
         { "x" : NumberLong("848411777775835583") } -->> { "x" : NumberLong("5902408780260971510") } on : shardB Timestamp(5, 0)
         { "x" : NumberLong("5902408780260971510") } -->> { "x" : { "$maxKey" : 1 } } on : shardB Timestamp(2, 2)
Tip提示
←  checkShardingIndexcleanupOrphaned →