Docs Menu

Rotate Keys for Self-Managed Sharded Clusters

Sharded cluster members can use keyfiles to authenticate each other as memers of the same deployment.

キーファイルには複数のキーを含めることができ、少なくとも 1 つのキーがメンバー間で共通の場合、メンバーシップ認証が確立されます。 これにより、ダウンタイムなしでキーのローリング アップグレードが可能になります。

The following tutorial steps through the process to update, without any downtime, the key for a sharded cluster. [1]

警告

The example keys in this tutorial are for illustrative purposes only. Do NOT use for your deployement. Instead, generate a keyfile using any method you choose (e.g. openssl rand -base64 756, etc.).

Consider a sharded cluster where each member's keyfile contains the following key:

Image of current key to replace.

The following procedure updates the sharded cluster members to use a new key:

Image of new key.
[1] このチュートリアルは、 MongoDB の暗号化されたストレージ エンジン のローカル キー管理に使用される キー ファイルには適用されません。そのキーファイルには1つのキーしか入れることができません。

MongoDB 8.0以降では、 directShardOperationsロールを使用して、シャードに対してコマンドを直接実行する必要があるメンテナンス操作を実行できます。

警告

directShardOperationsロールを使用して コマンドを実行すると、クラスターが正しく動作しなくなり、データが破損する可能性があります。 directShardOperationsロールは、メンテナンス目的で、または MongoDB サポートのガイダンスに必ず従う必要があります。 メンテナンス操作を実行したら、 directShardOperationsロールの使用を停止します。

Modify each member's keyfile to include both the old and new keys.

警告

The example keys in this tutorial are for illustrative purposes only. Do NOT use for your deployement. Instead, generate a keyfile using any method you choose (e.g. openssl rand -base64 756, etc.).

You can specify multiple key strings as a sequence of key strings (optionally enclosed in quotes):

すべてのキーファイルに古いキーと新しいキーの両方が含まれたら、各ノードを一度に 1 つずつ再起動します。

For each secondary of the config server replica set (CSRS), connect mongosh to the member and:

  1. ノードをシャットダウンするには、 db.shutdownServer()メソッドを使用します。

    use admin
    db.shutdownServer()
  2. ノードを再起動します。

プライマリの場合はmongoshをノードに接続し、

  1. rs.stepDown()を使用してメンバーを降格します。

    rs.stepDown()
  2. ノードをシャットダウンするには、 db.shutdownServer()メソッドを使用します。

    use admin
    db.shutdownServer()
  3. ノードを再起動します。

For each secondary member of the shard replica sets, connect mongosh to the member and:

  1. ノードをシャットダウンするには、 db.shutdownServer()メソッドを使用します。

    use admin
    db.shutdownServer()
  2. ノードを再起動します。

For the primary of each shard replica set, connect mongosh to the member and

  1. rs.stepDown()を使用してメンバーを降格します。

    rs.stepDown()
  2. ノードをシャットダウンするには、 db.shutdownServer()メソッドを使用します。

    use admin
    db.shutdownServer()
  3. ノードを再起動します。

For each mongos/router instance, connect mongosh to the mongos instance and:

  1. ノードをシャットダウンするには、 db.shutdownServer()メソッドを使用します。

    use admin
    db.shutdownServer()
  2. ノードを再起動します。

Once all members have been restarted, the members now accept either the old or new key for membership authentication.

警告

The example keys in this tutorial are for illustrative purposes only. Do NOT use for your deployement. Instead, generate a keyfile using any method you choose (e.g. openssl rand -base64 756, etc.).

各ノードのキーファイルを変更して、新しいパスワードのみを含めます。

すべてのキーファイルに新しいキーのみが含まれたら、各ノードを一度に 1 つずつ再起動します。

For each secondary of the config server replica set (CSRS), connect mongosh to the member and:

  1. ノードをシャットダウンするには、 db.shutdownServer()メソッドを使用します。

    use admin
    db.shutdownServer()
  2. ノードを再起動します。

プライマリの場合はmongoshをノードに接続し、

  1. rs.stepDown()を使用してメンバーを降格します。

    rs.stepDown()
  2. ノードをシャットダウンするには、 db.shutdownServer()メソッドを使用します。

    use admin
    db.shutdownServer()
  3. ノードを再起動します。

For each secondary member of the shard replica sets, connect mongosh to the member and:

  1. ノードをシャットダウンするには、 db.shutdownServer()メソッドを使用します。

    use admin
    db.shutdownServer()
  2. ノードを再起動します。

For the primary of each shard replica set, connect mongosh to the member and

  1. rs.stepDown()を使用してメンバーを降格します。

    rs.stepDown()
  2. ノードをシャットダウンするには、 db.shutdownServer()メソッドを使用します。

    use admin
    db.shutdownServer()
  3. ノードを再起動します。

For each mongos/router instance, connect mongosh to the mongos instance and:

  1. ノードをシャットダウンするには、 db.shutdownServer()メソッドを使用します。

    use admin
    db.shutdownServer()
  2. ノードを再起動します。

Once all members have been restarted, the members now accept only the new key for membership authentication.