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

자체 관리형 MongoDB 의 외부 구성 값

MongoDB는 구성 파일에서 확장 지시문을 사용하여 외부 소스 값을 로드하는 기능을 지원합니다. 확장 지시문은 특정 구성 파일 옵션의 값을 로드하거나 또는 전체 구성 파일을 로드할 수 있습니다. 확장 지시문은 보안 인증서와 비밀번호와 같은 기밀 정보를 가리는 데 도움이 됩니다.

storage:
dbPath: "/var/lib/mongo"
systemLog:
destination: file
path: "/var/log/mongodb/mongod.log"
net:
bindIp:
__exec: "python /home/user/getIPAddresses.py"
type: "string"
trim: "whitespace"
digest: 85fed8997aac3f558e779625f2e51b4d142dff11184308dc6aca06cff26ee9ad
digest_key: 68656c6c30303030307365637265746d796f6c64667269656e64
tls:
mode: requireTLS
certificateKeyFile: "/etc/tls/mongod.pem"
certificateKeyFilePassword:
__rest: "https://myrestserver.example.net/api/config/myCertKeyFilePassword"
type: "string"
digest: b08519162ba332985ac18204851949611ef73835ec99067b85723e10113f5c26
digest_key: 6d795365637265744b65795374756666
  • If the configuration file includes the __rest expansion, on Linux/macOS, the read access to the configuration file must be limited to the user running the mongod / mongos process only.

  • If the configuration file includes the __exec expansion, on Linux/macOS, the write access to the configuration file must be limited to the user running the mongod / mongos process only.

확장 지시문을 사용하려면 사용된 확장 지시문의 전체 목록과 함께 --configExpand 명령줄 옵션을 지정해야 합니다.

mongod --config "/path/to/config/mongod.conf" --configExpand "rest,exec"

If you omit the --configExpand option or if you do not specify the complete list of expansion directives used in the configuration file, the mongod returns an error and terminates. You can only specify the --configExpand option on the command line.

The __rest expansion directive loads configuration file values from a REST endpoint. __rest supports loading specific values in the configuration file or loading the entire configuration file.

The following configuration file uses the __rest expansion directive to load the setting net.tls.certificateKeyFilePassword value from an external REST endpoint:

storage:
dbPath: "/var/lib/mongo"
systemLog:
destination: file
path: "/var/log/mongodb/mongod.log"
net:
bindIp: 192.51.100.24,127.0.0.1
tls:
mode: requireTLS
certificateKeyFile: "/etc/tls/mongod.pem"
certificateKeyFilePassword:
__rest: "https://myrestserver.example.net/api/config/myCertKeyFilePassword"
type: "string"
파일 권한

If the configuration file includes the __rest expansion, on Linux/macOS, the read access to the configuration file must be limited to the user running the mongod / mongos process only.

확장 구문 분석

To parse the __rest blocks, start the mongod with the --configExpand "rest" option.

The mongod issues a GET request against specified URL. If successful, the mongod replaces the value of certificateKeyFilePassword with the returned value. If the URL fails to resolve or if the REST endpoint returns an invalid value, the mongod throws an error and terminates.

The following configuration file uses the __rest expansion directive to load the configuration file from an external REST endpoint. The expansion directive and its options must be the only values specified in the configuration file.

__rest: "https://myrestserver.example.net/api/config/fullConfig"
type: "yaml"
파일 권한

If the configuration file includes the __rest expansion, on Linux/macOS, the read access to the configuration file must be limited to the user running the mongod / mongos process only.

확장 구문 분석

To parse the __rest blocks, start the mongod with the --configExpand "rest" option.

The mongod issues a GET request against the specified URL. If successful, the mongod parses the returned configuration yaml file and uses it during startup. If the URL fails to resolve or return a properly formatted yaml file, the mongod throws an error and terminates.

중요

