設定物件儲存的 Rclone

您可以將 Rclone 與原生 OCI Object Storage API 搭配使用,將資料移轉至 OCI Object Storage 分類桶。請記住目標移轉儲存桶,或參閱教學課程將資料置於物件儲存中,瞭解如何建立 OCI Object Storage 儲存桶。
第一個步驟包括取得適當的證明資料和 API 端點。此解決方案將在 Linux 主機上使用 Rclone 並以 OCI 使用者加上 API 金鑰進行認證,請參閱 Rclone Oracle Object Storage 文件,瞭解其他授權方法以及如何下載並安裝 Rclone 的資訊。

附註:

如需上述參考的資源,請參閱本手冊其他地方的「瀏覽更多」,以取得適當的連結。

使用 OCI 使用者和 API 金鑰設定認證,取得 OCI 租用戶命名空間和儲存桶區間

產生 API 簽署組、設定組態檔,以及取得租用戶命名空間、區間資訊以及區域物件儲存 API 端點。

  1. 請先產生 API 簽署金鑰組:
    1. 檢視使用者的詳細資料。
      • 如果您正在建立自己的 API 金鑰,請開啟「設定檔」功能表 (使用者功能表圖示),然後按一下使用者設定值
      • 如果您是管理員建立其他使用者的 API 金鑰,請在主控台中按一下識別,然後按一下使用者。在清單中找出使用者,然後按一下該使用者的名稱以檢視詳細資訊。
    2. 資源段落的頁面左側,按一下 API 金鑰
    3. 按一下新增 API 金鑰
    4. 按一下 API 金鑰清單左上方的新增 API 金鑰新增 API 金鑰對話方塊便會顯示。
    5. 按一下下載私密金鑰,並將金鑰儲存至您的 .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 Object Storage 設定 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 Object Storage (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 物件儲存的功能表選項。
  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 時所建立及記錄的儲存桶區間):
    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