GCE虚拟机中GCSFUSE挂载Cloud Storage桶失败的问题及解决
问题背景
在GCP虚拟机上部署了3D地图制作工具VCPUBLISHER,目标Cloud Storage桶为公开状态,Compute Engine默认账号已配置Storage Admin角色。本地存储文件时工具运行正常,但因单数据集平均超过40GB,计划挂载Cloud Storage桶作为存储介质。
报错情况
执行初始挂载命令:
gcsfuse gs://bucket_name /var/full/path/to/mount/location
返回错误:
Error while mounting gcsfuse: mountWithArgs: mountWithStorageHandle: fs.NewServer: create file system: SetUpBucket: Error in iterating through objects: storage: bucket doesn't exist
但通过gsutil ls可正常列出该桶内的内容,同时GCSFUSE日志中出现额外错误:
Error returned from GetStorageLayout: rpc error: code = InvalidArgument desc = Invalid storage layout name. Storage layout name should be a valid bucket resource name followed by '/storageLayout'.
error details: name = ErrorInfo reason = INVALID_STORAGE_LAYOUT_NAME domain = storage.googleapis.com metadata = map[ ]
解决步骤
调整挂载目录权限:
修改挂载目录的所属用户和权限:sudo chown user:user /var/full/path/to/mount/location sudo chmod 755 /var/full/path/to/mount/location(注:将
user替换为实际执行挂载操作的系统用户)修改挂载命令参数:
使用带额外参数的命令重新挂载:gcsfuse -o allow_other --implicit-dirs bucketname /var/full/path/to/mount/location其中:
-o allow_other:允许其他用户访问挂载的文件系统--implicit-dirs:自动识别GCS桶中的虚拟目录结构bucketname:仅填写桶名称,无需gs://前缀
执行以上步骤后,成功完成Cloud Storage桶的挂载,VCPUBLISHER可正常读取桶内数据。
内容的提问来源于stack exchange,提问作者Luis García

