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:
- 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.
-
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 (
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. 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.
Buka IAM - Pilih project.
- Klik Grant access.
-
Di kolom New principals, masukkan ID pengguna Anda. Biasanya berupa alamat email untuk Akun Google.
- Di daftar Select a role, pilih peran.
- Untuk memberikan peran tambahan, klik Tambahkan peran lain, lalu tambahkan setiap peran tambahan.
- Klik Simpan.
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
-
-
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 (
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. 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.
Buka IAM - Pilih project.
- Klik Grant access.
-
Di kolom New principals, masukkan ID pengguna Anda. Biasanya berupa alamat email untuk Akun Google.
- Di daftar Select a role, pilih peran.
- Untuk memberikan peran tambahan, klik Tambahkan peran lain, lalu tambahkan setiap peran tambahan.
- Klik Simpan.
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
-
- Memiliki bucket Cloud Storage yang ingin Anda pasang. Jika Anda belum memilikinya, buat bucket baru.
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.
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.png
telah disalin ke sistem file lokal, jalankanls
di folder tempat bucket Anda dipasang:ls "$HOME/mount-folder"
Jika operasi penyalinan berhasil,
kitten.png
akan 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.png
akan ditampilkan dalam output.
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 rm
dengan 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/...
- Pelajari cara Vertex AI menggunakan Cloud Storage FUSE untuk memasang bucket Cloud Storage untuk tugas pelatihan kustom.
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:
Mengupload objek ke dalam bucket
Untuk mendownload objek contoh dan menguploadnya ke bucket yang terpasang, selesaikan langkah-langkah berikut:
Pembersihan
Agar tidak menimbulkan biaya pada akun Google Cloud Anda untuk resource yang digunakan di halaman ini, hapus resource dengan menyelesaikan langkah-langkah berikut: