버전 5.0에서 변경되었습니다.
db.shutdownServer()Shuts down the current
mongodormongosprocess cleanly and safely. You must issue thedb.shutdownServer()operation against the admin database.db.shutdownServer()에는 다음 구문이 있습니다.db.shutdownServer({ force: <boolean>, timeoutSecs: <int> }) 이 메서드는 다음과 같은 필드를 사용합니다.
필드설명선택 사항.
mongod또는mongos강제로 종료하려면true로 지정합니다. 강제 종료는mongod또는mongos에서 진행 중인 모든 작업을 중단하며, 예기치 않은 동작을 초래할 수 있습니다.You can pause and resume in-progress index builds using
force. Seedb.shutdownServer()on Replica Set Members for more information.선택 사항.
MongoDB 5.0부터
mongod및mongos는 종료하기 전에 진행 중인 모든 데이터베이스 작업이 완료될 수 있도록 정지 기간을 입력합니다.mongod프라이머리가 종료 요청을 받으면 프라이머리는 다음을 수행합니다.휴지기에 들어갑니다.
남은 모든 데이터베이스 작업을 종료합니다.
종료합니다.
mongod세컨더리 또는mongos종료 요청의 경우, 종료가 요청된 후 정지 기간이 입력됩니다.정지 기간은 다음과 같이 지정됩니다.
timeoutSecs field if a
shutdownordb.shutdownServer()command was run, orshutdownTimeoutMillisForSignaledShutdown서버 매개 변수(SIGTERM신호가mongod로 전송된 경우) 또는SIGTERM신호가mongos로 전송된 경우mongosShutdownTimeoutMillisForSignaledShutdown서버 매개변수입니다.
클라이언트는 종료되는
mongod또는mongos에 대해 새 연결을 열 수 없습니다.timeoutSecs specifies a time period in seconds. The default is:
MongoDB 5.0에서 15초.
MongoDB 5.0 이전 버전에서는 10초입니다.
mongoduses timeoutSecs as follows:If the current node is the primary node of a replica set,
mongodwaits for a period of up to the number of seconds specified by the timeoutSecs field for an electable node to catch up before stepping down the primary node. For details about the catch up time, see replication lag.If the current node is in the
SECONDARYstate after stepping down from being the primary, any remaining time specified in timeoutSecs is used for a quiesce period, which allows existing operations to complete. New operations are sent to other replica set nodes.
Starting in MongoDB 5.0,
mongosuses timeoutSecs as a quiesce period, which allows existing operations to complete. New operations are sent to othermongosnodes. In MongoDB versions earlier than 5.0,mongosshuts down immediately and does not use timeoutSecs.
이 작업은 shutdown 명령 주위에 래퍼(wrapper)를 제공합니다.
호환성
이 메서드는 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
중요
This command is not supported in MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
행동
For a mongod started with Authentication on Self-Managed Deployments, you must run db.shutdownServer() over an authenticated connection. See Access Control for more information.
For a mongod started without Authentication on Self-Managed Deployments, you must run db.shutdownServer() from a client connected to the localhost interface. For example, run mongosh with the --host "127.0.0.1" option on the same host machine as the mongod.
db.shutdownServer() 복제본 세트 멤버
db.shutdownServer() fails if the mongod replica set member is running certain operations such as index builds. You can specify force: true to save index build progress to disk. The mongod recovers the index build when it restarts and continues from the saved checkpoint.
복제본 세트 프라이머리, 세컨더리 또는 [mongos] 종료 mongos
MongoDB 5.0부터 mongod 및 mongos는 종료하기 전에 진행 중인 모든 데이터베이스 작업이 완료될 수 있도록 정지 기간을 입력합니다.
mongod 프라이머리가 종료 요청을 받으면 프라이머리는 다음을 수행합니다.
휴지기에 들어갑니다.
남은 모든 데이터베이스 작업을 종료합니다.
종료합니다.
mongod 세컨더리 또는 mongos 종료 요청의 경우, 종료가 요청된 후 정지 기간이 입력됩니다.
정지 기간은 다음과 같이 지정됩니다.
timeoutSecs field if a
shutdownordb.shutdownServer()command was run, orshutdownTimeoutMillisForSignaledShutdown서버 매개 변수(SIGTERM신호가mongod로 전송된 경우) 또는SIGTERM신호가mongos로 전송된 경우mongosShutdownTimeoutMillisForSignaledShutdown서버 매개변수입니다.
클라이언트는 종료되는 mongod 또는 mongos에 대해 새 연결을 열 수 없습니다.
timeoutSecs specifies a time period in seconds. The default is:
MongoDB 5.0에서 15초.
MongoDB 5.0 이전 버전에서는 10초입니다.
mongod uses timeoutSecs as follows:
If the current node is the primary node of a replica set,
mongodwaits for a period of up to the number of seconds specified by the timeoutSecs field for an electable node to catch up before stepping down the primary node. For details about the catch up time, see replication lag.If the current node is in the
SECONDARYstate after stepping down from being the primary, any remaining time specified in timeoutSecs is used for a quiesce period, which allows existing operations to complete. New operations are sent to other replica set nodes.
Starting in MongoDB 5.0, mongos uses timeoutSecs as a quiesce period, which allows existing operations to complete. New operations are sent to other mongos nodes. In MongoDB versions earlier than 5.0, mongos shuts down immediately and does not use timeoutSecs.
경고
프라이머리 계정을 강제 종료하면 아직 세컨더리 계정으로 복제되지 않은 모든 쓰기가 롤백될 수 있습니다.
액세스 제어
To run db.shutdownServer() on a mongod enforcing Authentication on Self-Managed Deployments, the authenticated user must have the db.shutdownServer() privilege. For example, a user with the built-in role hostManager has the appropriate permissions.
예시
종료 mongod
db.getSiblingDB("admin").shutdownServer()
[mongod] 강제 종료 mongod
db.getSiblingDB("admin").shutdownServer({ "force" : true })
더 긴 시간 초과로 프라이머리 mongod 종료
db.getSiblingDB("admin").shutdownServer({ "timeoutSecs": 60 })