The value returned by the specified REST endpoint cannot include any additional expansion directives. The mongod does not perform additional processing on the returned data and will terminate with an error code if the returned data includes additional expansion directives.

The __exec expansion directive loads configuration file values from a shell or terminal command. __exec supports loading specific values in the configuration file or loading the entire configuration file.

The following example configuration file uses the __exec expansion directive to to load the setting net.tls.certificateKeyFilePassword value from the output of a shell or terminal command:

storage:
dbPath: "/var/lib/mongo"
systemLog:
destination: file
path: "/var/log/mongodb/mongod.log"
net:
bindIp: 192.51.100.24,127.0.0.1
tls:
mode: requireTLS
certificateKeyFile: "/etc/tls/mongod.pem"
certificateKeyFilePassword:
__exec: "python /home/myUserName/getPEMPassword.py"
type: "string"
파일 권한

If the configuration file includes the __exec expansion, on Linux/macOS, the write access to the configuration file must be limited to the user running the mongod / mongos process only.

확장 구문 분석

To parse the __exec blocks, start the mongod with the --configExpand "exec" option.

The mongod attempts to execute the specified operation. If the command executes successfully, the mongod replaces the value of certificateKeyFilePassword with the returned value. If the command fails or returns an invalid value for the configuration file setting, the mongod throws an error and terminates.

The following example configuration file uses the __exec expansion directive to load the configuration file from the output of a shell or terminal command. The __exec expansion directive and its options must be the only values specified in the configuration file.

__exec: "python /home/myUserName/getFullConfig.py"
type: "yaml"
파일 권한

If the configuration file includes the __exec expansion, on Linux/macOS, the write access to the configuration file must be limited to the user running the mongod / mongos process only.

확장 구문 분석

To parse the __exec blocks, start the mongod with the --configExpand "rest" option.

If the command executes successfully, the mongod parses the returned configuration yaml file and uses it during startup. If the command fails or returns an invalid yaml file, the mongod throws an error and terminates.

중요

The data returned by executing the specified __exec string cannot include any additional expansion directives. The mongod does not perform additional processing on the returned data and will terminate with an error code if the returned data includes additional expansion directives.

__rest

The __rest expansion directive loads configuration file values from a REST endpoint. __rest supports loading specific values in the configuration file or loading the entire configuration file. The mongod then starts using the externally sourced values as part of its configuration.

The __rest expansion directive has the following syntax:

  • 특정 구성 파일 설정에 대해 REST 엔드포인트를 지정하려면 다음을 수행합니다.

    <some configuration file setting>:
    __rest: "<string>"
    type: "string"
    trim: "none|whitespace"
    digest: "<string>"
    digest_key: "<string>"
  • 전체 구성 파일에 대해 REST 엔드포인트를 지정하려면 다음 안내를 따르세요.

    __rest: "<string>"
    type: "yaml"
    trim: "none|whitespace"

    REST 엔드포인트를 통해 전체 구성 파일을 지정하는 경우 반드시 확장 지시문과 해당 옵션이 구성 파일에 지정된 유일한 값이어야 합니다.

__rest 은(는) 다음 필드를 사용합니다.

필드
유형
설명

문자열

Required The URL against which the mongod issues a GET request to retrieve the externally sourced value.

로컬 호스트가 아닌 엔드포인트(예: 원격 서버 REST 에서 호스팅되는 REST 엔드포인트)의 경우 에는__rest 호스팅하다https:// 시스템과 원격 서버 모두 TLS 를 지원 암호화됨 () URL이 1 필요합니다.1 이상입니다.

URL 에 지정된 엔드포인트에 인증 필요한 경우 REST 표준 RFC 3986 사용자 정보 형식을 사용하여 자격 증명 URL 에 인코딩합니다.

