버전 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는 초 단위로 기간을 지정합니다. 기본값은 다음과 같습니다.
MongoDB 5.0에서 15초.
MongoDB 5.0 이전 버전에서는 10초입니다.
mongod는 다음과 같이 timeoutSecs을 사용합니다.현재 노드가 복제본 세트의 프라이머리 노드인 경우
mongod는 프라이머리 노드가 물러나기 전에 투표 선택 가능 노드가 따라잡을 수 있도록 timeoutSecs 필드에 지정된 시간(초)까지 대기합니다. 따라잡기 시간에 대한 자세한 내용은 복제 지연을 참조하세요.프라이머리에서 물러난 후 현재 노드가
SECONDARY상태인 경우, 기존 작업을 완료할 수 있는 정지 기간으로 timeoutSecs에 지정된 남은 시간이 사용됩니다. 새 작업은 다른 복제본 세트 노드로 전송됩니다.
MongoDB 5.0 부터 는 기존 작업을 완료할 수 있는 정지 기간으로
mongostimeoutSecs를 사용합니다. 새 작업은 다른 노드로 전송됩니다. 이전의 MongoDBmongos버전 5 에서는 가 즉시 종료되고0mongostimeoutSecs를 사용하지 않습니다.
이 작업은 shutdown 명령 주위에 래퍼(wrapper)를 제공합니다.
호환성
이 메서드는 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
중요
이 명령은 MongoDB Atlas 클러스터에서 지원되지 않습니다. 모든 명령에 대한 Atlas 지원에 관해 자세히 알아보려면 지원되지 않는 명령을 참조하세요.
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는 초 단위로 기간을 지정합니다. 기본값은 다음과 같습니다.
MongoDB 5.0에서 15초.
MongoDB 5.0 이전 버전에서는 10초입니다.
mongod는 다음과 같이 timeoutSecs을 사용합니다.
현재 노드가 복제본 세트의 프라이머리 노드인 경우
mongod는 프라이머리 노드가 물러나기 전에 투표 선택 가능 노드가 따라잡을 수 있도록 timeoutSecs 필드에 지정된 시간(초)까지 대기합니다. 따라잡기 시간에 대한 자세한 내용은 복제 지연을 참조하세요.프라이머리에서 물러난 후 현재 노드가
SECONDARY상태인 경우, 기존 작업을 완료할 수 있는 정지 기간으로 timeoutSecs에 지정된 남은 시간이 사용됩니다. 새 작업은 다른 복제본 세트 노드로 전송됩니다.
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 })