AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

killAllSessions(データベースコマンド)

killAllSessions

The killAllSessions command kills all sessions for the specified users. [1]

このコマンドの構文は、次のとおりです。

db.runCommand(
{
killAllSessions: [ { user: <user>, db: <dbname> }, ... ]
}
)

このコマンドは、次の環境でホストされている配置で使用できます。

  • MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン

  • MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン

重要

This command is not supported in MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.

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]

既存のセッションを表示するには、 $listSessions操作 または$listLocalSessionsを参照してください。

[1](1, 2) The killAllSessions operation ignores sessions that have transactions in prepared state. See Behavior for details.

If the deployment enforces authentication/authorization, you must have the killAnySession to run the killAllSessions command.

注意

ユーザーはkillAnySession特権アクションがなくても自分のセッションを強制終了できます。

セッションを強制終了すると、セッション内で進行中の操作がすべて終了され、これらの操作に関連付けられている開いているカーソルが閉じられます。

強制終了されたセッションは引き続き現在のセッションとして表示され、今後の操作では強制終了されたセッションが使用される可能性があります。 既存のセッションを表示するには、 $listSessions操作 または$listLocalSessionsを参照してください。

The killAllSessions operation ignores sessions that have Transactions in prepared state. Transactions in prepared state refer to transactions with write operations that span multiple shards whose commit coordinator has completed the "sendingPrepare" action.

次の操作は、システム内のすべてのユーザーのすべてのセッションを強制終了します。

db.runCommand( { killAllSessions: [ ] } )

次の操作は、 データベース内のユーザーappReader db1とreportWriter データベース内のユーザーdb2 のすべてのセッションを強制終了します。

db.runCommand( { killAllSessions: [
{ user: "appReader", db: "db1" },
{ user: "reportWriter", db: "db2" }
] } )