为对象存储配置 Rclone

您可以将 Rclone 与原生 OCI Object Storage API 一起使用,将数据迁移到 OCI Object Storage Buckets 中。请记住目标迁移存储桶,或参阅将数据放入对象存储教程,了解如何创建 OCI 对象存储存储桶。
第一步包括获取正确的身份证明和 API 端点。此解决方案将在 Linux 主机上使用 Rclone 并使用 OCI 用户和 API 密钥进行身份验证。有关其他授权方法以及如何下载和安装 Rclone 的信息,请参阅 Rclone Oracle 对象存储文档。

注意:

有关上述参考资源,请参阅本手册中其他地方的“探索更多”以获得相应的链接。

使用 OCI 用户和 API 密钥设置验证,获取 OCI 租户名称空间和存储桶区间

生成 API 签名对、设置配置文件并获取租户名称空间、区间信息和区域对象存储 API 端点。

  1. 首先生成 API 签名密钥对:
    1. 查看用户的详细信息。
      • 如果您要为自己创建 API 密钥,请打开“概要信息”菜单(“用户”菜单图标)并单击用户设置
      • 如果您是为其他用户创建 API 密钥的管理员,请在控制台中单击身份,然后单击用户。在列表中找到用户,然后单击用户名以查看详细信息。
    2. 在页面左侧的资源部分中,单击 API 密钥
    3. 单击添加 API 密钥
    4. 单击 API 密钥列表左上角的添加 API 密钥。此时将显示添加 API 密钥对话框。
    5. 单击 Download Private Key 并将密钥保存到 .oci 目录。在大多数情况下,您不需要下载公钥。

      注意:

      • 如果您没有 .oci 目录,请在主目录中创建目录
      • 如果浏览器将私钥下载到其他目录,请确保将其移动到 .oci 目录中
      .
    6. 单击添加

      该密钥将添加到 OCI 用户的资源中,并显示配置文件预览。请注意,配置文件已标记为 DEFAULT;您稍后在设置 Rclone 配置时将需要配置文件名称。将配置文件片段从文本框复制并粘贴到 .oci 目录中名为 config 的文件中。更新配置文件中的 key_file 路径以匹配上面的步骤 e 中的位置。保存文件路径以设置 Rclone 配置。

  2. 获取对象存储名称空间字符串:
    1. 打开“概要信息”菜单,然后单击租户:<your_tenancy_name> 。您的名称空间字符串列在对象存储设置下。
    2. 复制名称空间字符串,因为设置 Rclone 时需要它。
  3. 确定存储桶区间和区域:
    1. 在 OCI 控制台中,依次导航到存储对象存储和归档存储存储桶,并查找将迁移数据的存储桶的名称。
    2. 单击存储桶名称以查看详细信息。
    3. 查看 OCI 控制台页面的左上角,并记下存储桶所在的区域和区域名称。设置 Rclone 时将需要此信息。
    4. 单击区间旁边的名称链接可查看区间详细信息。
    5. 区间详细信息页上,在区间信息选项卡下查找并复制区间 OCID。设置 Rclone 时需要此信息,

OCI 对象存储配置 Rclone

