阿里 ossfs 挂载后设置开机自动挂载

Centos 6.5 或 Ubuntu 14.04通过 fstab 的方式自动 mount

在 /etc/fstab 中加入下面的命令 ossfs your_bucket_name your_mount_point fuse _netdev,url=your_url,allow_other 0 0 按照我们的实际信息,应将以下命令加入/etc/fstab中: ossfs wordpressoss /data/wwwroot/wordpress/wp-content/uploads 41htXS03QeGC7hZZ 5efjr5HZaGWBlSIf5WU7tMeZrvx20h,url=http://oss-cn-qingdao.aliyuncs.com,allow_other 0 0

保存/etc/fstab文件。执行以下命令,如果没有报错,则说明设置正常。 mount -a 到这一步,ubuntu 就能自动挂载了。centos 6.5 还需要执行下面的命令: chkconfig netfs on 自此您重启系统后,即可看见挂载的 Bucket。

Centos7.0 通过开机自启动脚本 mount

在 /etc/init.d/ 目录下建立文件 ossfs,模版如下: #! /bin/bash# ossfs Automount Aliyun OSS Bucket in the specified direcotry.## chkconfig: 2345 90 10# description: Activates/Deactivates ossfs configured to start at boot time.ossfs your_bucket your_mountpoint -ourl=your_url -oallow_other 按照我们的实际信息,应将以下命令加入/etc/init.d/ossfs中: #! /bin/bash# ossfs Automount Aliyun OSS Bucket in the specified direcotry.## chkconfig: 2345 90 10# description: Activates/Deactivates ossfs configured to start at boot time.ossfs wordpressoss /data/wwwroot/wordpress/wp-content/uploads -ourl=http://oss-cn-qingdao.aliyuncs.com -oallow_other

执行命令,添加执行权限: chmod a+x /etc/init.d/ossfs 如果脚本文件内容无误,那么此时oss中的bucket已经挂载到您指定的目录下了。 把ossfs启动脚本作为其他服务,开机自动启动。 chkconfig ossfs on

PS:使用ECS挂载ossfs,如何避免因后台程序扫描文件而产生费用? 程序扫描ossfs挂载的目录,会转换成向OSS的请求,如果请求次数很多,会产生费用(1分钱/1万次)。如果是updatedb,可以通过修改/etc/updatedb.conf让它跳过。具体做法是: 在PRUNEFS =后面加上fuse.ossfs 在PRUNEPATHS =后面加上挂载的目录

PS:使用ossfs上传到OSS的文件Content-Type全是”application/octet-stream”是怎么回事? ossfs 通过查询 /etc/mime.types 中的内容来确定文件的 Content-Type ,请检查这个文件是否存在,如果不存在,则需要添加: 对于centos可以通过 yum install mailcap 来添加 也可以手动添加,每种格式一行,每行格式为: application/javascript js

ps: 挂载操作可参考 https://help.aliyun.com/document_detail/32196.html?spm=5176.7933691.203620.13.x1Gud5 https://www.janecc.com/use-the-ossfs-tool-to-oss-to-linux.html

ps: 挂载非空文件夹: ossfs cms-upload96189 /tmp/osstest -ourl=http://oss-cn-qingdao.aliyuncs.com -o nonempty

转载于:https://my.oschina.net/jack088/blog/878054

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值