정의
startSessionThe
startSessioncommand starts a new logical session for a sequence of operations.팁
In
mongosh, this command can also be run through theMongo.startSession()helper method.Helper methods are convenient for
mongoshusers, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
- MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스
참고
이 명령은 모든 MongoDB Atlas 클러스터에서 지원됩니다. 모든 명령에 대한 Atlas 지원에 관해 자세히 알아보려면 지원되지 않는 명령을 참조하세요.
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
구문
명령은 다음과 같은 구문을 가집니다:
db.runCommand( { startSession: 1 } )
To run startSession, use the db.runCommand( { <command> } ) method.
db.runCommand( { startSession: 1 } )
행동
If the deployment enforces authentication/authorization, you must be authenticated to run the startSession command. The user who runs startSession owns the created session, and only that user can use the session.
배포서버에서 인증/권한 부여를 적용하지 않는 경우, 생성된 세션에는 소유자가 없으며 모든 연결의 모든 사용자가 사용할 수 있습니다. 사용자가 인증/권한 부여를 적용하지 않는 배포서버에 대해 세션을 인증하고 생성하는 경우, 사용자가 세션을 소유합니다. 그러나 모든 연결의 모든 사용자가 세션을 사용할 수 있습니다.
다운타임 없이 배포가 인증으로 전환되면 소유자가 없는 세션을 사용할 수 없습니다.
세션은 세션을 생성한 MongoClient 객체에만 사용할 수 있습니다. 단일 세션은 동시에 사용할 수 없습니다. 단일 세션을 사용하는 작업은 순차적으로 실행해야 합니다.
출력
In addition to the status and operation time of the command, the startSession returns the following session specific information:
필드 | 유형 | 설명 | |
|---|---|---|---|
| 문서 | 세션 식별자의 16바이트 UUID(Universally Unique Identifier) 부분을 포함하는 문서입니다. 세션의 식별자는 이 UUID와 인증된 사용자 자격 증명의 해시로 구성됩니다. | |
| 숫자 | 마지막 클라이언트 사용 이후 세션이 만료되기 전에 활성 상태로 유지된 시간(분)입니다. 기본적으로 세션의 만료 시간은 30분입니다. 이 값을 변경하려면 |