接下来,您需要为 OCI 对象存储配置 Rclone。执行以下过程。

  1. 导航到 Linux 系统并运行 rclone config 以启动交互式设置过程:
    $ rclone config
    No remotes found, make a new one?
    e) Edit existing remote
    n) New remote
    d) Delete remote
    r) Rename remote
    c) Copy remote
    s) Set configuration password
    q) Quit config
    e/n/d/r/c/s/q>
  2. 选择选项 n) New remote,并在出现提示时输入新远程服务器的名称:
    Enter name for new remote.
    <enter your name here>
  3. 下一个提示将询问存储类型,并显示选项列表。选择与 OCI 对象存储 (oracleobjectstorage) 关联的编号:
    Option Storage.
    Type of storage to configure.
    Choose a number from below, or type in your own value.
    .
    .
    .
    35 / OpenStack Swift (Rackspace Cloud Files, Blomp Cloud Storage, Memset Memstore, OVH)
       \ (swift)
    36 / Oracle Cloud Infrastructure Object Storage
       \ (oracleobjectstorage)
    37 / Pcloud
       \ (pcloud)
    <snip>
    Storage> 36

    注意:

    截至本文撰写时,该选项为数字 36。此数量随着 Rclone 发行版的变化而变化,因为它们增加了额外的存储选项。请务必确认您正在为 OCI Object Storage 选择菜单选项。
  4. 选择要使用的验证提供程序。对于此示例,将选择选项 2 OCI user and API Key
    Option provider.
    Choose your Auth Provider
    Choose a number from below, or type in your own string value.
    Press Enter for the default (env_auth).
     1 / automatically pickup the credentials from runtime(env), first one to provide auth wins
       \ (env_auth)
       / use an OCI user and an API key for authentication.
     2 | you’ll need to put in a config file your tenancy OCID, user OCID, region, the path, fingerprint to an API key.
       | https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm
       \ (user_principal_auth)
       / use instance principals to authorize an instance to make API calls.
     3 | each instance has its own identity, and authenticates using the certificates that are read from instance metadata.
       | https://docs.oracle.com/en-us/iaas/Content/Identity/Tasks/callingservicesfrominstances.htm
       \ (instance_principal_auth)
       / use workload identity to grant OCI Container Engine for Kubernetes workloads policy-driven access to OCI resources using OCI Identity and Access Management (IAM).
     4 | https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contenggrantingworkloadaccesstoresources.htm
       \ (workload_identity_auth)
     5 / use resource principals to make API calls
       \ (resource_principal_auth)
     6 / no credentials needed, this is typically for reading public buckets
       \ (no_auth)
    provider> 2
  5. 输入 OCI 租户对象存储名称空间(在“使用 OCI 用户和 API 密钥设置验证,获取 OCI 租户名称空间和存储桶区间”中执行步骤 2b 时创建和记录该名称空间):
    Option namespace.
    Object storage namespace
    Enter a value.
    namespace> namespace_name
  6. 输入存储桶区间 OCID(在“使用 OCI 用户和 API 密钥设置验证,获取 OCI 租户名称空间和存储桶区间”中执行步骤 3e 时创建和记录的该 OCID):
    Option compartment.
    Object storage compartment OCID
    Enter a value.
    compartment> ocid1.compartment.oc1xxx.xxxx.xxxx.xxxx
  7. 输入存储桶区域(在“使用 OCI 用户和 API 密钥设置验证,获取 OCI 租户名称空间和存储桶区间”中执行步骤 3c 时创建和记录该区域):
    Option region.
    Object storage Region
    Enter a value.
    region> us-ashburn-1
  8. 下一个提示是端点;将此提示留空,这将选择默认区域端点。Rclone 将使用收集的信息来形成完整的端点 URL:
    Option endpoint.
    Endpoint for Object storage API.
    Leave blank to use the default endpoint for the region.
    Enter a value. Press Enter to leave empty.
    endpoint>
  9. 输入 OCI 配置文件位置的完整路径和 config_profile 信息(您在“使用 OCI 用户和 API 密钥设置验证,获取 OCI 租户名称空间和存储桶区间”中执行步骤 1f 时创建和记录的该信息),回答 n 以了解高级配置:
    Option config_file.
    Path to OCI config file
    Choose a number from below, or type in your own string value.
    Press Enter for the default (~/.oci/config).
     1 / oci configuration file location
       \ (~/.oci/config)
    config_file> /home/username/.oci/config
     
    Option config_profile.
    Profile name inside the oci config file
    Choose a number from below, or type in your own string value.
    Press Enter for the default (Default).
     1 / Use the default profile
       \ (Default)
    config_profile> DEFAULT
     
    Edit advanced config?
    y) Yes
    n) No (default)
    y/n> n
  10. 如果一切看起来都正确,则 Rclone 将显示配置的摘要,选择 y 以保存配置:
    
    Options:
    - type: oracleobjectstorage
    - provider: user_principal_auth
    - namespace: namespace
    - compartment: ocid1.compartment.oc1xxx.xxxx.xxxx.xxxx
    - region: us-ashburn-1
    - config_file: /home/username/.oci/config
    - config_profile: DEFAULT
    Keep this "foo" remote?
    y) Yes this is OK (default)
    e) Edit this remote
    d) Delete this remote
    y/e/d> y
     
    Current remotes:
     
    Name                 Type
    ====                 ====
    remote_name          oracleobjectstorage
  11. 退出配置接口:
    e) Edit existing remote
    n) New remote
    d) Delete remote
    r) Rename remote
    c) Copy remote
    s) Set configuration password
    q) Quit config
    e/n/d/r/c/s/q> q
  12. 通过列出区间中的存储桶来测试 Rclone 连接:
    $ rclone lsd remote_name:
              -1 2024-04-19 00:08:33        -1 bucket1