AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

setDefaultRWConcern (데이터베이스 명령)

setDefaultRWConcern

The setDefaultRWConcern administrative command sets the global default read or write concern configuration for a replica set or sharded cluster. setDefaultRWConcern must be run against the admin database.

이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.

명령은 다음과 같은 구문을 가집니다:

db.adminCommand(
{
setDefaultRWConcern : 1,
defaultReadConcern: { <read concern> },
defaultWriteConcern: { <write concern> },
writeConcern: { <write concern> },
comment: <any>
}
)

이 명령은 다음 필드를 사용합니다.

필드
유형
설명

int

1로 설정합니다.

object

전역 읽기 고려 구성이 포함된 문서입니다. 유효한 읽기 고려 객체를 지정하세요.

Omit this document to leave the current global read concern unmodified. If omitted, setDefaultRWConcern must specify defaultWriteConcern.

object

전역 기본 쓰기 고려 구성이 포함된 문서입니다.

  • For the write concern w setting, setDefaultRWConcern supports all write concern values except w : 0.

  • For the write concern wtimeout setting, setDefaultRWConcern defaults to 0 if the setting is omitted. Operations block until the requested write concern is met. If specifying a global default wtimeout, ensure the value is large enough to allow write operations to achieve the requested write concern.

  • 현재 구성된 쓰기 고려의 설정을 해제하려면 빈 문서 {}을(를) 지정하세요.

Omit this document to leave the current global write concern unmodified. If omitted, setDefaultRWConcern must specify defaultReadConcern.

객체

Optional. A document that specifies the write concern to be used by the setDefaultRWConcern command itself.

If omitted, setDefaultRWConcern uses the previously set global default write concern if one was configured.

comment

any

선택 사항. 이 명령에 첨부할 사용자 제공 코멘트입니다. 설정되면 이 설명은 다음 위치에서 이 명령의 레코드와 함께 표시됩니다.

댓글은 유효한 모든 BSON types (문자열, 정수, 객체, 배열 등)이 될 수 있습니다.

setDefaultRWConcern returns an object that contains the currently configured global default read and write concern. See getDefaultRWConcern for more complete documentation on the returned fields.

참고

featureCompatibilityVersion 4.4 이상이 필요합니다.

Each mongod in the replica set or sharded cluster must have featureCompatibilityVersion set to at least 4.4 to use setDefaultRWConcern.

Starting in MongoDB 5.0, once the Cluster Wide Write Concern (CWWC) is set via the setDefaultRWConcern command the write concern cannot be unset.

MongoDB는 읽기 또는 쓰기 고려를 명시적으로 지정하지 않은 연산에만 전역 기본 읽기 또는 쓰기 고려를 적용합니다.

MongoDB가 전역 기본 읽기 또는 쓰기 고려를 연산에 적용하면 실행 클라이언트가 해당 읽기 또는 쓰기 고려를 명시적으로 지정한 것처럼 해당 연산이 작동합니다.

Issue setDefaultRWConcern against the replica set primary. The primary replicates the new global default settings to the remaining members of the replica set. Secondaries which have not yet replicated the updated global default settings continue using their local 'stale' copy of the defaults.

Issue the setDefaultRWConcern command with a writeConcern of w : "majority" to ensure the command only returns after the changes have propagated to a majority of replica set members.

Issue the setDefaultRWConcern against a mongos in the cluster. The mongos persists the updated settings to the config server replica set (CSRS). Each mongos periodically issues a getDefaultRWConcern against the CSRS to refresh their local copy of the global settings. A mongos uses its local 'stale' copy of the global defaults during the time period between refreshes.

Issue the setDefaultRWConcern command with a writeConcern of w : "majority" to ensure the command only returns after the changes have propagated to a majority of CSRS members.

애플리케이션이 읽기 또는 쓰기 고려 설정을 명시적으로 지정하지 않은 채 mongos을(를) 대상으로 연산을 실행하면 mongos이(가) 이에 해당하는 전역 기본 설정을 적용합니다.

The global default settings do not propagate to the individual shards. You cannot run setDefaultRWConcern against a shard.

중요

setDefaultRWConcern requires featureCompatibilityVersion 4.4+. If you downgrade your deployment's featureCompatibilityVersion from 4.4 to 4.2, all cluster-wide read and write concern defaults are lost, but mongos instances may continue applying the defaults for up to 30 seconds.

