建立抄本檔案共用

使用控制台、命令列介面 (CLI)、API 或 Terraform,在同一都會區內的另一個區域,或同一地理區域內的不同都會區中,建立複本檔案共用。

下表顯示在每一個地理位置內哪些都會區域可以彼此抄寫。

本表顯示每個地理區域中可互相複製的都會區。 每個地理位置都是個別的直欄。
美洲 歐洲 亞洲
  • 德州達拉斯 / us-south
  • 蒙特婁 / ca-mon
  • 聖保羅 / br-sao
  • 多倫多 / ca-tor
  • 華盛頓 / us-east
-法蘭克福/ eu-de
-倫敦/ eu-gb
-馬德里/ eu-es
  • 清奈 / in-che
  • 孟買 / in-mum
  • 大阪 / jp-osa
  • 雪梨 / au-syd
  • 東京 / jp-tok

指定的原始檔共用不得已有另一個抄本,且不得是另一個共用的抄本。

如果您要在另一個地區中建立抄本,則需要先建立服務對服務授權。 這兩個檔案服務實例必須屬於相同的帳戶。 不支援跨帳戶抄寫。 如需詳細資訊,請參閱 為 File Storage for VPC 建立服務對服務授權。

當您建立具有區域可用性的檔案共用時,資料會自動在整個區域內進行複製,因此您無需在區域內設定複製對。

在主控台中為檔案共用新增複製

您可以從所有檔案共用清單或檔案共用詳細資料頁面建立檔案共用的抄本。 如果還沒有來源檔案共用,請按照在 主控台中建立檔案共用和掛載目標中的 說明提供一個。 當檔案共用在 File Storage shares for VPC 頁面上顯示為「穩定」時,按一下 Actions 圖示 Actions 圖示,然後按一下 Create Replica

在「建立檔案共用抄本」頁面上,檢閱原始檔共用詳細資料,並完成抄本詳細資料。

  1. 名稱-提供抄本共用的唯一名稱。

  2. 抄本位置-已預先選取地理位置,且無法變更。 請使用「區域」選單來選取複本的區域。 選單是按地理區域分類的。 在每個地理區域下,都會區地點均按字母順序排列。 點擊地鐵站名稱旁的箭頭以展開其分區,然後點擊某個分區以選取該分區。

  3. 資源群組-從清單中選取資源群組。

  4. 標籤-選擇性地指定 使用者標籤。 您套用至抄本的標籤可以與來源共用的標籤相同或不同。

  5. 設定檔-預先選取 dp2 設定檔,即使原始檔共用是以舊版中的設定檔為基礎。 指定 IOPS 的最大值。 它會決定您在 執行失效接手 之後在抄本上取得的效能。

  6. 裝載目標-選擇性地建立抄本共用的裝載目標。 如果您現在不想建立裝載目標,則可以跳過此步驟。 否則,請按一下「建立」。 在每個檔案共用中,每個 VPC 可以建立一個裝載目標。 視共用的 裝載目標存取模式 而定,建立裝載目標 表單看起來不同。

    • 如果選擇安全群組作為存取模式,請輸入如表 2 所述的資訊。 此動作會建立 虛擬網路介面 並將其連接至裝載目標,以識別具有保留 IP 位址的檔案共用,並套用所選取「安全」群組的規則。 此裝載目標支援傳輸中加密及跨區域裝載。
    用於建立安裝目標的值。
    欄位
    詳細資料
    裝載目標名稱 指定裝載目標名稱。 名稱最多可以為 63 個小寫英數字元,並包含連字號 (-),且必須以小寫字母開頭。 如果需要,您日後可以編輯該名稱。
    區域 區域繼承自檔案共用 (例如,達拉斯 2)。
    VPC 選取可用的 VPC。 此清單僅包含在所選區域內擁有子網的 VPC。
    子網路 請從清單中選取一個子網。
    保留 IP 位址 裝載目標的必要項目。 之後無法變更 IP 位址。 不過,您可以刪除裝載目標,並建立另一個具有不同 IP 位址的裝載目標。
    保留方法 您可以讓檔案服務為您選取 IP 位址。 建立裝載目標之後,保留 IP 會變成可見。 或者,指定您自己的 IP。
    自動釋放 當您刪除裝載目標時,釋放 IP 位址。 預設為啟用。
    安全群組 已選取 VPC 的 預設安全群組。 您可以使用它,或從清單中選取另一個安全群組。
    • 已停用 如果您選擇 VPC 作為存取模式,請提供掛載目標的名稱,並從清單中選擇一個 VPC。 此裝載目標可用來在與檔案共用相同的區域中所選取 VPC 的任何虛擬伺服器實例上裝載檔案共用。 不支援跨區域裝載。

    VPC 存取模式已停用,並將於 2027 年 5 月 6 日停止支援。 請遵循 遷移指南,將原始共用的存取控制模式更新為 security-group

  7. 同步頻率-指定您要將主要檔案共用的變更同步化至抄本共用的頻率。 在「頻率」欄位中,請選擇以下其中一個選項,並設定開始時間:

    • 每 15 分鐘:請輸入開始時間的分鐘數。
    • 每小時:請輸入開始時間的分鐘數。
    • 每日:請以協調世界時(UTC)為單位,以 HH:MM 格式輸入開始時間,時間範圍為 00:00 至 23:59。
    • 每週:選擇要執行複製的星期幾(一天或多天),並以 UTC 時間、HH:MM 格式輸入開始時間,時間範圍為 00:00 至 23:59。
    • 每月:請輸入執行複製的當月日期(1 至 31),並以 HH:MM 格式輸入 UTC 時間,時間範圍為 00:00 至 23:59。
    • Cron 表達式:請以 minute hour day month weekday 的格式輸入 cron-spec 表達式。 複製作業的排程間隔不得少於 15 分鐘。 例如,若要每天 UTC 時間下午 5:30 進行複製,請輸入 30 17 * * *
  8. 加密 — 複本會始終繼承來源共用資料夾的加密設定。 無法變更加密類型。 如果來源共用的資料集使用供應商管理的加密功能,則會顯示「供應商管理」選項,但無法選取該選項。 如果來源共用資料夾使用「客戶自行管理的加密」,則金鑰詳細資訊將以唯讀方式顯示,包括加密類型、金鑰名稱、金鑰管理服務執行個體以及金鑰 ID。

  9. 在側邊畫面中,檢閱您的預估成本,並套用折扣代碼 (如果您有的話)。

  10. 按一下「建立檔案共用」。

