简体   繁体   English

无法使用 Fuse 在 GCP buket 中写入文件

[英]Unable to write files in a GCP buket using Fuse

I have mounted a storage bucket on a VM using the command:我使用以下命令在 VM 上安装了一个存储桶:

gcsfuse my-bucket /path/to/mount

After this I'm able to read files from the bucket in Python using Pandas, but I'm not able to write files nor create new folders.在此之后,我可以使用 Pandas 从 Python 中的存储桶中读取文件,但我无法写入文件也无法创建新文件夹。 I have tried with Python and from the terminal using sudo but get the same error.我曾尝试使用 Python 并从终端使用 sudo 但得到相同的错误。

I have also tried Using the key_file from the bucket:我也尝试过使用存储桶中的 key_file:

sudo mount -t gcsfuse -o implicit_dirs,allow_other,uid=1000,gid=1000,key_file=Notebooks/xxxxxxxxxxxxxx10b3464a1aa9.json <BUCKET> <PATH>

It does not through errors when I run the code, but still I'm not able to write in the bucket.当我运行代码时它不会出现错误,但我仍然无法在桶中写入。

I have also tried :我也试过

gcloud auth login

But still have the same issue.但仍然有同样的问题。

I ran into the same thing a while ago, which was really confusing.不久前我遇到了同样的事情,这真的很混乱。 You have to set the correct access scope for the virtual machine so that anyone using the VM is able to call the storage API.您必须为虚拟机设置正确的访问 scope,以便任何使用 VM 的人都能够调用存储 API。 The documentation shows that the default access scope for storage on a VM is read-only: 文档显示 VM 上存储的默认访问 scope 是只读的:

When you create a new Compute Engine instance, it is automatically configured with the following access scopes:当您创建新的 Compute Engine 实例时,它会自动配置以下访问范围:

  • Read-only access to Cloud Storage: https://www.googleapis.com/auth/devstorage.read_only云存储的只读访问权限:https://www.googleapis.com/auth/devstorage.read_only

All you have to do is change this scope so that you are also able to write to storage buckets from the VM.您所要做的就是更改此 scope,以便您还能够从 VM 写入存储桶。 You can find an overview of different scopes here .您可以在此处找到不同范围的概述。 To apply the new scope to your VM, you have to first shut it down.要将新的 scope 应用到您的 VM,您必须先将其关闭。 Then from your local machine execute the following command:然后从您的本地机器执行以下命令:

gcloud compute instances set-scopes INSTANCE_NAME \
  --scopes=storage-rw \
  --zone=ZONE

You can do the same thing from the portal if you go to the settings of your VM, scroll all the way down, and choose "Set Access for each API".如果您将 go 设置为 VM 的设置,则可以从门户执行相同的操作,一直向下滚动,然后选择“为每个 API 设置访问权限”。 You have the same options when you create the VM for the first time.首次创建 VM 时,您有相同的选项。 Below is an example of how you would do this:以下是您将如何执行此操作的示例:

计算引擎访问范围

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM