스냅샷 저장소 등록 또는 업데이트 API (Registering Or Updating A Snapshot Repository API)
snapshots API를 사용해 스냅샷을 저장할 새 저장소를 등록하거나 기존 저장소의 정보를 업데이트할 수 있어요.
스냅샷 저장소는 다음 유형이 될 수 있습니다.
- 파일 시스템(fs): fs 저장소 생성 방법은 Register repository shared file system을 참고하세요.
- Amazon Simple Storage Service(Amazon S3) 버킷(s3): s3 저장소 생성 방법은 Register repository Amazon S3을 참고하세요.
- Hadoop Distributed File System(HDFS)(hdfs): hdfs 저장소 생성 방법은 Register an HDFS repository를 참고하세요. 저장소 생성 지침은 Register repository 문서를 참고하세요.
출처: OpenSearch 문서
본문
Endpoints
POST /_snapshot/{repository}/
PUT /_snapshot/{repository}/
Path parameters
| Parameter | Data type | Description | | repository | String | Repository name |
Request parameters
요청 파라미터는 저장소 유형에 따라 달라지며, 다음 유형이 있어요.
- fs
- s3
- hdfs
Common parameters
다음 표는 fs와 s3 저장소 모두에서 사용할 수 있는 파라미터를 보여줘요.
| Request field | Description | | prefix_mode_verification | When enabled, adds a hashed value of a random seed to the prefix for repository verification. For remote-store-enabled clusters, you can add the setting.prefix_mode_verification setting to the node attributes for the supplied repository. This field works with both new and existing repositories. Optional. | | shard_path_type | Controls the path structure of shard-level blobs. Supported values are FIXED, HASHED_PREFIX, and HASHED_INFIX. For more information about each value, see shard_path_type values. Default is HASHED_PREFIX. Optional. |
shard_path_type values
다음 값들은 shard_path_type 설정에서 지원돼요.
- FIXED: 기존의 계층적 방식대로 경로 구조를 유지합니다. 예: /<BASE_PATH>/indices//0/<SHARD_BLOBS>.
- HASHED_PREFIX: 각 고유 샤드 ID의 경로 시작 부분에 해시된 프리픽스를 앞에 붙입니다. 예: //<BASE_PATH>/indices//0/<SHARD_BLOBS>.
- HASHED_INFIX: 각 고유 샤드 ID의 기본 경로 뒤에 해시된 프리픽스를 추가합니다. 예: ///indices//0/<SHARD_BLOBS>. 사용되는 해시 메서드는 FNV_1A_COMPOSITE_1로, FNV1a 해시 함수를 사용하며 대부분의 원격 저장소 옵션과 잘 확장되는 커스텀 인코딩된 64비트 해시 값을 생성합니다. FNV1a는 가장 중요한 6비트를 가져와 URL-safe Base64 문자를 만들고 다음 14비트로 이진 문자열을 생성합니다.
fs repository
| Request field | Description | | location | The file system directory for snapshots, such as a mounted directory from a file server or a Samba share. Must be accessible by all nodes. Required. | | chunk_size | Breaks large files into chunks during snapshot operations (e.g. 64mb, 1gb), which is important for cloud storage providers and far less important for shared file systems. Default is null (unlimited). Optional. | | compress | Whether to compress metadata files. This setting does not affect data files, which might already be compressed, depending on your index settings. Default is false. Optional. | | max_restore_bytes_per_sec | The maximum rate at which snapshots are restored. Default is 0 (unlimited). The restore rate is also subject to indices.recovery.max_bytes_per_sec (by default, 40mb). Optional. | | max_snapshot_bytes_per_sec | The maximum rate at which snapshots are taken. Default is 40 MB per second (40mb). Optional. | | remote_store_index_shallow_copy | Determines whether the snapshot of the remote store indexes are captured as a shallow copy. Default is false. | | shallow_snapshot_v2 | Determines whether the snapshots of the remote store indexes are captured as a shallow copy v2. Default is false. | | readonly | Whether the repository is read-only. Useful when migrating from one cluster ("readonly": false when registering) to another cluster ("readonly": true when registering). Optional. |
s3 repository
| Request field | Description | | base_path | The path within the bucket in which you want to store snapshots (for example, my/snapshot/directory). Do not include the s3:// prefix. Optional. If not specified, snapshots are stored in the S3 bucket root. | | bucket | The name of the S3 bucket, without the s3:// prefix. Required. | | region | The AWS Region in which the S3 bucket is located. Optional. If missing, values of s3.client.default.region from opensearch.yml are used. | | endpoint | The S3 bucket endpoint. Optional. Required if region is set for OpenSearch 2.9 and later. For example, for us-west-2, use https://s3.us-west-2.amazonaws.com. If missing, values of s3.client.default.endpoint from opensearch.yml are used. | | buffer_size | The threshold beyond which chunks (of chunk_size) should be broken into pieces (of buffer_size) and sent to S3 using a different API. Default is the smaller of two values: 100 MB or 5% of the Java heap. Valid values are between 5mb and 5gb. We don't recommend changing this option. | | canned_acl | S3 has several canned ACLs that the repository-s3 plugin can add to objects as it creates them in S3. Default is private. Optional. | | chunk_size | Breaks files into chunks during snapshot operations (for example, 64mb, 1gb), which is important for cloud storage providers and far less important for shared file systems. Default is 1gb. Optional. | | client | When specifying client settings (for example, s3.client.default.access_key), you can use a string other than default (for example, s3.client.backup-role.access_key). If you used an alternate name, change this value to match. Default and recommended value is default. Optional. | | compress | Whether to compress metadata files. This setting does not affect data files, which might already be compressed, depending on your index settings. Default is false. Optional. | | disable_chunked_encoding | Disables chunked encoding for compatibility with some storage services. Default is false. Optional. | | max_restore_bytes_per_sec | The maximum rate at which snapshots are restored. Default is 0 (unlimited). The restore rate is also subject to indices.recovery.max_bytes_per_sec (by default, 40mb). Optional. | | max_snapshot_bytes_per_sec | The maximum rate at which snapshots are taken. Default is 40 MB per second (40mb). Optional. | | readonly | Whether the repository is read-only. Useful when migrating from one cluster ("readonly": false when registering) to another cluster ("readonly": true when registering). Optional. | | remote_store_index_shallow_copy | Determines whether the snapshot of the remote store indexes is captured as a shallow copy. Default is false. | | s3_async_client_type | The asynchronous HTTP client that the repository-s3 plugin uses when it uploads data to this repository. Valid values are crt (the AWS Common Runtime client) and netty (the Netty NIO client). For more information, see s3_async_client_type. Default is crt. Optional. | | shallow_snapshot_v2 | Determines whether the snapshots of the remote store indexes are captured as a shallow copy v2. Default is false. | | storage_class | Specifies the S3 storage class for the snapshot files. Default is standard. Do not use the glacier and deep_archive storage classes. Optional. | | server_side_encryption_type | Specifies the S3 server-side encryption types. Supported values are AES256 (SSE-S3), aws:kms (SSE-AWS Key Management Service (KMS)), and bucket_default (bucket default encryption). Default is bucket_default. | | server_side_encryption_kms_key_id | Specifies the AWS KMS key to be used if S3 SSE-KMS is selected by setting the aws:kms encryption type. Required if aws:kms is set as the server_side_encryption_type. | | server_side_encryption_bucket_key_enabled | Specifies whether S3 Bucket Keys should be used when using S3 SSE-KMS. Optional. | | server_side_encryption_encryption_context | Specifies any additional encryption context that should be used when using S3 SSE-KMS. This setting value must be formatted as a JSON object. Optional. | | expected_bucket_owner | Specifies the AWS account ID of the expected S3 bucket owner. This setting can be used for verifying bucket ownership. Optional. |
server_side_encryption 설정은 OpenSearch 3.1.0부터 제거됐어요. S3는 모든 S3 버킷의 기본 암호화 수준으로 서버 측 암호화를 적용합니다. 이는 비활성화할 수 없으므로 이 저장소 설정 값은 아무 효과가 없었습니다. 자세한 내용은 Protecting data with server-side encryption 문서를 참고하세요.
s3_async_client_type
s3_async_client_type은 단일 저장소에 적용되므로 저장소의 settings 블록에 설정하세요. repository-s3 플러그인은 s3_async_client_type을 노드 설정으로도 등록하므로 opensearch.yml에 설정을 두면 노드가 성공적으로 시작되고 Nodes Info API가 이를 반환하지만, 플러그인은 저장소 정의에서만 값을 읽습니다. s3_async_client_type을 설정하지 않은 저장소는 opensearch.yml에 netty를 지정해도 crt를 사용합니다.
노드 플랫폼에 AWS Common Runtime 네이티브 라이브러리를 사용할 수 없으면 플러그인은 경고를 기록하고 Netty 클라이언트를 사용합니다.
저장소가 어떤 클라이언트를 사용하는지 확인하려면 org.opensearch.repositories.s3.S3AsyncService 로거에 대해 DEBUG 로깅을 활성화하고 S3 Http client type 메시지를 찾아보세요.
hdfs repository
| Request field | Description | | uri | The HDFS URI of the hdfs://:/path/to/backup format. Required. | | path | The path within HDFS where you want to store snapshots (for example, /my/snapshot/directory). Required. | | security.principal | The Kerberos principal to use when connecting to HDFS. Optional. | | conf. | Additional HDFS client configuration settings (for example, core-site.xml or hdfs-site.xml). Optional. |
Example requests
다음 예시들은 다양한 저장소 유형을 등록하는 방법을 보여줘요.
fs
다음 예시는 로컬 디렉터리 /mnt/snapshots를 location으로 사용하는 fs 저장소를 등록해요.
REST Python
PUT /_snapshot/my-fs-repository
{
"type": "fs",
"settings": {
"location": "/mnt/snapshots"
}
}
Copy Copy as cURL
response = client.snapshot.create_repository(
repository = "my-fs-repository",
body = {
"type": "fs",
"settings": {
"location": "/mnt/snapshots"
}
}
)
Copy
s3
다음 요청은 my-open-search-bucket이라는 기존 버킷에 my-opensearch-repo라는 새 S3 저장소를 등록해요. 기본적으로 모든 스냅샷은 my/snapshot/directory에 저장됩니다.
REST Python
PUT /_snapshot/my-opensearch-repo
{
"type": "s3",
"settings": {
"bucket": "my-open-search-bucket",
"base_path": "my/snapshot/directory"
}
}
Copy Copy as cURL
response = client.snapshot.create_repository(
repository = "my-opensearch-repo",
body = {
"type": "s3",
"settings": {
"bucket": "my-open-search-bucket",
"base_path": "my/snapshot/directory"
}
}
)
Copy 다음 요청은 my-open-search-bucket이라는 기존 버킷에 my-opensearch-repo라는 새 S3 저장소를 등록해요. 기본적으로 모든 스냅샷은 my/snapshot/directory에 저장됩니다. 또한 이 저장소는 SSE-KMS를 사용하도록 구성되고, 예상 버킷 소유자 AWS 계정 ID는 123456789000입니다.
REST Python
PUT /_snapshot/my-opensearch-repo
{
"type": "s3",
"settings": {
"bucket": "my-open-search-bucket",
"base_path": "my/snapshot/directory",
"server_side_encryption_type": "aws:kms",
"server_side_encryption_kms_key_id": "arn:aws:kms:us-east-1:123456789000:key/kms-key-id",
"server_side_encryption_encryption_context": "{\"additional-enc-ctx\": \"sample-context\"}",
"expected_bucket_owner": "123456789000",
}
}
Copy Copy as cURL
response = client.snapshot.create_repository(
repository = "my-opensearch-repo",
body = '''
{
"type": "s3",
"settings": {
"bucket": "my-open-search-bucket",
"base_path": "my/snapshot/directory",
"server_side_encryption_type": "aws:kms",
"server_side_encryption_kms_key_id": "arn:aws:kms:us-east-1:123456789000:key/kms-key-id",
"server_side_encryption_encryption_context": "{\"additional-enc-ctx\": \"sample-context\"}",
"expected_bucket_owner": "123456789000",
}
}
'''
)
Copy
hdfs
다음 요청은 HDFS URI hdfs://namenode:8020과 HDFS 파일시스템 경로 /opensearch/snapshots를 사용하는 새 HDFS 저장소를 등록해요.
REST Python
PUT /_snapshot/my-hdfs-repository
{
"type": "hdfs",
"settings": {
"uri": "hdfs://namenode:8020",
"path": "/opensearch/snapshots"
}
}
Copy Copy as cURL
response = client.snapshot.create_repository(
repository = "my-hdfs-repository",
body = {
"type": "hdfs",
"settings": {
"uri": "hdfs://namenode:8020",
"path": "/opensearch/snapshots"
}
}
)
Copy
Example response
성공하면 다음 JSON 객체가 반환됩니다.
{
"acknowledged": true
}
저장소가 등록됐는지 확인하려면 Get snapshot repository API를 사용하고, 저장소 이름을 repository 경로 파라미터로 전달하세요.
Required permissions
Security 플러그인을 사용한다면 적절한 권한(cluster:admin/repository/put)을 가지고 있는지 확인하세요.