Membuat instance Filestore menggunakan gcloud CLI
Panduan memulai ini menunjukkan cara menyiapkan dan menjalankan Filestore dengan cepat menggunakan Google Cloud CLI. Dalam panduan memulai ini, Anda akan mempelajari cara:
- Buat instance Filestore.
- Pasang fitur berbagi file dari instance tersebut di VM klien Compute Engine.
- Buat file di berbagi file yang di-mount.
- Hapus instance Filestore.
Sebelum memulai
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
Install the Google Cloud CLI.
-
Jika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.
-
Untuk melakukan inisialisasi gcloud CLI, jalankan perintah berikut:
gcloud init -
Create or select 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.
-
Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace
PROJECT_IDwith a name for the Google Cloud project you are creating. -
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace
PROJECT_IDwith your Google Cloud project name.
-
Jika Anda menggunakan project yang sudah ada untuk panduan ini, pastikan Anda memiliki izin yang diperlukan untuk menyelesaikan panduan ini. Jika Anda membuat project baru, berarti Anda sudah memiliki izin yang diperlukan.
-
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 Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.gcloud services enable file.googleapis.com
-
Install the Google Cloud CLI.
-
Jika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.
-
Untuk melakukan inisialisasi gcloud CLI, jalankan perintah berikut:
gcloud init -
Create or select 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.
-
Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace
PROJECT_IDwith a name for the Google Cloud project you are creating. -
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace
PROJECT_IDwith your Google Cloud project name.
-
Jika Anda menggunakan project yang sudah ada untuk panduan ini, pastikan Anda memiliki izin yang diperlukan untuk menyelesaikan panduan ini. Jika Anda membuat project baru, berarti Anda sudah memiliki izin yang diperlukan.
-
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 Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.gcloud services enable file.googleapis.com
-
Membuat dan mengelola instance Filestore:
Cloud Filestore Editor (
roles/file.editor) -
Membuat dan mengelola instance Compute Engine:
Compute Instance Admin (v1) (
roles/compute.instanceAdmin.v1) -
Create a Compute Engine instance. Configure the instance as follows:
-
Name the instance
nfs-client. -
Tetapkan flag
--zonekeus-central1-c. -
Tetapkan flag
--image-projectkedebian-cloud. -
Tetapkan flag
--image-familykedebian-11. -
Tetapkan flag
--tagskehttp-server,.
gcloud compute instances create nfs-client --zone=us-central1-c --image-project=debian-cloud --image-family=debian-11 --tags=http-server,
-
Name the instance
-
Create a Compute Engine instance. Configure the instance as follows:
-
Name the instance
nfs-client. -
Tetapkan flag
--zonekeus-central1-c. -
Tetapkan flag
--image-projectkewindows-cloud. -
Tetapkan flag
--image-familykewindows-2012-r2. -
Tetapkan flag
--tagskehttp-server,http-server,.
gcloud compute instances create nfs-client --zone=us-central1-c --image-project=windows-cloud --image-family=windows-2012-r2 --tags=http-server,http-server,
-
Name the instance
Buat instance Filestore. Konfigurasikan instance sebagai berikut:
- Beri nama instance
nfs-server. - Tetapkan flag
--regionkeus-central1. - Tetapkan flag
--tierkeREGIONAL. Tetapkan flag
--performancekemax-iops-per-tb=17000.Tetapkan flag
--file-sharekename="vol1",capacity=1TB.Tetapkan flag
--networkkename="default".gcloud filestore instances create nfs-server --region=us-central1 --tier=REGIONAL --performance=max-iops-per-tb=17000 --file-share=name="vol1",capacity=1TB --network=name="default"
- Beri nama instance
Dapatkan informasi tentang instance Filestore yang Anda buat:
gcloud filestore instances describe nfs-server --region=us-central1
Perintah ini akan menampilkan sesuatu seperti:
createTime: '2025-02-12T09:15:08.163246004Z' customPerformanceSupported: true fileShares: -capacityGb: '1024' name: vol1 name: projects/yourproject/locations/us-central1/instances/nfs-server networks: -connectMode: DIRECT_PEERING ipAddresses: - 10.0.0.2 network: default reservedIpRange: 10.0.0.2/26 performanceConfig: iopsPerTb: maxIopsPerTb: '17000' performanceLimits: maxIops: '17000' maxReadIops: '17000' maxReadThroughputBps: '417792000' maxWriteIops: '5100' maxWriteThroughputBps: '139264000' protocol: NFS_V3 state: READY tier: REGIONAL
-
Establish an SSH connection to the
nfs-clientinstance:gcloud compute ssh nfs-client
Instal NFS dengan menjalankan perintah berikut di jendela terminal
nfs-client:sudo apt-get -y update && sudo apt-get -y install nfs-commonBuat direktori pemasangan di instance
nfs-clientuntuk berbagi file Filestore:sudo mkdir /mnt/testPasang fitur berbagi file ke instance
nfs-clientdengan perintahmountdengan menentukan alamat IP instance Filestore, nama fitur berbagi file, dan direktori pemasangan yang akan dipasang:sudo mount MOUNT-POINT-DIRECTORY /mnt/testdengan:
MOUNT-POINT-DIRECTORY adalah jalur ke direktori tempat berbagi file Filestore dipasang. Contoh:
10.0.0.2:/vol1Opsional: Konfirmasi bahwa berbagi file Filestore telah di-mount:
df -h --type=nfs
Buat berbagi file dapat diakses dengan mengubah izinnya:
sudo chmod go+rw /mnt/testBuat akun dan tetapkan sandi awal untuk instance
nfs-client:gcloud compute reset-windows-password nfs-clientKonfigurasi instance Anda untuk mengaktifkan koneksi ke port serial:
gcloud compute instances add-metadata nfs-client --metadata=serial-port-enable=1Masukkan sesi interaktif:
gcloud compute connect-to-serial-port nfs-client --port=2Pada prompt
SAC>, buat channel baru:cmdChannel dengan nama
Cmd0001dibuat.Hubungkan ke channel:
ch -sn Cmd0001Masukkan nama pengguna dan sandi instance
nfs-client, lalu kosongkan kolomDomain. Anda terhubung ke antarmukaCommand Promptdari instancenfs-client.Di
Command Promptnfs-client, beralihlah keWindows PowerShell:powershellInstal klien
NFS:Install-WindowsFeature -Name NFS-ClientMulai ulang instance
nfs-clientsaat diminta:restart-computerPada perintah
SAC>, tunggu hingga notifikasi berikut muncul:EVENT: The CMD command is now available.
Kemudian, jalankan perintah
cmddanch -snseperti yang diinstruksikan sebelumnya untuk login dan menghubungkan kembali ke instancenfs-client.- Di Command Prompt, jalankan
powershelluntuk beralih ke Windows PowerShell. Di
PowerShell, jalankan perintah berikut untuk membuat dua entri registri baru,AnonymousUiddanAnonymousGid:New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" ` -Name "AnonymousUid" -Value "0" -PropertyType DWORD New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" ` -Name "AnonymousGid" -Value "0" -PropertyType DWORDMulai ulang layanan klien NFS:
nfsadmin client stop nfsadmin client startKeluar dari
PowerShell:exitDari
Command Prompt, pasang fitur berbagi file ke instancenfs-clientdengan perintahmountdengan menentukan alamat IP instance Filestore, nama fitur berbagi file, dan huruf drive yang akan dipasang:mount -o mtype=hard 10.0.0.2:/vol1 z:Di jendela terminal
nfs-client, buat file bernamatestfiledengan menjalankan perintah berikut:echo 'This is a test' > /mnt/test/testfilePastikan file telah dibuat dengan menjalankan perintah berikut dan memverifikasi bahwa
testfileada dalam konten direktori yang ditampilkan:ls /mnt/testDi jendela Command Prompt instance
nfs-client, buat file bernamatestfile:echo 'This is a test' > Z:\testfileKonfirmasi bahwa file telah dibuat dengan menjalankan perintah berikut:
dir Z:dan memverifikasi bahwa
testfileada dalam konten direktori yang ditampilkan.- Baca Ringkasan Filestore untuk mempelajari lebih lanjut dasar-dasar Filestore.
- Siapkan instance Filestore sendiri dengan mengikuti petunjuk di Membuat Instance.
- Baca Kontrol Akses untuk mempelajari cara mengontrol akses ke operasi Filestore dan resource pada instance.
- Lihat cara menyalin data ke atau dari instance Filestore.
- Lihat cara mentransfer set data besar dari Cloud Storage ke Filestore.
Peran yang diperlukan
Untuk mendapatkan izin yang Anda perlukan untuk menyelesaikan panduan memulai cepat ini, minta administrator Anda untuk memberi Anda peran IAM berikut di project Anda:
Untuk mengetahui informasi selengkapnya tentang pemberian peran, lihat Mengelola akses ke project, folder, dan organisasi.
Anda mungkin juga bisa mendapatkan izin yang diperlukan melalui peran khusus atau peran bawaan lainnya.
Setelah menyelesaikan tugas yang dijelaskan dalam dokumen ini, Anda dapat menghindari penagihan berkelanjutan dengan menghapus resource yang Anda buat. Untuk mengetahui informasi selengkapnya, lihat Pembersihan.
Membuat VM Compute Engine
Linux
Windows
Membuat instance Filestore
Panduan memulai ini menunjukkan cara membuat instance di tingkat layanan regional dengan performa kustom yang diaktifkan. Untuk mengetahui detail tentang cara membuat instance, lihat membuat instance.
Salin alamat IP instance untuk digunakan saat memasang
fitur berbagi file. Untuk panduan memulai ini, kita menggunakan alamat IP 10.0.0.2.
Pasang berbagi file Filestore di instance nfs-client
Linux
Windows
Login ke instance nfs-client dan buka Command Prompt sebagai administrator
Menginstal klien NFS
Mengonfigurasi ID pengguna yang digunakan oleh klien NFS
Petakan berbagi file vol1 ke instance nfs-client
Membuat file di berbagi file yang di-mount
Linux
Windows
Pembersihan
Agar akun Google Cloud Anda tidak dikenai biaya untuk resource yang digunakan pada halaman ini, hapus project Google Cloud yang berisi resource tersebut.
Menghapus Google Cloud project
Delete a Google Cloud project:
gcloud projects delete PROJECT_ID
Hapus instance Filestore
Hapus instance nfs-server:
gcloud filestore instances delete nfs-server --zone=us-central1-c
Menghapus instance Compute Engine
Hapus instance:gcloud compute instances delete nfs-client