Pelajari cara memasang bucket Cloud Storage sebagai sistem file lokal menggunakan Cloud Storage FUSE, sehingga Anda dapat berinteraksi dengan objek menggunakan semantik sistem file standar.
Dalam panduan memulai ini, Anda akan menyelesaikan tugas berikut:
Menginstal Cloud Storage FUSE di Debian atau Ubuntu
Memasang bucket sebagai folder di mesin
Mengupload objek ke bucket
Anda harus menggunakan Google Cloud CLI untuk membuat dan mengelola objek di bucket penyimpanan, dan menggunakan Cloud Storage FUSE CLI untuk memasang bucket ke mesin Anda.
Sebelum memulai
Untuk menyiapkan project, selesaikan langkah-langkah berikut:
- Login ke akun Google Cloud Anda. Jika Anda baru menggunakan Google Cloud, buat akun untuk mengevaluasi performa produk kami dalam skenario dunia nyata. Pelanggan baru juga mendapatkan kredit gratis senilai $300 untuk menjalankan, menguji, dan men-deploy workload.
-
In the Google Cloud console, on the project selector page, click Create project to begin creating a new Google Cloud project.
Roles required to 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. -
Verify that billing is enabled for your Google Cloud project.
-
Make sure that you have the following role or roles on the project: Storage Admin (
roles/storage.admin), Storage Bucket Viewer (roles/storage.bucketViewer)Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
Instal 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 -
In the Google Cloud console, on the project selector page, click Create project to begin creating a new Google Cloud project.
Roles required to 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. -
Verify that billing is enabled for your Google Cloud project.
-
Make sure that you have the following role or roles on the project: Storage Admin (
roles/storage.admin), Storage Bucket Viewer (roles/storage.bucketViewer)Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
Instal 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 - Memiliki bucket Cloud Storage yang ingin Anda pasang. Jika Anda belum memilikinya, buat bucket baru.
Menginstal Cloud Storage FUSE
Untuk menginstal Cloud Storage FUSE, ikuti petunjuk di Menginstal Cloud Storage FUSE.
Memasang bucket
Untuk memasang bucket ke sistem file lokal, selesaikan langkah-langkah berikut:
Buat Kredensial Default Aplikasi menggunakan perintah
gcloud auth application-default login:gcloud auth application-default login
Cloud Storage FUSE memuat kredensial secara otomatis.
Buat direktori untuk memasang bucket penyimpanan ke:
mkdir "$HOME/mount-folder"
Pasang bucket penyimpanan Anda menggunakan perintah
gcsfuse:gcsfuse BUCKET_NAME "$HOME/mount-folder"
Ganti BUCKET_NAME dengan nama bucket yang ingin Anda pasang.
Jika berhasil, perintah akan menampilkan output yang berisi teks yang mirip dengan berikut ini:
File system has been successfully mounted.
Mengupload objek ke dalam bucket
Untuk mendownload objek contoh dan menguploadnya ke bucket yang terpasang, selesaikan langkah-langkah berikut:

Klik kanan gambar dan simpan di mana saja di komputer Anda, misalnya di desktop.
Anda juga dapat mendownload gambar menggunakan perintah cURL
curl -O https://cloud.google.com/storage/images/kitten.png.Salin gambar dari lokasi tersimpannya ke folder tempat bucket Anda dipasang, menggunakan perintah
cp:cp kitten.png "$HOME/mount-folder/kitten.png"
Pastikan gambar telah disalin ke sistem file lokal dan berhasil diupload ke bucket dengan mengikuti langkah-langkah berikut:
Untuk memeriksa apakah
kitten.pngtelah disalin ke sistem file lokal, jalankanlsdi folder tempat bucket Anda dipasang:ls "$HOME/mount-folder"
Jika operasi penyalinan berhasil,
kitten.pngakan ditampilkan dalam output.Untuk menampilkan daftar isi bucket, gunakan perintah
gcloud storage ls:gcloud storage ls gs://BUCKET_NAME
Ganti BUCKET_NAME dengan nama bucket Anda.
Jika gambar berhasil diupload ke bucket Anda,
kitten.pngakan ditampilkan dalam output.
Pembersihan
Agar akun Google Cloud Anda tidak dikenai biaya untuk resource yang digunakan di halaman ini, hapus resource dengan menyelesaikan langkah-langkah berikut:
Lepaskan bucket penyimpanan dari mesin Linux menggunakan alat
fusermount:fusermount -u "$HOME/mount-folder"
Untuk menghapus bucket dan semua yang ada di dalamnya, gunakan perintah
gcloud storage rmdengan flag--recursive:gcloud storage rm gs://BUCKET_NAME --recursive
Ganti BUCKET_NAME dengan nama bucket Anda.
Jika berhasil, perintah akan menampilkan output yang mirip dengan berikut ini:
Removing gs://my-bucket/kitten.png#1676488739323620... Removing gs://my-bucket/...
Langkah berikutnya
- Pelajari cara Vertex AI menggunakan Cloud Storage FUSE untuk memasang bucket Cloud Storage untuk tugas pelatihan kustom.