On this page本页内容
killAllSessionsByPattern
The killAllSessionsByPattern
command kills all sessions that match any of the specified patterns. killAllSessionsByPattern
命令将杀死与任何指定模式匹配的所有会话。[1]
The command has the following syntax:该命令具有以下语法:
db.runCommand( { killAllSessionsByPattern: [ <pattern>, ... ] } )
The command takes an array of documents that specify the patterns to match:该命令获取指定要匹配的模式的文档数组:
Pattern | |
---|---|
{ lsid: { id : <UUID> } } | |
{ uid: <BinData> } | |
{ users: [ { user: <user>, db: <dbname> }, ... ] } | |
{ roles: [ { role: <role>, db: <dbname> }, ... ] } |
Specify an empty array to kill all sessions. 指定一个空数组以终止所有会话。[1]
To view existing sessions, see 要查看现有会话,请参阅$listSessions
operation or $listLocalSessions
.$listSessions
操作或$listLocalSessions
。
[1] | (1, 2) killAllSessionsByPattern operation ignores sessions that have transactions in prepared state. killAllSessionsByPattern 操作忽略事务处于准备状态的会话。 |
Killing a session kills any in-progress operations in the session and closes any open cursors associated with these operations.终止会话将终止会话中正在进行的任何操作,并关闭与这些操作关联的所有打开的游标。
The killed session may still be listed as a current session, and future operations may use the killed session. 被终止的会话仍可能被列为当前会话,未来的操作可能会使用被终止会话。To view existing sessions, see 要查看现有会话,请参阅$listSessions
operation or $listLocalSessions
.$listSessions
操作或$listLocalSessions
。
The killAllSessionsByPattern
operation ignores sessions that have transactions in prepared state. killAllSessionsByPattern
操作忽略事务处于准备状态的会话。Transactions in prepared state refer to transactions with write operations that span multiple shards whose commit coordinator has completed the 处于已准备状态的事务是指具有写操作的事务,这些操作跨越多个分片,提交协调器已完成"sendingPrepare" action
."sendingPrepare"
操作。
If the deployment enforces authentication/authorization, you must have the 如果部署强制执行身份验证/授权,则必须具有killAnySession
privilege action to run the killAllSessionsByPattern
command.killAnySession
权限操作才能运行killAllSessionsByPattern
命令。
For patterns that include 对于包含users
or roles
, you must also have privileges that grant impersonate
action on the cluster resource.users
或roles
的模式,您还必须具有在群集资源上授予模拟操作的权限。
Users can kill their own sessions even without the 即使没有killAnySession
privilege action.killAnySession
权限操作,用户也可以终止自己的会话。
The following operation kills all sessions:以下操作将终止所有会话:
db.runCommand( { killAllSessionsByPattern: [ ] } )
The following operation kills all sessions that have the specified 以下操作将终止具有指定uid
and whose owner has the specified role:uid
且其所有者具有指定角色的所有会话:
db.runCommand( { killAllSessionsByPattern: [ { "uid" : BinData(0,"oBRA45vMY78p1tv6kChjQPTdYsnCHi/kA/fFMZTIV1o=") }, { roles: [ { role: "readWrite", db: "test" } ] } ] } )