安装步骤
-
创建bucket
登陆阿里云oss控制台,新增一个bucket,获取access key -
下载ossfs
注意根据服务器版本下载
wget https://github.com/aliyun/ossfs/releases/download/v1.80.3/ossfs_1.80.3_centos6.5_x86_64.rpm
- 安装
使用sudo或切换到root
rpm -ivh ossfs_1.80.3_centos6.5_x86_64.rpm
- 挂载
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
- 配置启动时自动挂载
不要放到/etc/fstab ,防止挂载失败而系统无法启动
echo 'ossfs my-bucket /tmp/ossfs -ourl=http://oss-cn-hangzhou.aliyuncs.com' >> /etc/rc.d/rc.local
- 卸载
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