如果您尚未準備好訂購,或只是尋找定價資訊,則可以將您在側邊畫面中看到的資訊新增至「預估」。 如需更多關於此功能如何運作的資訊,請參閱 估算您的成本

從 CLI 將抄寫新增至檔案共用

您可以使用 CLI 在其他區域或區域中建立具有複製共用的檔案共用,或為現有檔案共用建立複製共用。

在使用 CLI 之前,您必須先安裝「IBM Cloud」CLI 以及 VPC CLI 外掛程式。 如需相關資訊,請參閱 CLI 必要條件

從 CLI 建立與抄本的檔案共用

您可以同時建立一個區域性檔案共用,並在同一區域內建立其複本。 此方法僅適用於其副本仍位於同一區域內的區域性共享。 跨區域複本必須在另一個步驟中建立,因為在初始化複本時,來源共用資料夾必須處於穩定狀態。

當您使用 ibmcloud is share-create 命令建立共用時,您可以透過指定選項 --replica-share-name--replica-share-profile--replica-share-cron-spec--replica-share-zone 的值來同時建立副本共用。cron-spec 指定複製頻率,您可以安排最多 15 分鐘複製一次資料。 有關命令選項的更多信息,請參閱 ibmcloud is share-create

在下列範例中,會在 us-south-2 中建立共用 my-source-file-share,並在 us-south-1 中建立抄本檔案共用 my-replica-file-share。 在此範例中,只為來源檔案共用建立一個掛載目標。 您也可以使用與 --replica-share-mount-targets 選項相同的 JSON 語法,為複製共用建立掛載目標。

ibmcloud is share-create --name my-source-file-share --zone us-south-2 --profile dp2 --size 1500 --iops 2000  --user-tags env:dev --mount-targets '[{"name":"my-source-mount-target","virtual_network_interface": {"name":"my-source-vni","subnet": {"id":"0717-c66032c9-048d-4c35-aa83-c932e24afdbb"}}}]' --replica-share-name my-replica-file-share --replica-share-profile dp2 --replica-share-cron-spec '55 09 * * *' --replica-share-zone us-south-1
Creating file share my-source-file-share under account Test Account as user test.user@ibm.com...
ID                                 r006-0a3444bc-df55-4c2e-aef4-f37a9a8d8262
Name                               my-source-file-share
CRN                                crn:v1:bluemix:public:is:us-south-2:a/a1234567::share:r006-0a3444bc-df55-4c2e-aef4-f37a9a8d8262
Lifecycle state                    pending
Access control mode                security_group
Accessor binding role              none
Allowed transit encryption modes   user_managed,none
Zone                               us-south-2
Profile                            dp2
Size(GB)                           1500
IOPS                               2000
User Tags                          env:dev
Encryption                         provider_managed
Mount Targets                      ID                                          Name
                                   r006-67799c85-09cf-4cfe-811d-effa10c99395   my-source-mount-target
Resource group                     ID                                 Name
                                   6edefe513d934fdd872e78ee6a8e73ef   defaults
