ossfs 能让您在Linux系统中把OSS bucket 挂载到本地文件系统中,您能够便捷地通过本地文件系统操作OSS 上的对象,实现数据的共享。
主要功能
ossfs 基于s3fs 构建,具有s3fs 的全部功能。主要功能包括:
支持POSIX 文件系统的大部分功能,包括文件读写,目录,链接操作,权限,uid/gid,以及扩展属性(extended attributes)
通过OSS 的multipart 功能上传大文件。
MD5 校验保证数据完整性。
局限性
ossfs提供的功能和性能和本地文件系统相比,具有一些局限性。具体包括:
随机或者追加写文件会导致整个文件的重写。
元数据操作,例如list directory,性能较差,因为需要远程访问OSS服务器。
文件/文件夹的rename操作不是原子的。
多个客户端挂载同一个OSS bucket时,依赖用户自行协调各个客户端的行为。例如避免多个客户端写同一个文件等等。
不支持hard link。
不适合用在高并发读/写的场景,这样会让系统的load升高。
安装及使用
安装包下载
Linux发行版 | 下载 |
---|---|
Ubuntu 16.04 (x64) | ossfs_1.80.3_ubuntu16.04_amd64.deb |
Ubuntu 14.04 (x64) | ossfs_1.80.3_ubuntu14.04_amd64.deb |
CentOS 7.0 (x64) | ossfs_1.80.3_centos7.0_x86_64.rpm |
CentOS 6.5 (x64) | ossfs_1.80.3_centos6.5_x86_64.rpm |
安装方法
对于Ubuntu,安装命令为:
sudo apt-get update sudo apt-get install gdebi-core sudo gdebi your_ossfs_package
对于CentOS6.5及以上,安装命令为:
sudo yum localinstall your_ossfs_package
对于CentOS5,安装命令为:
sudo yum localinstall your_ossfs_package --nogpgcheck
使用方法
设置bucket name 和 AccessKeyId/Secret信息,将其存放在/etc/passwd-ossfs 文件中,注意这个文件的权限必须正确设置,建议设为640。
echo my-bucket:my-access-key-id:my-access-key-secret > /etc/passwd-ossfs chmod 640 /etc/passwd-ossfs
将OSS bucket mount到指定目录。
ossfs my-bucket my-mount-point -ourl=my-oss-endpoint
示例
将my-bucket这个bucket挂载到/tmp/ossfs目录下,AccessKeyId是faint,AccessKeySecret是123,oss endpoint是http://oss-cn-hangzhou.aliyuncs.com
echo my-bucket:faint:123 > /etc/passwd-ossfs chmod 640 /etc/passwd-ossfs mkdir /tmp/ossfs ossfs my-bucket /tmp/ossfs -ourl=http://oss-cn-hangzhou.aliyuncs.com
卸载bucket:
fusermount -u /tmp/ossfs
更多详细内容请参考:https://github.com/aliyun/ossfs#ossfs
版本日志
请参考:https://github.com/aliyun/ossfs/blob/master/ChangeLog
文章源地址: https://help.aliyun.com/document_detail/32196.html?spm=5176.8150156.427429.5.2Vu4ZT