Docs 菜单
Docs 主页
/
MongoDB Manual
/ / /

clearJumboFlag

在此页面上

  • 定义
  • 兼容性
  • 语法
  • 访问控制
  • 例子
clearJumboFlag

清除数据段的 jumbo 标志。要使用该命令,请对clearJumboFlag mongos实例发出 命令。

此命令可用于以下环境中托管的部署:

  • MongoDB Atlas :用于在云中部署 MongoDB 的完全托管服务

重要

无服务器实例不支持此命令。有关更多信息,请参阅不支持的命令。

Th 命令采用以下语法:

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

-或-

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

clearJumboFlag 命令将以下字段作为参数:

字段
类型
说明
字符串

具有巨型数据段的分片 集合 的 命名空间

指定集合的完整命名空间,包括数据库名称(即 "<database>.<collection>")

阵列

特定数据段的确切边界。 该数组必须由两个文档组成,这两个文档指定要移动的数据块的下限分片键值和上限分片键值:

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

注意

文档

巨型块中包含的特定分片键及其值。

{ <shardKey> : <value> }

注意

在使用authorization 运行的系统上,用户必须具有对clearJumboFlag { db: "", collection: "" }资源 执行 操作 的权限。

内置角色clusterManager提供适当的权限。

sh.status()包括以下sh.status.databases.<collection>.chunk-details test.jumbo为collection。

... // 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)

以下clearJumboFlag命令指定{ "x" : 1 } -->> { "x" : 2 }数据段的边界

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

成功后,该命令会在输出中返回"ok": 1

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

以下clearJumboFlag命令指定查找字段以查找包含分片键{ "x" : 2 }的数据段:

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

成功后,该命令会在输出中返回"ok": 1

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

要验证操作,请再次运行sh.status()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)

sh.status()包括以下sh.status.databases.<collection>.chunk-details test.jumboHashed为collection 。collection使用哈希分片键。

... // 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)

要在集合使用哈希分片键时清除数据段的jumbo标志,请将clearJumboFlag边界字段一起使用:

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

成功后,该命令会在输出中返回"ok": 1

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

要验证操作,请再次运行sh.status()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)

提示

另请参阅:

后退

balancerStop