banner
李大仁博客

李大仁博客

天地虽大,但有一念向善,心存良知,虽凡夫俗子,皆可为圣贤。

[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 > ~/.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

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.