从与 S3 兼容的来源转移

Storage Transfer Service 支持从与 Amazon S3 API 兼容的云或本地对象存储系统转移。

Storage Transfer Service 使用部署在靠近数据源的虚拟机上的转移代理来访问与 S3 兼容的来源中的数据。这些代理在 Docker 容器中运行,并且属于一个代理池。代理池是一组使用相同配置的代理,它们共同且并行地移动数据。

此功能让您可以从本地或云对象存储迁移到 Cloud Storage,归档数据以释放本地存储容量,将数据复制到 Google Cloud 以保证业务连续性,或将数据转移到 Google Cloud 进行分析和处理。对于从 AWS S3 迁移到 Cloud Storage 的客户,可以使用该功能来控制到 Google Cloud 的网络路由,从而显著降低出站数据传输费用。

准备工作

在配置转移作业之前,请完成以下步骤:

请勿在代理 ID 前缀、代理池名称或转移作业名称中包含敏感信息,例如个人身份信息 (PII) 或安全数据。资源名称可能会传播到其他 Google Cloud 资源的名称,并且可能会向您项目之外的 Google 内部系统公开。

获取来源凭据

从与 S3 兼容的来源转移需要访问密钥 ID私有访问密钥

获取这些信息的步骤取决于您的存储提供商。

生成 ID 和密钥的账号需要以下权限之一:

  • 源对象的只读权限(如果您不想删除源对象)。
  • 源对象的完整访问权限(如果您选择在转移过程中删除源对象)。

创建账号、添加权限并下载访问密钥 ID私有访问密钥后,请将 ID 和密钥存储在安全的位置。

配置对目标存储桶的访问权限

按照配置对接收器的访问权限:Cloud Storage 中的说明配置对目标存储桶的访问权限。

创建代理池

请勿在代理池名称中包含敏感信息,例如个人身份信息 (PII) 或安全数据。资源名称可能会传播到其他 Google Cloud 资源的名称,并且可能会向您项目之外的 Google 内部系统公开。

如需创建代理池,请执行以下操作:

Google Cloud 控制台

  1. 在 Google Cloud 控制台中,转到代理池页面。

    转到“代理池”

    系统随即将显示代理池页面,其中列出了现有的代理池。

  2. 点击创建另一个池

  3. 为您的池命名,并视需要添加描述。

  4. 您可以选择设置将应用于整个池的带宽限制。所指定的带宽(以 MB/s 为单位)将在池中的所有代理之间拆分。 如需了解详情,请参阅管理网络带宽

  5. 点击创建

REST API

使用 projects.agentPools.create

POST https://storagetransfer.googleapis.com/v1/projects/PROJECT_ID/agentPools?agent_pool_id=AGENT_POOL_ID

其中:

  • PROJECT_ID:要在其中创建代理池的项目 ID。
  • AGENT_POOL_ID:您要创建的代理池 ID。

如果代理池卡在 Creating 状态超过 30 分钟,我们建议您删除代理池并重新创建。

当代理池处于 Creating 状态时,从项目中撤消所需的 Storage Transfer Service 权限会导致服务行为不正确。

gcloud CLI

如需使用 gcloud 命令行工具创建代理池,请运行 [gcloud transfer agent-pools create][agent-pools-create]。

gcloud transfer agent-pools create NAME \
  [--no-async] \
  [--bandwidth-limit=BANDWIDTH_LIMIT] \
  [--display-name=DISPLAY_NAME]

其中有以下选项可用:

  • NAME 是此池的唯一永久性标识符。

  • --no-async 会阻止终端中的其他任务,直到池创建为止。如果未包含,则池创建将异步运行。

  • --bandwidth-limit 定义了此池的代理可以使用的带宽(以 MB/秒为单位)。带宽上限适用于池中的所有代理,可防止池的转移工作负载干扰共用带宽的其他操作。例如,输入“50”可将带宽设置为 50 MB/秒。如果未指定此标志,则此池的代理将使用它们可用的所有带宽。

  • --display-name 是可修改的名称,有助于您识别此池。您可以包括可能不适合池的唯一完整资源名称的详细信息。