Created                            2025-08-01T17:25:05+00:00
Replication share                  ID                                          Name                    Resource type
                                   r006-2068a709-8c18-4844-8c1d-42b83889dfb3   my-replica-file-share   share
Replication role                   source
Replication status                 none
Replication status reasons         Status code   Status message
                                   -             -
Snapshot count                     0
Snapshot size                      0
Source snapshot                    -
Allowed Access Protocols           nfs4
Availability Mode                  zonal
Bandwidth(Mbps)                    1
Storage Generation                 1

從 CLI 建立現有檔案共用的抄本

您可以為現有的檔案共用建立一個複本,該複本可位於同一區域,或位於同一地理區域內的另一個區域。

  1. 透過使用 ibmcloud is shares 指令列出地區中的檔案共用,從 CLI 尋找來源檔案共用。

    ibmcloud is shares
    
    Listing shares in all resource groups and region us-south under account Test Account as user test.user@ibm.com...
    ID                                          Name                    Lifecycle state   Zone         Profile   Size(GB)   Resource group   Replication role   Accessor binding role   Snapshot count   Snapshot size
    r006-a8d6af48-0c97-4c6b-bab1-fbefdc1e1e03   my-file-share           stable            us-south-2   dp2       10         defaults         none               none                    0                0
    r006-aaf4bfe9-358c-4faa-a4ec-0b955090b940   my-file-share-2         stable            us-south-2   dp2       10         defaults         none               none                    0                0
    r006-a60bfa90-a893-40ad-be34-28ab51a963f9   replica-dal-2           stable            us-south-2   dp2       10         defaults         replica            none                    0                0
    r006-3f21e3c3-e12d-425f-ab77-810cabfde8df   source-dal-1            stable            us-south-1   dp2       10         defaults         source             none                    0                0
    r006-455b601c-8fc1-4476-8771-4708c49c8ef7   my-replica-share-dal-1  stable            us-south-1   dp2       10         defaults         replica            none                    0                0
    r006-4dadac27-cd17-42df-a5fe-1388705d33e0   my-source-share-dal-2   stable            us-south-2   dp2       10         defaults         source             none                    0                0
    
  2. 使用 ibmcloud is share 指令,檢視您要用作來源之檔案共用的詳細資料。 在相同區域中建立抄本時,您可以使用共用的名稱或 ID。 如果您在另一個區域中建立抄本,請記下原始檔共用的 CRN。

    ibmcloud is share my-file-share
    
    Getting file share my-file-share under account Test Account as user test.user@ibm.com...
    ID                           r006-b696742a-92ee-4f6a-bfd7-921d6ddf8fa6
    Name                         my-file-share
    CRN                          crn:v1:bluemix:public:is:us-south-2:a/a1234567::share:r006-b696742a-92ee-4f6a-bfd7-921d6ddf8fa6
    Lifecycle state              stable
    Access control mode          security_group
    Accessor binding role        none
    Zone                         us-south-2
    Profile                      dp2
    Size(GB)                     1000
    IOPS                         1000
    User Tags                    docs:test
    Encryption                   provider_managed
    Mount Targets                ID                                          Name
                                 r006-dd497561-c7c9-4dfb-af0a-c84eeee78b61   my-cli-share-mount-target-1
    Resource group               ID                                 Name
                                 db8e8d865a83e0aae03f25a492c5b39e   Default
    Created                      2023-10-18T22:15:15+00:00
    Replication role             none
    Replication status           none
    Replication status reasons   Status code   Status message
                                 -             -
    Snapshot count               0
    Snapshot size                0
    Source snapshot              -
    Allowed Access Protocols     nfs4
    Availability Mode            zonal
    Bandwidth(Mbps)              1
    Storage Generation           1
    
  3. 在目標區域執行 ibmcloud is share-replica-create 指令,建立複製共用。 如果您的目標區域不正確,請使用 ibmcloud target -r REGION 指令切換目標區域。 使用 --source-share-id 選項,以 ID 或 CRN 指定來源共用。 提供值以定義要建立複製檔案共用的區域,以及複製共用的設定檔。 使用 --replication-cron-spec 選項,以 cron 表達式指定複製排程。 如果來源檔案共用有 user_managed 加密,您必須提供 --encryption-key-crn--encryption-key-crn 屬性不得另行指定。

    ibmcloud is share-replica-create --name my-replica-share --zone us-south-3 --profile dp2 --replication-cron-spec '10 05 * * *' --source-share my-file-share
    
    Creating replica file share my-replica-share under account Test Account as user test.user@ibm.com...
    ID                               r006-6d1719da-f790-45cc-9f68-896fd5673a1a
    Name                             my-replica-share
    CRN                              crn:v1:bluemix:public:is:us-south-3:a/a1234567::share:r006-6d1719da-f790-45cc-9f68-896fd5673a1a
    Lifecycle state                  pending
    Access control mode              security_group
    Accessor binding role            origin
    Allowed transit encryption modes ipsec,none
    Zone                             us-south-3
    Profile                          dp2
    Size(GB)                         1000
    IOPS                             100
    User Tags                        docs:test
    Encryption                       provider_managed
    Mount Targets                    ID                          Name
                                     No mounted targets found.
    Resource group                   ID                                 Name
                                     db8e8d865a83e0aae03f25a492c5b39e   Default
    Created                          2024-06-25T15:13:18+00:00
    Latest job                       Job status   Job status reasons
                                     running      -
    Replication cron spec            10 05 * * *
    Replication role                 replica
    Replication status               initializing
    Replication status reasons       Status code   Status message
                                     -             -
    Source share                     ID                                          Name            Resource type
                                     r006-b696742a-92ee-4f6a-bfd7-921d6ddf8fa6   my-file-share   share
    Snapshot count                   0
    Snapshot size                    0
    Source snapshot                  -
    Allowed Access Protocols         nfs4
    Availability Mode                zonal
    Bandwidth(Mbps)                  1
    Storage Generation               1
    

