使用 Google Cloud 控制台建立 Filestore 執行個體
本快速入門導覽課程說明如何使用 Google Cloud 控制台,在 Filestore 中執行基本作業。在快速入門導覽課程中,您將可以:
- 建立 Filestore 執行個體。
- 在 Compute Engine 用戶端 VM 執行個體上,掛接該執行個體的檔案共用區。
- 在已掛接的檔案共用區中建立檔案。
- 刪除 Filestore 執行個體。
事前準備
- 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自評估產品在實際工作環境中的成效。新客戶還能獲得價值 $300 美元的免費抵免額,可用於執行、測試及部署工作負載。
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Filestore API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Filestore API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.
必要的角色
如要取得完成本快速入門導覽課程所需的權限,請要求管理員在專案中授予您下列 IAM 角色:
-
建立及管理 Filestore 執行個體:
Cloud Filestore 編輯者 (
roles/file.editor) -
建立及管理 Compute Engine 執行個體:Compute 執行個體管理員 (v1) (
roles/compute.instanceAdmin.v1) -
建立、修改及刪除網路資源,但不包括防火牆規則:Compute 網路管理員 (
roles/compute.networkAdmin) -
對 IAM 服務帳戶執行作業:
服務帳戶使用者 (
roles/iam.serviceAccountUser) -
管理網路和相關資源:
網路管理員 (
roles/iam.networkAdmin) Google Cloud
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。
完成本文所述工作後,您可以刪除建立的資源,避免繼續計費,詳情請參閱「清除所用資源」一節。
建立 Compute Engine VM 執行個體做為用戶端
前往 Google Cloud 控制台的「VM Instances」(VM 執行個體) 頁面。
按一下「建立執行個體」,然後按照下列方式設定執行個體。
- 將「Name」(名稱) 設定為
nfs-client。 - 將「Zone」(區域) 設為 [us-central1-c]。
- 保留預設開機磁碟。
- 在「Networking」(網路) >「Firewall」(防火牆) 區段中,選取「Allow HTTP traffic」(允許 HTTP 流量) 核取方塊。
- 將網路保留為 default。
- 將「Name」(名稱) 設定為
按一下「建立」,建立執行個體。
建立 Filestore 執行個體
本快速入門導覽課程說明如何在「區域」層級中建立執行個體,並啟用自訂效能。如要瞭解如何建立執行個體,請參閱建立執行個體。
前往 Google Cloud 控制台的 Filestore「Instances」(執行個體) 頁面。
按一下「建立執行個體」,然後按照下列方式設定執行個體:
- 將「Instance ID」(執行個體 ID) 設為
nfs-server。 - 將「執行個體類型」設為「區域」。
- 在「容量」中輸入
1 TiB。 在「效能」中,按一下「自訂效能」切換按鈕,即可啟用自訂效能。根據預設,您會在「效能」欄位中看到 12,000 IOPS。「隨著容量調整效能」核取方塊已勾選,因此如果變更「容量」欄位中的值,效能也會隨之調整。如要瞭解設定選項的詳細資訊,請參閱「設定效能」。
將「Region」(地區) 設為 us-central1。
將「VPC network」(虛擬私有雲網路) 設為「default」(預設)。
將「File share name」(檔案共用區名稱) 設為
vol1。將「已分配的 IP 範圍」設為「使用系統自動分配的 IP 範圍」。
將「Access controls」設為「Grant access to all clients」。
- 將「Instance ID」(執行個體 ID) 設為
點選「建立」。
在用戶端上掛接 Filestore 檔案共用區
前往 Google Cloud 控制台的「VM Instances」(VM 執行個體) 頁面。
在 VM 執行個體清單中,按一下nfs-client 的 [SSH] 按鈕,開啟連線至該執行個體的終端機視窗。
執行下列指令,安裝 NFS:
sudo apt-get -y update && sudo apt-get -y install nfs-common執行下列指令,為 Filestore 檔案共用區建立掛接目錄:
sudo mkdir -p /mnt/test執行
mount指令並指定 Filestore 執行個體 IP 位址與檔案共用區名稱,掛接檔案共用區:sudo mount MOUNT-POINT-DIRECTORY /mnt/test其中:
MOUNT-POINT-DIRECTORY 是掛接 Filestore 檔案共用區的所在目錄路徑。例如:
10.0.0.2:/vol1選用:確認已掛接 Filestore 檔案共用區:
df -h --type=nfs變更設定,開放檔案共用區的存取權限:
sudo chmod go+rw /mnt/test
在檔案共用區中建立檔案
在連線至 nfs-client 執行個體的終端機視窗中,執行下列指令以建立名為
testfile的檔案:echo 'This is a test' > /mnt/test/testfile執行下列指令,確認檔案已建立:
ls /mnt/test並確認
testfile是否已列出。
清除所用資源
為了避免系統向您的 Google Cloud 帳戶收取本頁面所用資源的費用,請按照下列步驟操作。
刪除 Google Cloud 專案
- 前往 Google Cloud 控制台的「Manage resources」(管理資源) 頁面。
- 在專案清單中選取要刪除的專案,然後點選「Delete」(刪除)。
- 在對話方塊中輸入專案 ID,然後按一下 [Shut down] (關閉) 以刪除專案。
刪除 Filestore 執行個體
前往 Google Cloud 控制台的 Filestore 執行個體頁面。
按一下
nfs-server執行個體 ID,開啟執行個體詳細資料頁面。按一下「刪除」圖示 delete。
收到系統提示時,輸入執行個體 ID。
點選「刪除」。
刪除 Compute Engine 執行個體
前往 Google Cloud 控制台的 Filestore 執行個體頁面。
選取
nfs-client執行個體名稱旁的核取方塊。按一下「刪除」圖示 delete。
系統顯示提示時,再按一下「刪除」。
後續步驟
- 請參閱 Filestore 總覽,進一步瞭解 Filestore 的基本概念。
- 按照「建立執行個體」一文中的操作說明,自行設定 Filestore 執行個體。
- 請參閱「存取權控管」頁面,瞭解如何控管對 Filestore 作業和執行個體資源的存取權。
- 瞭解如何將資料複製到 Filestore 執行個體,或是複製 Filestore 執行個體中的資料。
- 瞭解如何將大型資料集從 Cloud Storage 移轉至 Filestore。