阿里云挂载OSS到ECS

安装步骤

  1. 创建bucket
    登陆阿里云oss控制台,新增一个bucket,获取access key

  2. 下载ossfs
    注意根据服务器版本下载

wget https://github.com/aliyun/ossfs/releases/download/v1.80.3/ossfs_1.80.3_centos6.5_x86_64.rpm
  1. 安装
    使用sudo或切换到root
rpm -ivh ossfs_1.80.3_centos6.5_x86_64.rpm
  1. 挂载
    my-bucket:bucket名称
    my-access-key-id: 授权密钥id
    my-access-key-secret: 授权密钥
    my-mount-point: 挂载目录
    my-oss-endpoint: bucket访问云域名,如:http://oss-cn-shenzhen-internal.aliyuncs.com
    注意下面命令需要将参数替换成自己的。
echo my-bucket:my-access-key-id:my-access-key-secret > /etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs
mkdir /oss
ossfs my-bucket my-mount-point -ourl=my-oss-endpoint -o allow_other
  1. 配置启动时自动挂载
    不要放到/etc/fstab ,防止挂载失败而系统无法启动
echo 'ossfs my-bucket /tmp/ossfs -ourl=http://oss-cn-hangzhou.aliyuncs.com' >>  /etc/rc.d/rc.local
  1. 卸载
fusermount -u /oss

遇到的问题

Q: error: Failed dependencies:
	fuse >= 2.8.4 is needed by ossfs-1.80.4-1.x86_64
	fuse-libs >= 2.8.4 is needed by ossfs-1.80.4-1.x86_64
A: 依赖关系,centos6.8的fuse最高版本是2.8.3 ,而oss官网提供的ossfs 需要2.8.4,
所以自己到github上下载1.80.3的ossfs安装。
Q:file /sbin/mount.fuse from install of ossfs-1.80.3-1.x86_64 conflicts with f...
A:因为前面的问题,已经装了fuse了,可能是版本冲突,卸载待fuse fuse-libs ,然后重新安装 ossfs,让他自己安装依赖
Q:ossfs: unable to access MOUNTPOINT /oss: No such file or directory
A:没有创建目录 mkdir /oss
Q:ossfs: could not resolve host 'http:oss-cn-shenzhen.aliyuncs.com'. If you use IP, please try to add option '-o use_path_reqeust_style'
A:url 写错了
Q:ossfs: invalid credentials
    <?xml version="1.0" encoding="UTF-8"?>
    <Error>
      <Code>AccessDenied</Code>
      <Message>The bucket you visit is not belong to you.</Message>
      <RequestId>5AF50BE562A4FAB1DB7BBE3E</RequestId>
      <HostId>yeah400-disk.oss-cn-shenzhen-internal.aliyuncs.com</HostId>
    </Error>
A:密钥错了,或者不是这个oss的
Q:挂载后目录权限问题
A:挂载命令添加 -o allow_other #允许所以用户,权限是777

参考:
https://help.aliyun.com/document_detail/32196.html
https://help.aliyun.com/document_detail/32197.html?spm=a2c4g.11186623.4.1.pI3VjY
https://github.com/aliyun/ossfs
https://www.cnblogs.com/rwxwsblog/p/5938701.html

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值