Cloud Storage FUSE מאפשר לטעון קטגוריה של Cloud Storage כמערכת קבצים מקומית, כדי שתוכלו לנהל אינטראקציה עם האובייקטים שלכם באמצעות סמנטיקה של מערכת קבצים רגילה. במדריך למתחילים הזה תתקינו את Cloud Storage FUSE ב-Debian או ב-Ubuntu, תטענו קטגוריה כתיקייה במכונה ותעלו אובייקט לקטגוריה.
תשתמשו ב-Google Cloud CLI כדי ליצור ולנהל את האובייקט בקטגוריית האחסון שלכם, וב-Cloud Storage FUSE CLI כדי לטעון את הקטגוריה למכונה שלכם.
לפני שמתחילים
כדי להגדיר פרויקט, מבצעים את השלבים הבאים:
-
In the Cloud de Confiance console, on the project selector page, click Create project to begin creating a new Cloud de Confiance 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 Cloud de Confiance 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 Cloud de Confiance 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 Cloud de Confiance 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 identifier for a user in a workforce identity pool. For details, see Represent workforce pool users in IAM policies, or contact your administrator.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init - קטגוריה של Cloud Storage שרוצים לטעון. אם עדיין אין לכם קטגוריה, צרו קטגוריה חדשה.
התקנת Cloud Storage FUSE
כדי להתקין את Cloud Storage FUSE, פועלים לפי ההוראות במאמר התקנת Cloud Storage FUSE.
טעינת הקטגוריה
כדי לטעון את הקטגוריה למערכת הקבצים המקומית שלכם, מבצעים את הפעולות הבאות:
יוצרים Application Default Credentials באמצעות הפקודה
gcloud auth application-default login:gcloud auth application-default login
Cloud Storage FUSE טוען באופן אוטומטי את פרטי הכניסה.
יוצרים ספרייה שאליה צריך לטעון את קטגוריית האחסון:
mkdir "$HOME/mount-folder"
טוענים את קטגוריית האחסון באמצעות הפקודה
gcsfuse:gcsfuse BUCKET_NAME "$HOME/mount-folder"
מחליפים את BUCKET_NAME בשם הקטגוריה שרוצים לטעון.
אם הפקודה מסתיימת בלי שגיאות, היא תחזיר פלט שמכיל טקסט דומה לזה:
File system has been successfully mounted.
העלאת אובייקט לקטגוריה
כדי להוריד אובייקט לדוגמה ולהעלות אותו לקטגוריה שנטענה, מבצעים את הפעולות הבאות:

לוחצים לחיצה ימנית על התמונה ושומרים אותה במקום כלשהו במחשב, למשל בשולחן העבודה.
אפשר גם להוריד את התמונה באמצעות פקודת ה-cURL
curl -O https://cloud.google.com/storage/images/kitten.png.מעתיקים את התמונה מהמיקום שבו נשמרה לתיקייה שבה הקטגוריה נטענה, באמצעות הפקודה
cp:cp kitten.png "$HOME/mount-folder/kitten.png"
כך מוודאים שהתמונה הועתקה למערכת הקבצים המקומית והועלתה לקטגוריה ללא שגיאות:
כדי לבדוק שהקובץ
kitten.pngהועתק למערכת הקבצים המקומית, מריצים את הפקודהlsבתיקייה שבה הקטגוריה שלכם נטענה:ls "$HOME/mount-folder"
אם פעולת ההעתקה בוצעה ללא שגיאות, הפלט יחזיר
kitten.png.כדי להציג את תוכן הקטגוריה, משתמשים בפקודה
gcloud storage ls:gcloud storage ls gs://BUCKET_NAME
מחליפים את BUCKET_NAME בשם הקטגוריה שלכם.
אם התמונה הועלתה לקטגוריה ללא שגיאות, הפלט יחזיר
kitten.png.
הסרת המשאבים
כדי להימנע מצבירת חיובים בחשבון Cloud de Confiance by S3NS על המשאבים שבהם השתמשתם בדף הזה, מוחקים את המשאבים באמצעות הפעולות הבאות:
מנתקים את קטגוריית האחסון ממכונת Linux שלכם באמצעות הכלי
fusermount:fusermount -u "$HOME/mount-folder"
כדי למחוק את הקטגוריה ואת כל התוכן שבה, משתמשים בפקודה
gcloud storage rmעם הדגל--recursive:gcloud storage rm gs://BUCKET_NAME --recursive
מחליפים את BUCKET_NAME בשם הקטגוריה שלכם.
אם הפקודה מסתיימת בלי שגיאות, היא תחזיר פלט דומה לזה:
Removing gs://my-bucket/kitten.png#1676488739323620... Removing gs://my-bucket/...
המאמרים הבאים
איך משתמשים במיומנויות של סוכני Cloud Storage כדי להפוך את הטעינה והגדרת המטמון לאוטומטיות באמצעות עוזרי AI לעזרה בתכנות.