安装转移代理

转移代理是通过 Storage Transfer Service 协调来源的转移活动的软件代理。转移代理必须安装在具有源数据访问权限的系统上。

gcloud CLI

如需使用 gcloud CLI 安装要用于兼容 S3 的来源的代理,请使用 transfer agents install 命令。

您必须提供访问凭据,该凭据可以作为 AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY 值存储在环境变量中,也可以作为默认凭据存储在系统的配置文件中。

export AWS_ACCESS_KEY_ID=ID
export AWS_SECRET_ACCESS_KEY=SECRET
gcloud transfer agents install --pool=POOL_NAME

如需使用服务账号密钥运行代理,请使用 --creds-file 选项:

gcloud transfer agents install --pool=POOL_NAME \
  --creds-file=/relative/path/to/service-account-key.json

您必须将以下 IAM 角色授予用于运行转移代理的用户或服务账号:

创建转移作业

Google Cloud 控制台

请按照以下步骤创建从 S3 兼容来源到 Cloud Storage 存储桶的转移作业。

  1. 进入 Google Cloud 控制台中的 Storage Transfer Service 页面。

    转到 Storage Transfer Service

  2. 点击创建转移作业。 系统随即会显示创建转移作业页面。

  3. 选择与 S3 兼容的对象存储作为来源类型。目标位置必须是 Google Cloud Storage

    点击下一步

