Google Cloud Managed Lustre 可從 Cloud Storage 匯入資料,也能將資料匯出至 Cloud Storage。資料轉移作業是增量作業,只會複製目的地中沒有的檔案,或是自轉移後有所變更的檔案。
與標準 bucket 相比,啟用階層命名空間的 Cloud Storage bucket 可提供更快的傳輸速度,方便您在 Managed Lustre 與 bucket 之間傳輸資料。
限制
每個執行個體一次只能啟用一項轉移作業。如果先前轉移作業仍在執行,您嘗試啟動第二項轉移作業時,會收到類似下列的錯誤訊息:
ERROR: (gcloud.lustre.instances.export-data) ABORTED: unable to queue the operation
Cloud Storage 輸出頻寬注意事項
Cloud Storage 預設的輸出頻寬為每個專案在每個區域最多 200 Gbps。如果工作負載需要更高的資料傳輸速度,可以申請提高輸出頻寬上限。詳情請參閱「Cloud Storage 頻寬配額」。
所需權限
啟動轉移作業的權限
用來啟動轉移作業的使用者或服務帳戶必須具備下列權限:
lustre.instances.exportData,以便從 Managed Lustre 轉移至 Cloud Storage。lustre.instances.importData,即可從 Cloud Storage 轉移資料。
這兩項權限都是透過 roles/lustre.admin 角色授予。您可以建立自訂角色,獨立授予權限。
Managed Lustre 服務代理的權限
取得 Managed Lustre 服務代理
首次在專案中建立 Managed Lustre 執行個體時,系統會建立 Managed Lustre 服務代理程式。服務代理程式身分 ID 的格式為 service-PROJECT_NUMBER@gcp-sa-lustre.iam.gserviceaccount.com。
如果您還沒有 Managed Lustre 服務代理程式
請執行
services identity create指令。gcloud beta services identity create \ --service=lustre.googleapis.com \ --project=PROJECT_NUMBER_OR_ID將 PROJECT_NUMBER_OR_ID 替換為您要在其中建立 Managed Lustre 執行個體的專案編號或 ID。輸出結果會與下列內容相似:
Service identity created: service-1234567890@gcp-sa-lustre.iam.gserviceaccount.com複製服務代理程式身分的值,以便在下一個步驟中使用。
如果您已建立 Managed Lustre 執行個體
如要建構服務代理程式身分,請取得專案編號。PROJECT_NUMBER與專案 ID不同:
- 專案 ID 是由字母、數字和連字號組成的唯一字串。建立專案時,您會指定專案 ID。例如:
example-project-123。 - 專案編號是系統自動產生的專案專屬 ID,僅由數字組成。例如:
1234567890。
如要取得特定專案 ID 的 PROJECT_NUMBER,請使用
gcloud projects describe指令:gcloud projects describe PROJECT_ID --format="value(projectNumber)"- 專案 ID 是由字母、數字和連字號組成的唯一字串。建立專案時,您會指定專案 ID。例如:
將傳回的專案編號複製到服務代理人身分:
service-PROJECT_NUMBER@gcp-sa-lustre.iam.gserviceaccount.com複製服務代理程式身分,以便在下一個步驟中使用。
授予權限
Managed Lustre 服務代理需要下列其中一個 Cloud Storage 角色:
- 如要將資料傳輸至 Cloud Storage 或從 Cloud Storage 傳輸資料,請在 Cloud Storage 值區上啟用
roles/storage.objectUser。 - 如要只從 Cloud Storage 轉移資料,請點選 Cloud Storage bucket 上的
roles/storage.objectViewer。
如要授予其中一個角色,請執行下列 gcloud 指令:
gcloud storage buckets add-iam-policy-binding gs://BUCKET_NAME \
--member=serviceAccount:SERVICE_AGENT_IDENTITY \
--role=roles/storage.objectViewer_OR_objectUser
SERVICE_AGENT_IDENTITY 是上一個步驟中的 Managed Lustre 服務代理程式身分。
將資料匯入 Managed Lustre
您可以從 Cloud Storage 值區匯入資料。bucket 可以位於相同或不同專案。值區可以與 Managed Lustre 執行個體位於不同的地帶或區域,但跨區域傳輸
的速度可能會比區域內傳輸慢。
gcloud
gcloud lustre instances import-data INSTANCE_ID \
--location=LOCATION \
--gcs-path-uri=gs://BUCKET_NAME/ \
--lustre-path=PS_PATH
其中:
- INSTANCE_ID 是 Managed Lustre 執行個體名稱。
--location是 Managed Lustre 執行個體的區域。例如:us-central1-a。--gcs-path-uri會使用gs://<bucket_name>/<optional_path_inside_bucket>/格式,指定 Cloud Storage 值區的 URI,或值區中的路徑。如果指定 bucket 內的路徑,結尾必須為正斜線 (/)。--lustre-path會指定 Managed Lustre 檔案系統的根目錄路徑。開頭必須為/。預設值為/。如要指定預設值以外的值,檔案系統中必須已存在該目錄。
以下為選用參數:
--request-id可讓您為這項要求指派專屬 ID。如果使用相同要求 ID 重試這項要求,伺服器會忽略已完成的要求。必須是有效的 UUID,且不得全為零。--async會立即傳回回應,不會等待作業完成。
詳情請參閱 Cloud SDK 說明文件。
REST
POST https://lustre.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID:importData
Authorization: Bearer [YOUR_ACCESS_TOKEN]
{
"gcsPath" : {
"uri" : "gs://BUCKET_NAME/"
},
"lustrePath" : {
"path" : "/PATH"
}
}
其中:
- PROJECT_ID 是您的 Google Cloud 專案名稱。
- LOCATION 是 Managed Lustre 執行個體的區域。例如:
us-central1-a。 - INSTANCE_ID 是 Managed Lustre 執行個體名稱。
gcsPath包含uri鍵,其值會指定 Cloud Storage bucket 的 URI,或 bucket 內的路徑,格式為gs://<bucket_name>/<optional_path_inside_bucket>/。如果指定 bucket 內的路徑,結尾必須為正斜線 (/)。- 包含
path鍵,其值會指定受管理 Lustre 檔案系統的根目錄路徑。lustrePath必須以/開頭。預設值為/。如要指定預設值以外的值,檔案系統中必須已存在該目錄。
如要使用自己的服務帳戶,而非 Google 管理的服務代理程式,要求支援 JSON 物件中的 serviceAccount 欄位:
"serviceAccount" : "projects/PROJECT_ID/serviceAccounts/SERVICE_ACCOUNT_ID"
curl 指令範例如下:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://lustre.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID:importData \
-d '{"gcsPath": {"uri":"gs://BUCKET_NAME/"}, "lustrePath": {"path":"/"}}'
檔案屬性
從 Cloud Storage bucket 將資料匯入 Managed Lustre 執行個體時,Managed Lustre 執行個體中的檔案屬性會透過下列其中一種方式設定:
- 如果 Cloud Storage 物件具有自訂中繼資料 (如匯出資料所述),則:
- 檔案的 UID、GID、模式和
mtime是根據物件的自訂中繼資料設定。 - 檔案的
atime會設為與mtime相同的值。
- 檔案的 UID、GID、模式和
- 如果 Cloud Storage 物件沒有自訂中繼資料,則:
- 檔案的 UID 和 GID 會設為 0 (
root)。 - 檔案模式設為
rwxr-xr-x(755)。 - 檔案的
atime和mtime會設為 Cloud Storage 物件的建立時間。
- 檔案的 UID 和 GID 會設為 0 (
無論是哪種情況:
- 檔案的
ctime會設為檔案寫入執行個體的時間。 - 目錄的
atime、ctime和mtime會設為在執行個體上建立目錄的時間。
匯出資料
您可以將資料從 Managed Lustre 執行個體匯出至相同或不同專案中的 Cloud Storage 值區。值區可以與 Managed Lustre 執行個體位於不同的可用區或區域,但跨區域傳輸速度可能會比區域內傳輸慢。
gcloud
gcloud lustre instances export-data \
INSTANCE_ID \
--location=LOCATION \
--gcs-path-uri="gs://BUCKET_NAME/" \
--lustre-path="/"
其中:
- INSTANCE_ID 是 Managed Lustre 執行個體名稱。
--location是 Managed Lustre 執行個體的區域。例如:us-central1-a。--gcs-path-uri會使用gs://<bucket_name>/<optional_path_inside_bucket>/格式,指定 Cloud Storage 值區的 URI,或值區中的路徑。如果指定 bucket 內的路徑,結尾必須為正斜線 (/)。--lustre-path會指定 Managed Lustre 檔案系統的根目錄路徑。開頭必須為/。預設值為/。
以下為選用參數:
--request-id可讓您為這項要求指派專屬 ID。如果使用相同要求 ID 重試這項要求,伺服器會忽略已完成的要求。必須是有效的 UUID,且不得全為零。--async會立即傳回回應,不會等待作業完成。
REST
POST https://lustre.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID:exportData
Authorization: Bearer [YOUR_ACCESS_TOKEN]
{
"lustrePath" : {
"path" : "/"
},
"gcsPath" : {
"uri" : "gs://BUCKET_NAME/"
}
}
其中:
- PROJECT_ID 是您的 Google Cloud 專案名稱。
- INSTANCE_ID 是 Managed Lustre 執行個體名稱。
- LOCATION 是 Managed Lustre 執行個體的區域。例如:
us-central1-a。 - 包含
path鍵,其值會指定受管理 Lustre 檔案系統的根目錄路徑。lustrePath開頭必須為/。 預設值為/。 gcsPath包含uri鍵,其值會指定 Cloud Storage bucket 的 URI,或 bucket 內的路徑,格式為gs://<bucket_name>/<optional_path_inside_bucket>/。如果指定 bucket 內的路徑,結尾必須為正斜線 (/)。
如要使用自己的服務帳戶,而非 Google 管理的服務代理程式,要求支援 JSON 物件中的 serviceAccount 欄位:
"serviceAccount" : "projects/PROJECT_ID/serviceAccounts/SERVICE_ACCOUNT_ID"
curl 指令範例如下:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json"
https://lustre.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID:exportData \
-d '{"lustrePath": {"path":"/"}, "gcsPath": {"uri":"gs://BUCKET_NAME/"}}'
檔案屬性
將資料從 Managed Lustre 執行個體匯出至 Cloud Storage bucket 時,下列檔案屬性會保留為 Cloud Storage 中的自訂中繼資料:
- 檔案的 UID 會以
goog-reserved-posix-uid鍵儲存。 - 檔案的 GID 會與
goog-reserved-posix-gid金鑰一併儲存。 - 檔案的數字模式會以
goog-reserved-posix-mode鍵儲存。 - 檔案的
mtime會以goog-reserved-file-mtime金鑰儲存。
這些自訂中繼資料鍵名與 Storage Transfer Service 用於 POSIX 檔案系統移轉的鍵名相同。
系統不會保留下列檔案屬性:
- 系統不會保留符號連結。
- 系統會將硬連結匯出為個別的 Cloud Storage 物件,因此會產生多個副本。
- 使用
lfs setstripe或lfs setdirstripe明確設定的 Lustre 條紋不會保留。 - 系統不會保留檔案的
atime和ctime。 - 系統不會保留目錄
mtime。 - 系統不會保留空白目錄。
取得作業
如要查看匯入或匯出作業的狀態,您需要作業 ID。當您提出匯入或匯出要求時,服務會傳回這個 ID,格式如下:
operation-1234567890123-6127783ad26ea-88913969-02748053
gcloud
gcloud lustre operations describe OPERATION_ID \
--location=LOCATION
REST
GET https://lustre.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID
Authorization: Bearer [YOUR_ACCESS_TOKEN]
curl 指令範例如下:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://lustre.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID
取消作業
如要取消匯入或匯出作業,您需要作業 ID。當您提出匯入或匯出要求時,服務會傳回這個 ID,格式如下:
operation-1234567890123-6127783ad26ea-88913969-02748053
gcloud
gcloud lustre operations cancel OPERATION_ID \
--location=LOCATION
REST
POST https://lustre.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID:cancel
Authorization: Bearer [YOUR_ACCESS_TOKEN]
curl 指令範例如下:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://lustre.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/operations/OPERATION_ID:cancel