在非AWS机器上使用s3fs挂载S3存储桶并使用IAM角色

52次阅读
没有评论

问题描述

在自己的本地CentOS-6服务器上尝试使用s3fs挂载S3存储桶,命令如下:

[roots@myhost ~]# s3fs bucket-name /mnt/s3mnt -o  uid=1001,gid=1001,allow_other,umask=022,iam_role=iam-role,use_cache=/tmp

但是出现了以下错误:

s3fs: unable to access MOUNTPOINT /mnt/s3mnt: Transport endpoint is not connected
debug :     set_moutpoint_attribute(3293): PROC(uid=0, gid=0) - MountPoint(uid=0, gid=0, mode=40777)
s3fs_init(2597): inits3fs_check_service(2896): check services.
RequestPerform(1524): ### CURLE_OPERATION_TIMEDOUT
RequestPerform(1617): ### retrying...
RemakeHandle(1288): Retry request. [type=-1][url=http://169.254.169.254/latest/meta-data/iam/security-credentials/iam-role][path=]
RequestPerform(1620): Failed to reset handle and internal data for retrying.
s3fs: Failed to check IAM role name(iam-role).

用户想知道是否有人成功地在非AWS机器上使用s3fs挂载S3存储桶,并希望得到一些建议。

解决方案

请注意以下操作注意版本差异及修改前做好备份。

方案1

首先,确保在该机器上配置了AWS凭证。可以使用以下命令进行配置:

~ $ aws configure

然后,使用以下命令验证配置是否成功:

~ $ aws sts get-caller-identity

如果配置成功,可以尝试重新运行s3fs命令。如果问题仍然存在,请尝试以下解决方案。

方案2

根据用户的评论,可能是由于旧版本的fuse存在问题。在不使用iamrole参数的情况下,s3fs可以正常工作。因此,您可以尝试使用以下命令:

/usr/bin/s3fs my-bucket /my-mount/ -o uid=500,gid=501,iam_role=MyRole,use_cache=/tmp,endpoint=ap-south-1,url=https://s3.amazonaws.com

请注意,您需要将my-bucket替换为您的存储桶名称,/my-mount/替换为您要挂载的目录,uidgid替换为适当的用户和组ID,iam_role替换为您的IAM角色名称,endpointurl替换为适当的值。
希望这些解决方案对您有所帮助。如果问题仍然存在,请提供更多详细信息以便我们进一步帮助您。

正文完