配置来源

  1. 指定此转移作业所需的信息:

    1. 选择您为此转移作业配置的代理池

    2. 输入相对于端点的存储桶名称。例如,如果您的数据位于:

      https://example.com/bucket_a

      输入:bucket_a

    3. 输入端点。请勿包含协议(http://https://)。例如:

      example.com

  2. 为此转移作业指定任何可选特性:

    1. 输入用于对请求签名的签名区域

    2. 选择此请求的签名流程

    3. 选择寻址样式。这决定了存储桶名称是以路径样式(例如 https://example.com/bucket-name/key-name)还是虚拟托管样式(例如 https://bucket-name.example.com/key-name)提供。如需了解详情,请参阅 Amazon 文档中的存储桶的虚拟托管

    4. 选择网络协议

    5. 选择要使用的 Listing API 版本。如需了解详情,请参阅 ListObjectsV2ListObjects 文档。

  3. 点击下一步

配置接收器

  1. 存储桶或文件夹字段中,输入目标存储桶以及(可选)文件夹名称,或点击浏览从当前项目的现有存储桶列表中选择一个存储桶。如需创建新存储桶,请点击 创建新存储桶

  2. 点击下一步

选择转移作业设置

  1. 说明字段中,输入转移作业的说明。最佳做法是输入有意义且唯一的说明,以便区分作业。

  2. 元数据选项下,您可以选择使用默认选项,也可以点击查看和选择选项为所有受支持的元数据指定值。如需了解详情,请参阅元数据保留

  3. 何时覆盖下,选择以下选项之一:

    • 如果不同:如果同名的源文件具有不同的 ETag 或校验和值,则覆盖目标文件。

    • 始终:当源文件同名时,即使源文件相同,也始终覆盖目标文件。

  4. 何时删除下,选择以下选项之一:

    • 永不:永不从源或目标中删除文件。

    • 在转移文件后从数据源删除文件:将文件转移到目标位置后,从数据源中删除文件。

    • 如果文件不在数据源中则从目标位置删除文件:如果目标 Cloud Storage 存储桶中的文件也不在数据源中,则从 Cloud Storage 存储桶中删除文件。

      此选项可确保目标 Cloud Storage 存储桶与您的数据源完全匹配。

  5. 通知选项下,选择 Pub/Sub 主题以及要通知的事件。如需了解详情,请参阅 Pub/Sub 通知

  6. 点击下一步

安排转移作业

您可以安排转移作业仅运行一次,也可以配置周期性转移作业。

点击创建以创建转移作业。

gcloud CLI

在使用 gcloud CLI 创建转移作业之前,请按照配置对 Cloud Storage 接收器的访问权限中的说明操作。

如需使用 gcloud CLI 创建从 S3 兼容来源到 Cloud Storage 存储桶的转移作业,请使用以下命令。

gcloud transfer jobs create s3://SOURCE_BUCKET_NAME gs://SINK_BUCKET_NAME \
  --source-agent-pool=POOL_NAME \
  --source-endpoint=ENDPOINT \
  --source-signing-region=REGION \
  --source-auth-method=AWS_SIGNATURE_V2 | AWS_SIGNATURE_V4 \
  --source-request-model=PATH_STYLE | VIRTUAL_HOSTED_STYLE \
  --source-network-protocol=HTTP | HTTPS \
  --source-list-api=LIST_OBJECTS | LIST_OBJECTS_V2

必须提供以下标志:

  • --source-agent-pool 是要用于此转移作业的代理池的名称。

  • --source-endpoint 指定存储系统的端点。例如 s3.us-east.example.com。请向您的提供商确认正确的格式。

其余标志是可选的:

  • --source-signing-region 指定签名请求的区域。如果您的存储提供商不需要签名区域,请省略此标志。
  • --source-auth-method 指定要使用的身份验证方法。有效值为 AWS_SIGNATURE_V2AWS_SIGNATURE_V4。如需了解详情,请参阅 Amazon 的 SigV4SigV2 文档。
  • --source-request-model 指定要使用的寻址样式。有效值为 PATH_STYLEVIRTUAL_HOSTED_STYLE。路径样式使用格式 https://s3.REGION.example.com/BUCKET_NAME/KEY_NAME。虚拟托管样式使用格式 https://BUCKET_NAME.s3.REGION.example.com/KEY_NAME
  • --source-network-protocol 指定代理应该为此作业使用的网络协议。有效值为 HTTPHTTPS
  • --source-list-api 指定用于从存储桶返回对象的 S3 Listing API 的版本。有效值为 LIST_OBJECTSLIST_OBJECTS_V2。如需了解详情,请参阅 Amazon 的 ListObjectsV2ListObjects 文档。

如需了解其他转移作业选项,请运行 gcloud transfer jobs create --help 或参阅 gcloud 参考文档

REST API

在使用 REST API 创建转移作业之前,请按照配置对 Cloud Storage 接收器的访问权限中的说明操作。

要使用 REST API 从 S3 兼容来源创建转移作业,请创建一个类似于以下示例的 JSON 对象。

POST https://storagetransfer.googleapis.com/v1/transferJobs
{
  ...
  "transferSpec": {
    "source_agent_pool_name":"POOL_NAME",
    "awsS3CompatibleData": {
      "region":"us-east-1",
      "s3Metadata":{
        "protocol": "NETWORK_PROTOCOL_HTTPS",
        "requestModel": "REQUEST_MODEL_VIRTUAL_HOSTED_STYLE",
        "authMethod": "AUTH_METHOD_AWS_SIGNATURE_V4"
      },
      "endpoint": "example.com",
      "bucketName": "BUCKET_NAME",
      "path": "PATH",
    },
    "gcsDataSink": {
      "bucketName": "SINK_NAME",
      "path": "SINK_PATH"
    },
    "transferOptions": {
      "deleteObjectsFromSourceAfterTransfer": false
    }
  }
}

如需了解字段说明,请参阅 AwsS3CompatibleData API 参考

客户端库

在使用客户端库创建转移作业之前,请按照配置对 Cloud Storage 接收器的访问权限中的说明操作。

Go

如需了解如何安装和使用 Storage Transfer Service 客户端库,请参阅 Storage Transfer Service 客户端库。 如需了解详情,请参阅 Storage Transfer Service Go API 参考文档

如需向 Storage Transfer Service 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证


import (
	"context"
	"fmt"
	"io"

	storagetransfer "cloud.google.com/go/storagetransfer/apiv1"
	"cloud.google.com/go/storagetransfer/apiv1/storagetransferpb"
)

func transferFromS3CompatibleSource(w io.Writer, projectID string, sourceAgentPoolName string, sourceBucketName string, sourcePath string, gcsSinkBucket string, gcsPath string) (*storagetransferpb.TransferJob, error) {
	// Your project id.
	// projectId := "my-project-id"

	// The agent pool associated with the S3 compatible data source. If not provided, defaults to the default agent.
	// sourceAgentPoolName := "projects/my-project/agentPools/transfer_service_default"

	// The S3 compatible bucket name to transfer data from.
	//sourceBucketName = "my-bucket-name"

	// The S3 compatible path (object prefix) to transfer data from.
	//sourcePath = "path/to/data"

	// The ID of the GCS bucket to transfer data to.
	//gcsSinkBucket = "my-sink-bucket"

	// The GCS path (object prefix) to transfer data to.
	//gcsPath = "path/to/data"

	// The S3 region of the source bucket.
	region := "us-east-1"

	// The S3 compatible endpoint.
	endpoint := "us-east-1.example.com"

	// The S3 compatible network protocol.
	protocol := storagetransferpb.S3CompatibleMetadata_NETWORK_PROTOCOL_HTTPS

	// The S3 compatible request model.
	requestModel := storagetransferpb.S3CompatibleMetadata_REQUEST_MODEL_VIRTUAL_HOSTED_STYLE

	// The S3 Compatible auth method.
	authMethod := storagetransferpb.S3CompatibleMetadata_AUTH_METHOD_AWS_SIGNATURE_V4

	ctx := context.Background()
	client, err := storagetransfer.NewClient(ctx)
	if err != nil {
		return nil, fmt.Errorf("storagetransfer.NewClient: %w", err)
	}
	defer client.Close()

	req := &storagetransferpb.CreateTransferJobRequest{
		TransferJob: &storagetransferpb.TransferJob{
			ProjectId: projectID,
			TransferSpec: &storagetransferpb.TransferSpec{
				SourceAgentPoolName: sourceAgentPoolName,
				DataSource: &storagetransferpb.TransferSpec_AwsS3CompatibleDataSource{
					AwsS3CompatibleDataSource: &storagetransferpb.AwsS3CompatibleData{
						BucketName: sourceBucketName,
						Path:       sourcePath,
						Endpoint:   endpoint,
						Region:     region,
						DataProvider: &storagetransferpb.AwsS3CompatibleData_S3Metadata{
							S3Metadata: &storagetransferpb.S3CompatibleMetadata{
								AuthMethod:   authMethod,
								RequestModel: requestModel,
								Protocol:     protocol,
							},
						},
					}},
				DataSink: &storagetransferpb.TransferSpec_GcsDataSink{
					GcsDataSink: &storagetransferpb.GcsData{
						BucketName: gcsSinkBucket,
						Path:       gcsPath,
					},
				},
			},
			Status: storagetransferpb.TransferJob_ENABLED,
		},
	}

	resp, err := client.CreateTransferJob(ctx, req)
	if err != nil {
		return nil, fmt.Errorf("failed to create transfer job: %w", err)
	}
	if _, err = client.RunTransferJob(ctx, &storagetransferpb.RunTransferJobRequest{
		ProjectId: projectID,
		JobName:   resp.Name,
	}); err != nil {
		return nil, fmt.Errorf("failed to run transfer job: %w", err)
	}
	fmt.Fprintf(w, "Created and ran transfer job from %v to %v with name %v", sourceBucketName, gcsSinkBucket, resp.Name)
	return resp, nil
}

Java

如需了解如何安装和使用 Storage Transfer Service 客户端库,请参阅 Storage Transfer Service 客户端库。 如需了解详情,请参阅 Storage Transfer Service Java API 参考文档

如需向 Storage Transfer Service 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证

import static com.google.storagetransfer.v1.proto.TransferTypes.S3CompatibleMetadata.AuthMethod;
import static com.google.storagetransfer.v1.proto.TransferTypes.S3CompatibleMetadata.NetworkProtocol;
import static com.google.storagetransfer.v1.proto.TransferTypes.S3CompatibleMetadata.RequestModel;

import com.google.storagetransfer.v1.proto.StorageTransferServiceClient;
import com.google.storagetransfer.v1.proto.TransferProto;
import com.google.storagetransfer.v1.proto.TransferTypes;
import com.google.storagetransfer.v1.proto.TransferTypes.GcsData;
import com.google.storagetransfer.v1.proto.TransferTypes.TransferJob;
import com.google.storagetransfer.v1.proto.TransferTypes.TransferSpec;
import java.io.IOException;

public class TransferFromS3CompatibleSource {

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.

    // Your project id
    String projectId = "my-project-id";

    // The agent pool associated with the S3 compatible data source. If not provided, defaults to
    // the default agent
    String sourceAgentPoolName = "projects/my-project-id/agentPools/transfer_service_default";

    // The S3 compatible bucket name to transfer data from
    String sourceBucketName = "my-bucket-name";

    // The S3 compatible path (object prefix) to transfer data from
    String sourcePath = "path/to/data";

    // The ID of the GCS bucket to transfer data to
    String gcsSinkBucket = "my-sink-bucket";

    // The GCS path (object prefix) to transfer data to
    String gcsPath = "path/to/data";

    // The S3 region of the source bucket
    String region = "us-east-1";

    // The S3 compatible endpoint
    String endpoint = "us-east-1.example.com";

    // The S3 compatible network protocol
    NetworkProtocol protocol = NetworkProtocol.NETWORK_PROTOCOL_HTTPS;

    // The S3 compatible request model
    RequestModel requestModel = RequestModel.REQUEST_MODEL_VIRTUAL_HOSTED_STYLE;

    // The S3 Compatible auth method
    AuthMethod authMethod = AuthMethod.AUTH_METHOD_AWS_SIGNATURE_V4;

    transferFromS3CompatibleSource(
        projectId,
        sourceAgentPoolName,
        sourceBucketName,
        sourcePath,
        region,
        endpoint,
        protocol,
        requestModel,
        authMethod,
        gcsSinkBucket,
        gcsPath);
  }

  public static void transferFromS3CompatibleSource(
      String projectId,
      String sourceAgentPoolName,
      String sourceBucketName,
      String sourcePath,
      String region,
      String endpoint,
      NetworkProtocol protocol,
      RequestModel requestModel,
      AuthMethod authMethod,
      String gcsSinkBucket,
      String gcsPath)
      throws IOException {
    TransferJob transferJob =
        TransferJob.newBuilder()
            .setProjectId(projectId)
            .setTransferSpec(
                TransferSpec.newBuilder()
                    .setSourceAgentPoolName(sourceAgentPoolName)
                    .setAwsS3CompatibleDataSource(
                        TransferTypes.AwsS3CompatibleData.newBuilder()
                            .setRegion(region)
                            .setEndpoint(endpoint)
                            .setBucketName(sourceBucketName)
                            .setPath(sourcePath)
                            .setS3Metadata(
                                TransferTypes.S3CompatibleMetadata.newBuilder()
                                    .setProtocol(protocol)
                                    .setRequestModel(requestModel)
                                    .setAuthMethod(authMethod)
                                    .build())
                            .build())
                    .setGcsDataSink(
                        GcsData.newBuilder().setBucketName(gcsSinkBucket).setPath(gcsPath).build()))
            .setStatus(TransferJob.Status.ENABLED)
            .build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources,
    // or use "try-with-close" statement to do this automatically.
    try (StorageTransferServiceClient storageTransfer = StorageTransferServiceClient.create()) {

      // Create the transfer job
      TransferJob response =
          storageTransfer.createTransferJob(
              TransferProto.CreateTransferJobRequest.newBuilder()
                  .setTransferJob(transferJob)
                  .build());

      System.out.println(
          "Created a transfer job from "
              + sourceBucketName
              + " to "
              + gcsSinkBucket
              + " with "
              + "name "
              + response.getName());
    }
  }
}

Node.js

如需了解如何安装和使用 Storage Transfer Service 客户端库,请参阅 Storage Transfer Service 客户端库。 如需了解详情,请参阅 Storage Transfer Service Node.js API 参考文档

如需向 Storage Transfer Service 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证


// Imports the Google Cloud client library
const storageTransfer = require('@google-cloud/storage-transfer');

/**
 * TODO(developer): Uncomment the following lines before running the sample.
 */
// Useful enums for AWS S3-Compatible Transfers
// const {AuthMethod, NetworkProtocol, RequestModel} = storageTransfer.protos.google.storagetransfer.v1.S3CompatibleMetadata;

// Your project id
// const projectId = 'my-project';

// The agent pool associated with the S3-compatible data source. Defaults to the default agent
// const sourceAgentPoolName = 'projects/my-project/agentPools/transfer_service_default';

// The S3-compatible bucket name to transfer data from
// const sourceBucketName = "my-bucket-name";

// The S3-compatible path (object prefix) to transfer data from
// const sourcePath = "path/to/data/";

// The ID of the GCS bucket to transfer data to
// const gcsSinkBucket = "my-sink-bucket";

// The GCS path (object prefix) to transfer data to
// const gcsPath = "path/to/data/";

// The S3 region of the source bucket
// const region = 'us-east-1';

// The S3-compatible endpoint
// const endpoint = "us-east-1.example.com";

// The S3-compatible network protocol
// const protocol = NetworkProtocol.NETWORK_PROTOCOL_HTTPS;

// The S3-compatible request model
// const requestModel = RequestModel.REQUEST_MODEL_VIRTUAL_HOSTED_STYLE;

// The S3-compatible auth method
// const authMethod = AuthMethod.AUTH_METHOD_AWS_SIGNATURE_V4;

// Creates a client
const client = new storageTransfer.StorageTransferServiceClient();

/**
 * Creates a transfer from an AWS S3-compatible source to GCS
 */
async function transferFromS3CompatibleSource() {
  // Runs the request and creates the job
  const [transferJob] = await client.createTransferJob({
    transferJob: {
      projectId,
      transferSpec: {
        sourceAgentPoolName,
        awsS3CompatibleDataSource: {
          region,
          s3Metadata: {
            authMethod,
            protocol,
            requestModel,
          },
          endpoint,
          bucketName: sourceBucketName,
          path: sourcePath,
        },
        gcsDataSink: {
          bucketName: gcsSinkBucket,
          path: gcsPath,
        },
      },
      status: 'ENABLED',
    },
  });

  await client.runTransferJob({
    jobName: transferJob.name,
    projectId,
  });

  console.log(
    `Created and ran a transfer job from '${sourceBucketName}' to '${gcsSinkBucket}' with name ${transferJob.name}`
  );
}

transferFromS3CompatibleSource();

Python

如需了解如何安装和使用 Storage Transfer Service 客户端库,请参阅 Storage Transfer Service 客户端库。 如需了解详情,请参阅 Storage Transfer Service Python API 参考文档

如需向 Storage Transfer Service 进行身份验证,请设置应用默认凭据。 如需了解详情,请参阅为本地开发环境设置身份验证

from google.cloud import storage_transfer

AuthMethod = storage_transfer.S3CompatibleMetadata.AuthMethod
NetworkProtocol = storage_transfer.S3CompatibleMetadata.NetworkProtocol
RequestModel = storage_transfer.S3CompatibleMetadata.RequestModel

def transfer_from_S3_compat_to_gcs(
    project_id: str,
    description: str,
    source_agent_pool_name: str,
    source_bucket_name: str,
    source_path: str,
    gcs_sink_bucket: str,
    gcs_path: str,
    region: str,
    endpoint: str,
    protocol: NetworkProtocol,
    request_model: RequestModel,
    auth_method: AuthMethod,
) -> None:
    """Creates a transfer from an AWS S3-compatible source to GCS"""

    client = storage_transfer.StorageTransferServiceClient()

    # The ID of the Google Cloud Platform Project that owns the job
    # project_id = 'my-project'

    # A useful description for your transfer job
    # description = 'My transfer job'

    # The agent pool associated with the S3-compatible data source.
    # Defaults to 'projects/{project_id}/agentPools/transfer_service_default'
    # source_agent_pool_name = 'projects/my-project/agentPools/my-agent'

    # The S3 compatible bucket name to transfer data from
    # source_bucket_name = "my-bucket-name"

    # The S3 compatible path (object prefix) to transfer data from
    # source_path = "path/to/data/"

    # The ID of the GCS bucket to transfer data to
    # gcs_sink_bucket = "my-sink-bucket"

    # The GCS path (object prefix) to transfer data to
    # gcs_path = "path/to/data/"

    # The S3 region of the source bucket
    # region = 'us-east-1'

    # The S3-compatible endpoint
    # endpoint = "us-east-1.example.com"

    # The S3-compatible network protocol
    # protocol = NetworkProtocol.NETWORK_PROTOCOL_HTTPS

    # The S3-compatible request model
    # request_model = RequestModel.REQUEST_MODEL_VIRTUAL_HOSTED_STYLE

    # The S3-compatible auth method
    # auth_method = AuthMethod.AUTH_METHOD_AWS_SIGNATURE_V4

    transfer_job_request = storage_transfer.CreateTransferJobRequest(
        {
            "transfer_job": {
                "project_id": project_id,
                "description": description,
                "status": storage_transfer.TransferJob.Status.ENABLED,
                "transfer_spec": {
                    "source_agent_pool_name": source_agent_pool_name,
                    "aws_s3_compatible_data_source": {
                        "region": region,
                        "s3_metadata": {
                            "auth_method": auth_method,
                            "protocol": protocol,
                            "request_model": request_model,
                        },
                        "endpoint": endpoint,
                        "bucket_name": source_bucket_name,
                        "path": source_path,
                    },
                    "gcs_data_sink": {
                        "bucket_name": gcs_sink_bucket,
                        "path": gcs_path,
                    },
                },
            }
        }
    )

    result = client.create_transfer_job(transfer_job_request)
    print(f"Created transferJob: {result.name}")

常见问题解答

从 S3 兼容存储空间转移是否需要付费?

从兼容 S3 的存储空间转移不会产生“需要代理的 Storage Transfer Service 转移”费用。如需了解可能产生的任何其他费用,请参阅价格。此外,来源云提供商可能还会产生传出数据传输和运营费用。

兼容 S3 的存储空间转移是否支持 Cloud Logging?

支持,您可以按照适用于 Storage Transfer Service 的 Cloud Logging 中的说明为转移作业启用 Cloud Logging。

是否支持使用清单的转移作业?

支持,兼容 S3 的转移作业支持清单文件

如果我在转移作业启动后向源存储桶添加对象,该对象是否会转移?

Storage Transfer Service 对源存储桶执行列出操作以计算与目标位置的差异。如果在添加新对象时列出操作已完成,则该对象会被跳过,直到下一次转移才会被列出。

Storage Transfer Service 是否会对 S3 兼容来源执行校验和匹配?

Storage Transfer Service 依赖于来源返回的校验和数据。对于 S3 兼容存储空间,Storage Transfer Service 预期对象的 Etag 是对象的 MD5 哈希值。

但是,使用 S3 分段上传转移到 S3 兼容存储空间的所有对象都没有 MD5 ETag。在这种情况下,Storage Transfer Service 使用文件大小来验证转移的对象。

从 S3 兼容存储空间转移可以达到什么吞吐量?

您可以添加更多转移代理来提高转移吞吐量。我们建议使用 3 个代理以实现容错,并填充 <10Gbps 的管道。如需进一步提高吞吐量,请添加更多代理。您可以在转移过程中添加和移除代理。

要将数据从 Amazon S3 转移到 Cloud Storage,应该将转移代理部署在何处?

在 Amazon EC2 或 EKS 中,您可以在您的存储桶所在区域中安装代理。您也可以在 Google Cloud 中,在最近的区域中运行代理。