Centos 7 Mount挂载阿里云对象存储空间OSS到服务器文件夹
------------------这是成功案例------------------
wget http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/32196/cn_zh/1463121229943/ossfs_1.79.8_centos7.0_x86_64.rpm
sudo yum localinstall ossfs_1.79.8_centos7.0_x86_64.rpm
echo bucket:LTAIOihQI......:DfbzQhF...... >/etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs
mkdir /alioss
ossfs bucket /alioss -ourl=http://oss-cn-hangzhou.aliyuncs.com
卸载
umount /alioss
开机挂载
vi /etc/rc.d/rc.local
# 开机挂载oss,采用此种方式挂载避免修改/etc/fstab ,导致挂载失败而系统无法启动。加 -o allow_other 允许非root用户操作避免因权限问题导致无法操作oss目录
ossfs bucket /alioss -ourl=http://oss-cn-hangzhou.aliyuncs.com -o allow_other
注意:无论使用阿里云自带的挂载ossfs还是alist,内网和外网Endpoint都测试过,挂载后都特别慢,无法正常使用。
------------------以下是资料收集------------------
下载ossfs安装包
wget http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/32196/cn_zh/1463121229943/ossfs_1.79.8_centos7.0_x86_64.rpm
安装ossfs
sudo yum localinstall ossfs_1.79.8_centos7.0_x86_64.rpm
将image这个bucket挂载到/mnt/ossfs目录下,AccessKeyId是faint, AccessKeySecret是123,oss endpoint是http://oss-cn-hangzhou.aliyuncs.com。
注意
如果你是阿里云的ecs,endpoint可以使用内网地址,例如http://oss-cn-hangzhou-internal.aliyuncs.com,减少流量费用。
更多的内网地址可参考:https://help.aliyun.com/document_detail/31837.html?spm=5176.2020520105.0.0.1QhBJ1
实例:
# echo image:faint:123 > /etc/passwd-ossfs
# chmod 640 /etc/passwd-ossfs
# mkdir /mnt/ossfs
# ossfs image /mnt/ossfs -ourl=http://oss-cn-hangzhou.aliyuncs.com -o allow_other
卸载
# umount /mnt/ossfs
优化及注意事项
开机挂载
vi /etc/rc.d/rc.local
# 开机挂载oss,采用此种方式挂载避免修改/etc/fstab ,导致挂载失败而系统无法启动。加 -o allow_other 允许非root用户操作避免因权限问题导致无法操作oss目录
ossfs image /mnt/ossfs -ourl=http://oss-cn-hangzhou.aliyuncs.com -o allow_other
非阿里云ecs挂载注意事项
为避免后台程序扫描oss文件导致产生费用,如果是updatedb,可以通过修改/etc/updatedb.conf让它跳过。具体做法是:
在PRUNEFS =后面加上fuse.ossfs
在PRUNEPATHS =后面加上挂载的目录
更多内容请参考:https://help.aliyun.com/document_detail/32196.html?spm=5176.doc31883.6.541.3B03r4
默认分类 2022-03-21 19:39:13 通过 网页 浏览(608)
共有0条评论!