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

2022-11-10,,,

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 4月 29 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

 
 
 
 

使用s3fs-fuse 挂载minio s3 对象存储的相关教程结束。

《使用s3fs-fuse 挂载minio s3 对象存储.doc》

下载本文的Word格式文档,以方便收藏与打印。