s3fs-fuse
是一个采用 c++??
开发的开源应用,它的作用是可以将 AWS S3
以及兼容 S3 API
的第三方对象存储像普通文件系统一样挂载到本地计算机,由于这种功能通过 FUSE
实现,因此只能在 Linux 和 MacOS 上使用。
S3 及兼容 API 的对象存储都采用 ACCESS KEY
和 ACCESS SECRET
认证身份,为了方便配置,可以将认证 KEY 放到独立的密码文件中,s3fs
默认会从以下两个文件中读取认证信息:
.passwd-s3fs
文件 (例如 ~/.passwd-s3fs
)/etc/passwd-s3fs
任选其一即可,文件默认不存在,需要自己手动创建。
$ echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > ~/.passwd-s3fs
$ chmod 600 ~/.passwd-s3fs
$ s3fs mybucket /path/to/mountpoint -o passwd_file=~/.passwd-s3fs
mybucket
替换成实际的 S3 Bucket/path/to/mountpoint
替换成本地挂载点-o
用来指定额外的参数,除非密码文件没有放在默认位置,否则不需指定密码文件。用 -o
指定对象存储 Endpoint 地址即可,阿里云OSS Endpoint地址参考这里??,七牛对象存储 Endpoint地址参考这里??。
$ s3fs mybucket /path/to/mountpoint -o url=https://endpoint -o use_path_request_style
use_path_request_style
参数是对还不支持virtual-host
请求风格的对象存储而提供的参数,指定该参数会使用传统的 API 调用风格。实测表明,阿里云 OSS 和七牛对象存储不需指定该参数。
编辑 /etc/fstab
:
s3fs#mybucket /path/to/mountpoint fuse _netdev,allow_other 0 0
s3fs#mybucket /path/to/mountpoint fuse _netdev,allow_other,use_path_request_style,url=http://endpoint/ 0 0
注意:设置开机自动挂载可能需要把
s3fs
二进制文件放到/usr/local/bin
目录,还要使用全局配置文件/etc/passwd-s3fs
保存密码。
设置 use_cache
将本地计算机的某个位置作为缓存,从而提高数据上传的效率。
$ s3fs mybucket /path/to/mountpoint -o url=https://endpoint -o use_cache=/tmp
指定 del_cache
参数,当 s3fs 启动和退出时会自动删除缓存文件。
s3fs <bucket_name> <mountpoint> -o url=http://endpoint –o passwd_file=<credentials_file> -o cipher_suites=AESGCM -o kernel_cache -o max_background=1000 -o max_stat_cache_size=100000 -o multipart_size=64 -o parallel_count=30 -o multireq_max=30 -o dbglevel=warn
Filesystem in Userspace
简称 FUSE
。它允许 Unix 普通用户在不修改内核的条件下能够创建自己的文件系统。目前 Linux 通过内核模块对 FUSE 进行支持。一些文件系统如 ZFS、glusterfs 和 lustre 通过 FUSE 实现。
原文:https://www.cnblogs.com/hiyang/p/12631908.html