On this page本页内容
killAllSessions
The killAllSessions
command kills all sessions for the specified users. killAllSessions
命令将终止指定用户的所有会话。[1]
The command has the following syntax:该命令具有以下语法:
db.runCommand( { killAllSessions: [ { user: <user>, db: <dbname> }, ... ] } )
The command takes an array of documents where each document specifies the user and the user's authentication database. 该命令接受一组文档,其中每个文档指定用户和用户的身份验证数据库。Specify an empty array to kill all sessions for all users in the system. 指定一个空数组以终止系统中所有用户的所有会话。[1]
To view existing sessions, see 要查看现有会话,请参阅$listSessions
operation or $listLocalSessions
.$listSessions
操作或$listLocalSessions
。
[1] | (1, 2) killAllSessions operation ignores sessions that have transactions in prepared state. killAllSessions 操作忽略事务处于准备状态的会话。 |
If the deployment enforces authentication/authorization, you must have the 如果部署强制执行身份验证/授权,则必须使用killAnySession
to run the killAllSessions
command.killAnySession
运行killAllSessions
命令。
Users can kill their own sessions even without 即使没有 killAnySession
privilege action.killAnySession
权限操作,用户也可以终止自己的会话。
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 killAllSessions
operation ignores sessions that have transactions in prepared state. killAllSessions
操作忽略事务处于准备状态的会话。Transactions in prepared state refer to transactions with write operations that span multiple shards whose commit coordinator has completed the 处于已准备状态的事务是指具有写操作的事务,这些操作跨越多个分片,提交协调器已完成"sendingPrepare" action
."sendingPrepare" action
操作。
The following operation kills all sessions for all users in the system:以下操作将终止系统中所有用户的所有会话:
db.runCommand( { killAllSessions: [ ] } )
The following operation kills all sessions for the user 以下操作将终止`中用户appReader
in the db1
and the user reportWriter
in db2
databases:appReader
和db2
数据库中用户reportWriter
的所有会话:
db.runCommand( { killAllSessions: [ { user: "appReader", db: "db1" }, { user: "reportWriter", db: "db2" } ] } )