On this page本页内容
killOp
Terminates an operation as specified by the operation ID. 根据操作ID指定终止操作。mongosh provides the 提供db.killOp() helper. db.killOp()帮助器。To find operations and their corresponding IDs, see 要查找操作及其对应的ID,请参阅$currentOp or db.currentOp().$currentOp或db.currentOp()。
The killOp命令必须针对killOp command must be run against the admin database.admin数据库运行。
To run killOp, use the 要运行killOp,请使用db.runCommand( { <command> } ) method.db.runCommand( { <command> } )方法。
The command has the following form:命令的格式如下:
{ "killOp": 1, "op": <opid>, comment: <any> }
op | number | |
comment | any |
|
Do not use 不要使用killOp to terminate an in-progress index builds in replica sets or sharded clusters. killOp终止副本集或分片集群中正在进行的索引构建。Use 在dropIndexes on the primary to drop the index. primary节点上使用dropIndexes来删除索引。See Stop In-Progress Index Builds.请参阅停止进行中的索引生成。
On systems running with 在authorization, to kill operations not owned by the user, the user must have access that includes the killop privilege action.authorization运行的系统上,要终止不属于用户的操作,用户必须具有包括killop权限操作在内的访问权限。
Starting in MongoDB 4.0, the 从MongoDB 4.0开始,killOp command can be run on a mongos and can kill queries (i.e. read operations) that span shards in a cluster. killOp命令可以在mongos上运行,并可以终止跨越集群中分片的查询(即读取操作)。The 当要终止的操作是写操作时,killOp command from the mongos does not propagate to the shards when the operation to be killed is a write operation.mongos的killop命令不会传播到分片。
For information on how to list sharding operations that are active on a 有关如何列出mongos, see the localOps parameter in $currentOp.mongos上活动的分片操作的信息,请参阅$currentOp中的localOps参数。
For more information and examples on killing operations on a sharded cluster, see:有关在分片化集群上终止操作的更多信息和示例,请参阅:
The following example uses 下面的示例使用killOp to target the running operation with opid 3478.killOp以opid 3478的运行操作为目标。
db.adminCommand( { "killOp": 1, "op": 3478 } )
The operation returns the following result:该操作返回以下结果:
{ "info" : "attempting to kill op", "ok" : 1 }
killOp reports success if it succeeded in marking the specified operation for termination. 如果成功将指定操作标记为终止,则报告成功。Operations may not actually be terminated until they reach an appropriate interruption point. 在达到适当的中断点之前,操作可能不会实际终止。Use 使用$currentOp or db.currentOp() to confirm the target operation was terminated.$currentOp或db.currentOp()确认目标操作已终止。