config 서버에서 쓰기 연산을 실행하는 샤딩 관리 명령(예: enableSharding 명령 또는 addShard 명령)은 전역 기본 쓰기 고려 설정에서 특정한 동작을 실행합니다.

  • 이 명령은 구성된 전역 기본 쓰기 고려에 관계없이 "majority"을(를) 사용합니다.

  • 이 명령은 최소 wtimeout60000(으)로 사용합니다. 이 명령은 60000보다 큰 경우에만 전역 기본 쓰기 고려 wtimeout을(를) 사용합니다.

For replica sets or sharded clusters enforcing Authentication on Self-Managed Deployments, setDefaultRWConcern requires that the authenticated user have the setDefaultRWConcern privilege action.

The clusterManager built-in role provides the required privileges to run setDefaultRWConcern.

아래 연산에서는 전역 쓰기 고려를 다음 값으로 설정합니다.

db.adminCommand({
"setDefaultRWConcern" : 1,
"defaultWriteConcern" : {
"w" : 2
}
})

이 작업은 다음과 유사한 문서를 반환합니다.

{
"defaultWriteConcern" : {
"w" : 2
},
"updateOpTime" : Timestamp(1586290895, 1),
"updateWallClockTime" : ISODate("2020-04-07T20:21:41.849Z"),
"localUpdateWallClockTime" : ISODate("2020-04-07T20:21:41.862Z"),
"ok" : 1,
"$clusterTime" : { ... }
"operationTime" : Timestamp(1586290925, 1)
}

다음 연산에서는 전역 읽기 고려를 "majority"(으)로 설정합니다.

db.adminCommand({
"setDefaultRWConcern" : 1,
"defaultReadConcern" : { "level" : "majority" }
})

이 작업은 다음과 유사한 문서를 반환합니다.

{
"defaultReadConcern" : {
"level" : "majority"
},
"updateOpTime" : Timestamp(1586290895, 1),
"updateWallClockTime" : ISODate("2020-04-07T20:21:41.849Z"),
"localUpdateWallClockTime" : ISODate("2020-04-07T20:21:41.862Z"),
"ok" : 1,
"$clusterTime" : { ... }
"operationTime" : Timestamp(1586290925, 1)
}

아래 연산에서는 전역 기본 읽기/쓰기 고려를 다음 값으로 설정합니다.

db.adminCommand({
"setDefaultRWConcern" : 1,
"defaultWriteConcern" : {
"w" : 2
},
"defaultReadConcern" : { "level" : "majority" }
})

이 작업은 다음과 유사한 문서를 반환합니다.

"defaultWriteConcern" : {
"w" : 2
},
"defaultReadConcern" : {
"level" : "majority"
}

다음을 수행할 수 있습니다.

  • 전역 기본 읽기 고려를 설정 해제하세요.

  • 전역 기본 쓰기 고려는 아직 설정하지 않은 경우에만 설정 해제하세요.

그 예로 전역 기본 읽기 고려가 level: "majority"(으)로 설정되어 있다고 가정해 봅시다. 전역 기본 읽기 고려를 설정 해제하려면 빈 문서 {}을(를) 사용하세요.

db.adminCommand( {
"setDefaultRWConcern" : 1,
"defaultReadConcern" : {}
} )

이 연산은 연산이 성공했다는 것을 나타내는 문서를 다음과 같이 반환합니다.

{
defaultReadConcern: { level: 'local' },
defaultWriteConcern: { w: 2, wtimeout: 0 },
updateOpTime: Timestamp({ t: 1656696934, i: 1 }),
updateWallClockTime: ISODate("2022-07-01T17:35:40.578Z"),
defaultWriteConcernSource: 'global',
defaultReadConcernSource: 'implicit',
localUpdateWallClockTime: ISODate("2022-07-01T17:35:40.578Z"),
ok: 1,
'$clusterTime': {
...
},
operationTime: Timestamp({ t: 1656632593, i: 1 })
}

전역 기본 쓰기 고려는 아직 설정하지 않은 경우에만 설정 해제할 수 있습니다.

전역 기본 쓰기 고려를 설정 해제하려면 빈 문서 {}을(를) 사용하세요.

db.adminCommand( {
"setDefaultRWConcern" : 1,
"defaultWriteConcern" : {}
} )

전역 기본 쓰기 고려가 다음과 같은 상태인 경우:

  • 설정 해제됨, 연산이 성공합니다.

  • 이미 설정되어 있음, 연산이 다음과 같은 오류를 반환합니다.

MongoServerError: The global default write concern cannot be unset
once it is set.
이 페이지 평가하기