美文网首页
s3fs-fuse 使用介绍

s3fs-fuse 使用介绍

作者: 酱油王0901 | 来源:发表于2023-11-12 23:08 被阅读0次

安装

Centos

sudo yum install epel-release
sudo yum install s3fs-fuse

Ubuntu

sudo apt install s3fs

建议使用最新的 release 版本。

使用

  1. 创建 passwd 文件,注意替换成实际的 ak 和 sk
touch ${HOME}/.passwd-s3fs # 创建 passwd 文件
echo <ACCESS_KEY_ID>:<SECRET_ACCESS_KEY> > ${HOME}/.passwd-s3fs # 替换成实际的 ak 和 sk
chmod 600 ${HOME}/.passwd-s3fs # chmod

cat ${HOME}/.passwd-s3fs # 查看 passwd 文件
testy:testy
  1. 挂载
s3fs <bucket> </path/to/mountpoint> -o passwd_file=${HOME}/.passwd-s3fs -o url=<endpoint> -o use_path_request_style

# 其中,
#    `url` 指定 s3 endpoint 
#    `passwd_file` 指定上述存储 ak,sk 的文件
#    `use_path_request_style` 指定 older path request style

For example

~/smd (update_ceph ✗) s3cmd ls # 这里只是查看 bucket name,具体使用时换成相应的 bucket 即可                                                                                                              
2023-04-26 12:10  s3://bucket-0arc2cr3vl52r5bi
~/smd (update_ceph ✗) mkdir /mnt/s3 # 创建挂载点 

# 挂载
~/smd (update_ceph ✗) s3fs bucket-0arc2cr3vl52r5bi /mnt/s3 -o passwd_file=${HOME}/.passwd-s3fs -o url="http://10.9.8.72:80" -o use_path_request_style                         

# 查询挂载信息
~/go/src/deeproute.ai/smd (update_ceph ✗) df -hT | grep s3                                                                                                                   
s3fs                    fuse.s3fs   16E     0   16E   0% /mnt/s3

需要注意的是,不能将 {HOME} 换成 ~, 否则会报 s3fs: unexpected error from stat(~/.passwd-s3fs) 错误,对应的 issue s3fs: unexpected error from stat(). · Issue #1889 · s3fs-fuse/s3fs-fuse

  1. 读写文件
~/smd (update_ceph ✗) cd /mnt/s3                                                                                                                                                                                                                    
/mnt/s3 ls
adjust_pg_balance.py               csi-cephfsplugin.yaml   csi-nodeplugin-rbac.yaml   examples/           merge.py   set-pg-balance.py          xxx
ceph-conf.yaml                     csi-cephfs-secret.yaml  csi-provisioner-rbac.yaml  get-osd-pg-info.py  README.md  set_pg_progress.json
csi-cephfsplugin-provisioner.yaml  csi-config-map.yaml     df.old.log                 intree              rookObj1   set-primary-pg-balance.py
/mnt/s3 cat xxx           
xx
/mnt/s3 echo yyy > yyy
/mnt/s3 cat yyy  
yyy

  1. 使用完毕记得 umount
umount /mnt/s3
  1. 如果希望启动时自动挂载,可以修改 /etc/fstab
<mybucket> </path/to/mountpoint> fuse.s3fs _netdev,allow_other,use_path_request_style,url=<https://url.to.s3/> 0 0
# 注意,上述的 bucket 名,挂载点,以及 endpoint 都需要进行替换

注意事项

  1. 如果上传文件数较大(>100G),则会上传失败
cp: error writing '/mnt/s3/xxxx': File too large
cp: failed to close '/mnt/s3/xxxx': File too large

可以设置分段大小 -o multipart_size=30 ,30 代表 30M,可以根据实际需求进行调整。
此参数设置分段大小,默认为 10,单位是 MB,即 10MB x 分段数(默认10000),因此默认只支持100G大小,可以设置此参数来上传更大的文件。

参考链接

相关文章

  • Digital Ocean如何挂载spaces

    install https://github.com/s3fs-fuse/s3fs-fuse[https://gi...

  • 基于s3fs-fuse挂载oss至文件系统

    安装s3fs-fuse 设置oss所使用的AccessKey和AccessSecretKey 挂载oss至文件系统...

  • 3.STREAM

    1.Stream使用介绍 2.FS的使用介绍 3.Buffer使用介绍 4.Events使用介绍 5.有个例子可以看下

  • [iOS]JPVideoPlayer 3.0 使用介绍

    [iOS]JPVideoPlayer 3.0 使用介绍 [iOS]JPVideoPlayer 3.0 使用介绍

  • Pytest - 使用介绍

    1. 概述 pytest是一个非常成熟的全功能的Python测试框架,主要特点有以下几点: 1、简单灵活,容易上手...

  • podspec介绍使用

    关于使用本地制作Library 服务器上创建对应git管理 podspec创建 git对应的pod使用 pod '...

  • FMDB使用介绍

    最近公司要开发新项目,要使用到数据库,由于以前使用的较少,所以做下知识补充。介绍 iOS中原生的SQLite AP...

  • libcurl使用介绍

    目录 参考 curl介绍 libcurl-easy的API介绍 注意事项 1. 参考 [1] curl官网/cur...

  • AppCode使用介绍

    AppCode官网下载AppCode-*.dmgAppCode破解版下载地址下载地址密码:u9vf 功能以及快捷键...

  • Tox - 使用介绍

    1. 概述 tox是通用的虚拟环境管理和测试命令行工具。tox能够让我们在同一个Host上自定义出多套相互独立且隔...

网友评论

      本文标题:s3fs-fuse 使用介绍

      本文链接:https://www.haomeiwen.com/subject/tgckwdtx.html