如何在具有完全访问权限的Linux实例上将Google Bucket挂载为本地磁盘 [英] How to mount Google Bucket as local disk on Linux instance with full access rights

查看:108
本文介绍了如何在具有完全访问权限的Linux实例上将Google Bucket挂载为本地磁盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的五行代码中,在全新的Ubuntu14实例上安装gcsfuse:

Using five lines below install gcsfuse on a brand new Ubuntu14 instance:

export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`
echo "deb http://packages.cloud.google.com/apt $GCSFUSE_REPO main" | sudo tee /etc/apt/sources.list.d/gcsfuse.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

sudo apt-get update
sudo apt-get install gcsfuse

现在在本地磁盘上创建一个文件夹(此文件夹将用作Google Bucket的安装点).授予该文件夹完全访问权限:

Now create a folder on a local disk (this folder is to be used as the mounting point for Google Bucket). Give this folder a full access:

sudo mkdir /home/shared 
sudo chmod 777 /home/shared 

使用gcsfuse命令将Google存储桶安装到我们之前创建的安装点文件夹中.但首先,请列出链接到您的Google Project的Google Bucket的名称:

Using gcsfuse command mount Google bucket to the mounting-point folder we created earlier. But first, list the names of the Google Buckets that are linked to your Google Project:

gsutil ls

我正在研究的Google Project有一个名为"my_bucket"的存储桶.知道存储桶的名称后,我可以运行gcsfuse命令,将my_bucket存储桶安装到本地/home/shared安装文件夹:

The Google Project I work on has a single bucket named "my_bucket". Knowing a bucket name I can run gcsfuse command that will mount my_bucket Bucket on to a local /home/shared mounting-folder:

gcsfuse my_bucket /home/shared 

此命令的执行记录它已成功:

The execution of this command logs that it was successful:

Using mount point: /home/shared
Opening GCS connection...
Opening bucket...
Mounting file system...
File system has been successfully mounted.

但是现在当我尝试在映射的/home/shared安装点文件夹中创建另一个文件夹时,出现错误消息:

But now when I try to create another folder inside of mapped /home/shared mounting-point folder I get the error message:

mkdir /home/shared/test

错误:

mkdir: cannot create directory ‘/home/shared/test’: Input/output error

尝试解决该问题,我成功使用以下方法un-mount:

Trying to fix the problem I successfully un-mount it using:

fusermount -u /home/shared

并将其映射回去,但现在使用另一个gcsfuse命令行:

and map it back but now using another gcsfuse command-line:

mount -t gcsfuse -o rw,user  my_bucket /home/shared

但这会导致完全相同的权限问题.

But it results to the exactly same permission issue.

最后,我尝试通过使用以下命令编辑/etc/fstab配置文件来解决此权限问题:

At very last I have made an attempt to fix this permission issue by editing /etc/fstab configuration file with:

sudo nano /etc/fstab

,然后在文件末尾添加一行:

and then appending a line to the end of the file:

my_bucket /home/shared gcsfuse rw,noauto,user

但是它无助于解决这个问题.

but it did not help to solve this issue.

需要进行哪些更改,以允许所有用户完全访问映射的Google Bucket,以便用户能够创建,删除和修改存储在Google Bucket上的文件和文件夹?

What needs to be changed to allow all the users a full access to the mapped Google Bucket so the users are able to create, delete and modify the files and folders stored on Google Bucket?

推荐答案

我看到了您的问题,因为我遇到了完全相同的问题,并且也执行了与您相同的步骤. 让用户以root身份完全控制已安装的云文件夹的解决方案:

I saw your question because I was having exactly the same problem and I also did the same steps as you. The solution to give user root full control of the mounted cloud folder :

您必须转到Google Cloude所在的位置,搜索服务帐户",然后单击它.

You have to go to your Google Cloude place, search for "Service account" and clic on it.

然后,您必须导出服务帐户(.json)的密钥文件. (我使用以下命令使用Google Cloud Shell控制台创建了新的服务帐户:gcloud auth application-default login 然后在外壳提示时按照步骤操作.)

Then you have to export the key file of your service account (.json) (I have created a new service account with the Google Cloud Shell consol using this command : gcloud auth application-default login And then followed the steps when I was prompted by the shell.)

创建密钥时选择并选择JSON 将.JSON密钥文件上传到您的linux服务器. 然后在您的Linux服务器上,运行以下命令:gcsfuse -o allow_other --gid 0 --uid 0 --file-mode 777 --dir-mode 777 --key-file /path_to_your_keyFile_that_you_just_uploaded.json nameOfYourBucket /path/to/mount

Clic on Create Key and choose JSON Upload the .JSON keyfile to your linux server. Then on your Linux server, run this command : gcsfuse -o allow_other --gid 0 --uid 0 --file-mode 777 --dir-mode 777 --key-file /path_to_your_keyFile_that_you_just_uploaded.json nameOfYourBucket /path/to/mount

要找到您的根用户GID& UID,以root用户身份登录到您的服务器,并以终端类型:id -u root表示UID& id -g root用于GID

To find your root user GID & UID, login in root to your server and in terminal type : id -u root for UID & id -g root for GID

希望我能帮上忙,因为我一直在苦苦挣扎,互联网上没有任何资源真正有用.干杯.

Hope I helped, because I've been struggling for long and no resource on internet really helped. Cheers.

这篇关于如何在具有完全访问权限的Linux实例上将Google Bucket挂载为本地磁盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