Home > 系统管理 > [CentOS] 使用s3fs-fuse挂载S3Bucket到本地分区

[CentOS] 使用s3fs-fuse挂载S3Bucket到本地分区

准备工作
1.创建接入S3 Bucket的IAM用户
2.创建S3 Bucket,赋予IAM用户读写S3 Bucket的权限

测试环境
Amazon AMI Linux
CentOS 7.5

s3fs
s3fs allows Linux and macOS to mount an S3 bucket via FUSE. s3fs preserves the native object format for files, allowing use of other tools like s3cmd.

STEP1. 安装s3fs-fuse相关依赖包

 # install automake fuse fuse-devel gcc-c++ git \
 libcurl-devel libxml2-devel make openssl-devel

STEP2.下载s3fs-fuse,编译安装s3fs-fuse

# cd /usr/local/
# git clone https://github.com/s3fs-fuse/s3fs-fuse.git
# cd s3fs-fuse
# ./autogen.sh
# ./configure
# make
# make install

使用包管理器安装

# CentOS
yum install -y epel-release
yum install -y s3fs-fuse
 
# Ubuntu
# apt-get install -y s3fs-fuse

STEP3.创建访问s3的.passwd-s3fs认证文件,将IAM用户的认证access key和access secret写入s3fs-fuse的认证文件

# echo MYIDENTITY:MYCREDENTIAL >  ~/.passwd-s3fs
# chmod 600  ~/.passwd-s3fs

STEP4.挂载S3存储桶到本地

# mkdir /mnt/s3bucket
# s3fs -o passwd_file=~/.passwd-s3fs -o endpoint=us-east-2 -o allow_other s3_bucket_name /mnt/s3bucket

STEP5.配置fstab,开机自动挂载分区

# vim /etc/fstab
/usr/local/bin/s3fs#s3_bucket_name:/path /mnt/s3bucket fuse allow_other,url=https://s3-us-east-2.amazonaws.com 0  0

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

Categories: 系统管理 Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.