oss挂载到ecs上
#下载rmp包
wget http://gosspublic.alicdn.com/ossfs/ossfs_1.80.6_centos7.0_x86_64.rpm
#安装
sudo yum localinstall ossfs_1.80.6_centos7.0_x86_64.rpm
#配置账号访问信息
echo my-bucket:my-access-key-id:my-access-key-secret > /etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs
#手动挂载到/data目录
mkdir /data
ossfs my-bucket /data -ourl=http://oss-cn-hangzhou-internal.aliyuncs.com
#取消挂载
fusermount -u /data
#创建开机启动脚本
cat /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.
/usr/local/bin/ossfs my-bucket /data -ourl=http://oss-cn-hangzhou-internal.aliyuncs.com -oallow_other
#开机自动挂载目录
chmod a+x /etc/init.d/ossfs
chkconfig ossfs on
###如果上述开机自动挂载目录失败的话,再添加命令到crontab
crontab -l
@reboot /etc/init.d/ossfs
###重启vm 测试一下是否自动挂了,重启后df -h 可以查看到/data 256T容量
网友评论