For localhost REST endpoints (e.g. a REST endpoint listening on the host machine), __rest allows unencrypted (http://) URLs.

IMPORTANT: The value returned by the specified REST endpoint cannot include any additional expansion directives. The mongod does not perform additional processing on the returned data and will terminate with an error code if the returned data includes additional expansion directives.

type

문자열

Optional Controls how __rest parses the returned value from the specified URL.

가능한 값은 다음과 같습니다.

  • string (기본값)

    Directs __rest to parse the returned data as a literal string. If specifying string, the entire __rest block and supporting options must be nested under the field for which you are loading externally sourced values.

  • yaml

    Directs __rest to parse the returned data as a yaml formatted file. If specifying yaml, the __rest block must be the only content in the configuration file. The mongod replaces the configuration file contents with the yaml retrieved from the REST resource.

trim

문자열

Optional Specify whitespace to direct __rest to trim any leading or trailing whitespace, specifically occurrences of " ", "\r", "\n", "\t", "\v", and "\f". Defaults to none, or no trimming.

문자열

선택 사항. 확장 결과의 HMAC-SHA256 출력은 HMAC-SHA256(digest_key, message)로 계산되며, 여기서 message는 조회할 구성 설정의 값입니다.

명시된 경우 digest_key도 지정해야 합니다.

문자열

선택 사항.64 32256 확장 결과의 HMAC-SHA 다이제스트를 계산하는 데 사용되는 바이트 키의 문자 16진수 문자열 표현입니다.

명시된 경우 다이제스트도 지정해야 합니다.

예를 들어 certificateKeyFilePassword이 "superSecret123"이라고 가정해 봅시다. REST 요청 또는 exec 서비스 호출을 사용하여 이 비밀번호를 조회하려면 다이제스트 키를 생성하고 이 키를 사용하여 비밀번호의 다이제스트를 계산해야 합니다.

터미널에서 다음 코드를 실행하여 32바이트 다이젬트 키를 생성합니다.

openssl rand -hex 32

다이젬트 키를 생성한 후에 이 키를 사용하여 암호의 다이젬트를 계산할 수 있습니다.

echo -ne "superSecret123" | openssl dgst -sha256 -mac hmac -macopt hexkey:f38d0d5adfcf1a0575f9fa9051c70a2f88b1bb7562513c9efd7686e9c21ad304

참고

  • If the configuration file includes the __rest expansion, on Linux/macOS, the read access to the configuration file must be limited to the user running the mongod / mongos process only.

  • To enable parsing of the __rest expansion directive, start the mongod with the --configExpand "rest" option.

For examples, see Use the __rest Expansion Directive.

__exec

The __exec expansion directive loads configuration file values from the output of a shell or terminal command. __exec supports loading specific values in the configuration file or loading the entire configuration file. The mongod then starts using the externally sourced values as part of its configuration.

The __exec expansion directive has the following syntax:

  • 특정 구성 파일 설정 또는 설정에 대한 셸 또는 터미널 명령을 지정하려면 다음을 수행합니다.

    <some configuration file setting>:
    __exec: "<string>"
    type: "string"
    trim: "none|whitespace"
  • 전체 구성 파일에 대해 shell 또는 터미널 명령을 지정하려면 다음을 수행합니다.

    __exec: "<string>"
    type: "yaml"
    trim: "none|whitespace"

    터미널 또는 shell 명령을 통해 전체 구성 파일을 지정하는 경우 확장 지시어와 해당 옵션은 반드시 구성 파일에 지정된 유일한 값이어야 합니다.

__exec 은(는) 다음 필드를 사용합니다.

필드
유형
설명

__exec

문자열

Required The string which the mongod executes on the terminal or shell to retrieve the externally sourced value.

Linux 및 OSX 호스트에서 실행은 POSIX popen()을 통해 처리됩니다. Windows 호스트에서 실행은 프로세스 제어 API를 통해 처리됩니다. __execmongod 또는 mongos를 시작한 사용자와 동일한 사용자로 읽기 전용 파이프를 엽니다.

IMPORTANT: The data returned by executing the specified command cannot include any additional expansion directives. The mongod does not perform additional processing on the returned data and will terminate with an error code if the returned data includes additional expansion directives.

type

문자열

Optional Controls how __exec parses the value returned by the executed command.

가능한 값은 다음과 같습니다.

  • string (기본값)

    Directs __exec to parse the returned data as a literal string. If specifying string, the entire __exec block and supporting options must be nested under the field for which you are loading externally sourced values.

  • yaml

    Directs __exec to parse the returned data as a yaml formatted file. If specifying yaml, the __exec block must be the only content in the configuration file. The mongod replaces the configuration file contents with the yaml retrieved from the executed command.

trim

문자열

Optional Specify whitespace to direct __exec to trim any leading or trailing whitespace, specifically occurrences of " ", "\r", "\n", "\t", "\v", and "\f". Defaults to none, or no trimming.

문자열

선택 사항. 확장 결과의 HMAC-SHA256 출력은 HMAC-SHA256(digest_key, message)로 계산되며, 여기서 message는 조회할 구성 설정의 값입니다.

명시된 경우 digest_key도 지정해야 합니다.

문자열

Optional. The 64-character hexadecimal string representation of the 32-byte key used to calculate the HMAC-SHA256 digest of the expansion result.

지정하는 경우 다이제스트도 지정해야 합니다.

예를 들어 certificateKeyFilePassword이 "superSecret123"이라고 가정해 봅시다. REST 요청 또는 exec 서비스 호출을 사용하여 이 비밀번호를 조회하려면 다이제스트 키를 생성하고 이 키를 사용하여 비밀번호의 다이제스트를 계산해야 합니다.

터미널에서 다음 코드를 실행하여 32바이트 다이젬트 키를 생성합니다.

openssl rand -hex 32

다이젬트 키를 생성한 후에 이 키를 사용하여 암호의 다이젬트를 계산할 수 있습니다.

echo -ne "superSecret123" | openssl dgst -sha256 -mac hmac -macopt hexkey:f38d0d5adfcf1a0575f9fa9051c70a2f88b1bb7562513c9efd7686e9c21ad304

참고

  • If the configuration file includes the __exec expansion, on Linux/macOS, the write access to the configuration file must be limited to the user running the mongod / mongos process only.

  • To enable parsing of the __exec expansion directives, start the mongod with the --configExpand "exec" option.

For examples, see Use the __exec Expansion Directive.

You can test the final output of a configuration file that specifies one or more expansion directives by starting the mongod with the --outputConfig option. A mongod started with --outputConfig outputs the resolved YAML configuration document to stdout and halts. If any expansion directive specified in the configuration file returns additional expansion directives, the mongod throws an error and terminates.

경고

--outputConfig 옵션은 확장 지시문을 사용하여 모든 필드에 대해 확인된 값을 반환합니다. 여기에는 이전에 구성 옵션에 외부 소스를 사용하여 가려졌던 모든 개인정보 또는 민감한 정보가 포함됩니다.

For example, the following configuration file mongod.conf contains a __rest expansion directive:

storage:
dbPath: "/var/lib/mongo"
systemLog:
destination: file
path: "/var/log/mongodb/mongod.log"
net:
port:
__rest: "https://mongoconf.example.net:8080/record/1"
type: string

지정된 URL에 기록된 문자열은 다음과 같습니다. 20128

If the configuration file includes the __rest expansion, on Linux/macOS, the read access to the configuration file must be limited to the user running the mongod / mongos process only.

--configExpand "rest"--outputConfig 옵션을 사용하여 mongod를 시작합니다.

mongod -f mongod.conf --configExpand rest --outputConfig

mongod는 종료하기 전에 stdout에 다음을 출력합니다.

config: mongod.conf
storage:
dbPath: "/var/lib/mongo"
systemLog:
destination: file
path: "/var/log/mongodb/mongod.log"
net:
port: 20128
outputConfig: true