Rotate Keys for Self-Managed Sharded Clusters
Sharded cluster members can use keyfiles to authenticate each other as memers of the same deployment.
키 파일 에는 여러 개의 키가 포함될 수 있으며 멤버 간에 하나 이상의 키가 공통적으로 사용되는 경우 멤버십 인증이 설정됩니다. 이를 통해 다운타임 없이 키를 롤링 업그레이드할 수 있습니다.
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:

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

[1] | 이 튜토리얼은 MongoDB의 암호화된 스토리지 엔진 로컬 키 관리에 사용되는 키 파일 에는 적용되지 않습니다. 해당 키파일 에는 하나의 키만 포함할 수 있습니다. |
절차
1. 이전 키와 새 키를 포함하도록 키 파일 수정
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. Restart Each Member
모든 키 파일에 이전 키와 새 키가 모두 포함되면 각 멤버를 한 번에 하나씩 다시 시작합니다.
Config 서버
For each secondary of the config server replica set (CSRS),
connect mongosh
to the member and:
db.shutdownServer()
메서드를 사용하여 멤버를 종료합니다:use admin db.shutdownServer() 멤버를 다시 시작합니다.
프라이머리의 경우 mongosh
를 멤버에 연결하고
rs.stepDown()
를 사용하여 멤버를 물러나게 합니다:rs.stepDown() db.shutdownServer()
메서드를 사용하여 멤버를 종료합니다:use admin db.shutdownServer() 멤버를 다시 시작합니다.
Shard Replica Sets
For each secondary member of the shard replica sets, connect
mongosh
to the member and:
db.shutdownServer()
메서드를 사용하여 멤버를 종료합니다:use admin db.shutdownServer() 멤버를 다시 시작합니다.
For the primary of each shard replica set, connect
mongosh
to the member and
rs.stepDown()
를 사용하여 멤버를 물러나게 합니다:rs.stepDown() db.shutdownServer()
메서드를 사용하여 멤버를 종료합니다:use admin db.shutdownServer() 멤버를 다시 시작합니다.
mongos
Routers
For each mongos/router instance, connect
mongosh
to the mongos
instance and:
db.shutdownServer()
메서드를 사용하여 멤버를 종료합니다:use admin db.shutdownServer() 멤버를 다시 시작합니다.
Once all members have been restarted, the members now accept either the old or new key for membership authentication.
3. 키 파일 콘텐츠를 새 키로만 업데이트
경고
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.).
새 비밀번호만 포함하도록 각 멤버의 키 파일을 수정합니다.
4. 각 멤버 다시 시작
모든 키 파일에 새 키만 포함되면 각 멤버를 한 번에 하나씩 다시 시작합니다.
Config 서버
For each secondary of the config server replica set (CSRS),
connect mongosh
to the member and:
db.shutdownServer()
메서드를 사용하여 멤버를 종료합니다:use admin db.shutdownServer() 멤버를 다시 시작합니다.
프라이머리의 경우 mongosh
를 멤버에 연결하고
rs.stepDown()
를 사용하여 멤버를 물러나게 합니다:rs.stepDown() db.shutdownServer()
메서드를 사용하여 멤버를 종료합니다:use admin db.shutdownServer() 멤버를 다시 시작합니다.
Shard Replica Sets
For each secondary member of the shard replica sets, connect
mongosh
to the member and:
db.shutdownServer()
메서드를 사용하여 멤버를 종료합니다:use admin db.shutdownServer() 멤버를 다시 시작합니다.
For the primary of each shard replica set, connect
mongosh
to the member and
rs.stepDown()
를 사용하여 멤버를 물러나게 합니다:rs.stepDown() db.shutdownServer()
메서드를 사용하여 멤버를 종료합니다:use admin db.shutdownServer() 멤버를 다시 시작합니다.
mongos
Routers
For each mongos/router instance, connect
mongosh
to the mongos
instance and:
db.shutdownServer()
메서드를 사용하여 멤버를 종료합니다:use admin db.shutdownServer() 멤버를 다시 시작합니다.
Once all members have been restarted, the members now accept only the new key for membership authentication.