使用s3fs-fuse 挂载minio s3 对象存储

minio 是一个aws s3 兼容的对象存储系统,我们可以通过s3fs 进行数据桶的挂载,这样可以做好多方便的事情

环境准备

使用docker-compose 运行

  • minio docker-compose 文件
version: "3"
services:
  s3:
    image: minio/minio
    command: server /export
    ports:
    - "9000:9000"
    volumes:
      - ./data:/data
      - ./config:/root/.minio
    environment:
    - "MINIO_ACCESS_KEY=dalongapp"
    - "MINIO_SECRET_KEY=dalongapp"
  • 安装s3fs-fuse

    centos 系统

yum install -y s3fs-fuse 
  • 配置.passwd-s3fs

    注意这个文件的权限,(目前我测试600 是没有问题的,实际参考操作提示解决)

echo dalongapp:dalongapp > .passwd-s3fs
chmod 600 .passwd-s3fs
  • 创建桶

如下图:

挂载文件系统

  • s3fs
创建挂载点
mkdir /opt/webhooks
s3fs -o passwd_file=.passwd-s3fs -o use_path_request_style -o endpoint=us-east-1 -o url=http://localhost:9000 -o bucket=app /opt/webhooks
  • 文件信息查询
ls  -sailh /op/webhooks
   1 512 drwx------ 1 root root 0 1月 1 1970 .
131074 4.0K drwxr-xr-x. 12 root root 4.0K 429 13:30 ..
     2 2.5K -rw-r----- 1 root root 2.2K 4月 29 13:05 hooks.json
     3 512 drwxr-x--- 1 root root 0 1月 1 1970 rong

挂载中的几个问题

  • password 权限
 credentials file .passwd-s3fs should not have others permissions.
设置 .passwd-s3fs 文件权限 600
  • openssl 问题
s3fs[18691]: init v1.85(commit:unknown) with OpenSSL
这个看这个目前基本是可以使用的,基本问题不大
  • unable to access MOUNTPOINT
注意需要配置.passwd-s3fs 文件,同时添加参数

一个简单使用挂载s3 文件系统的例子

  • webhook 功能
启动运行文件
/usr/bin/webhook -port 9001 -hooks /opt/webhooks/hooks.json -verbose -hotreload
  • systemd 配置
[Unit]
Description=webhook

[Service]
Type=simple
User=root
Group=root
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.
# Prefixing the path with '-' makes it try to load, but if the file doesn't
# exist, it continues onward.
EnvironmentFile=-/etc/default/webhook
EnvironmentFile=-/etc/sysconfig/webhook
ExecStart=/usr/bin/webhook -port 9001 -hooks $OPTHOOKS -verbose -hotreload
Restart=always

[Install]
WantedBy=multi-user.target
  • 运行配置
/etc/default/webhook
OPTHOOKS= "/opt/webhooks/hooks.json"

说明

使用s3fs 挂载方式,对于我们进行开发中配置的变动,还是很方便的,中心话,可以通过直接修改信息,然后重新上传配置,部分应用可能需要重启
生效配置

参考资料

https://github.com/s3fs-fuse/s3fs-fuse

posted on   荣锋亮  阅读(10096)  评论(2编辑  收藏  举报

编辑推荐:
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 上周热点回顾(2.17-2.23)
· 如何使用 Uni-app 实现视频聊天(源码,支持安卓、iOS)
· spring官宣接入deepseek,真的太香了~
历史上的今天:
2015-04-29 VC ++ MFC activex 控件获取连接的VPN 信息
2015-04-29 Google Proposes to Enhance JSON with Jsonnet
2014-04-29 oracle 与sql serve 获取随机行数的数据

导航

< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8
点击右上角即可分享
微信分享提示