使用 API 將抄寫新增至檔案共用

您可以透過在 VPC API 中呼叫 /shares 方法,以程式化方式設定抄寫,如下列範例要求中所示。

開始之前,請先設定 API 環境。 如需檔案共用 VPC API 的相關資訊,請參閱 VPC API 參考資料

使用 API 建立與抄本的檔案共用

您可以同時建立一個區域性檔案共用,並在同一區域內建立其複本。 此方法僅適用於其副本仍位於同一區域內的區域性共享。 跨區域複本必須在另一個步驟中建立,因為在初始化複本時,來源共用資料夾必須處於穩定狀態。

建立檔案共用時,您可以指定也在不同區域中建立抄本檔案共用。 提出 POST /shares 要求,並指定 replica_share 內容以定義抄本檔案共用。

下列範例會建立來源共用 source-share-001 的抄本 test-replica-001。 當您建立檔案共用時,會針對抄本檔案共用及來源檔案共用指定裝載目標 (選用)。

curl -X POST\
"$vpc_api_endpoint/v1/shares?version=2023-08-08&generation=2"\
-H "Authorization: Bearer $iam_token"\
-d '{
    "name": "source-share-001",
    "profile":{"name":"dp2"},
    "size":100,
    "iops": 400,
    "mount-targets":[{"vpc":{"id":"08669c86-4c8a-4bfa-8ddc-37071f955c52"}],
    "zone":{"name":"us-south-1"},
    "replica_share":{
  	   "name": "test-replica-001",
      "profile":{"name":"dp2"},
      "replication_cron_spec":"0 */5 * * *",
      "zone":{"name":"us-south-3"},
      "mount_targets": [
        {"virtual_network_interface": {"subnet": {"id": "2302-ea5fe79f-52c3-4f05-86ae-9540a10489f5"}}},
        {"vpc": {"id": "7ec86020-1c6e-4889-b3f0-a15f2e50f87e"}}],
      "resource_group": {},
      "allowed_transit_encryption_modes": "ipsec",
      "user_tags": ["string"]}}]
      }
    "resource_group": {},
    "allowed_transit_encryption_modes": "ipsec",
    "user_tags": ["string"]
   }'

使用 API 建立現有檔案共用的抄本

若要為現有的檔案共用新增複寫功能,您需要在另一個區域中建立一個複寫共用。 在 POST /shares 要求中,指定抄本共用的名稱及設定檔,並以其名稱、ID 或 CRN 來指定 source_share。 其他必要內容為 zonereplication_cron_spec,其提供抄寫排程。 您可以安排最多 15 分鐘複製一次資料。

將抄寫新增至與 Terraform 共用的檔案

您可以使用 Terraform 中的 ibm_is_share 資源來建立與抄寫的檔案共用,或更新檔案共用以包括抄寫。

以下範例將在「us-south-3」區域中建立一個複本共用,並將其與 ID 為 ibm_is_share.example.id 的父共用關聯起來。

resource "ibm_is_share" "my-replica1" {
  zone                  = "us-south-3"
  source_share          = ibm_is_share.example.id
  name                  = "my-replica1"
  profile               = "dp2"
  replication_cron_spec = "0 */5 * * *"
}

下列範例會在 us-south-1 中建立檔案共用,並在 us-south-3 中建立抄本。

resource "ibm_is_share" "my-replica" {
  zone    = "us-south-1"
  size    = 220
  name    = "my-share"
  profile = "dp2"
  replica_share {
    name                  = "my-replica"
    replication_cron_spec = "0 */5 * * *"
    profile               = "dp2"
    zone                  = "us-south-3"
  }
}

下一步