fuse--s3挂载到centos7.5服务器

需将s3 bucket 挂载到本地centos7服务器,用作附件或备份存储。

授权

在aws上创建 s3 bucket的IAM用户,并添加读写权限。在此获取 Access Key ID 与 Secret Access Key。

安装依赖包

yum install fuse.x86_64 fuse-devel.x86_64 fuse-libs.x86_64 libconfuse-devel.x86_64 libconfuse.x86_64 -y
yum install gcc-c++.noarch -y
yum install curl.x86_64 libcurl-devel.x86_64 libcurl.x86_64 -y
yum install libxml2.x86_64 libxml2-devel.x86_64 openssl-devel.x86_64 -y

安装s3fs-fuse

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

以下命令输出代表安装成功

[root@one s3test]# /usr/local/bin/s3fs 
s3fs: missing BUCKET argument.
Usage: s3fs BUCKET:[PATH] MOUNTPOINT [OPTION]...

添加Access Key ID 与 Secret Access Key

vim ~/.passwd-s3fs
格式为  Access Key ID:Secret Access Key
chmod 600  ~/.passwd-s3fs   

挂载:

 mkdir /mnt/s3bucket
 /usr/local/bin/s3fs -o passwd_file=~/.passwd-s3fs -o url=https://s3.cn-northwest-1.amazonaws.com.cn -o allow_other my-buckentname /mnt/s3bucket/ -o use_cache=/tmp

此处会有报错 libcurl版本低的问题

更新curl版本

见:https://www.htcp.net/337.html
步骤为:

cp /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt.bak
curl http://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/certs/ca-bundle.crt

vim /etc/yum.repos.d/city-fan-for-curl.repo
[CityFanforCurl]
name=City Fan Repo
baseurl=http://www.city-fan.org/ftp/contrib/yum-repo/rhel7/x86_64/
enabled=0
gpgcheck=0

yum update curl --enablerepo=CityFanforCurl -y

重新挂载

/usr/local/bin/s3fs -o passwd_file=~/.passwd-s3fs -o url=https://s3.cn-northwest-1.amazonaws.com.cn -o allow_other my-buckentname /mnt/s3bucket/ -o use_cache=/tmp
df -h  #查看挂载是否成功

注:若挂载未成功,可在挂载命令添加-d -d -f -o f2 -o curldbg ,输出日志查看问题
注意以上命令中,它实际访问的链接是https://my-buckentname.s3.cn-northwest-1.amazonaws.com.cn;
若要它的访问链接完全等于url中的链接,可加上 -o use_path_request_style

/usr/local/bin/s3fs -o passwd_file=~/.passwd-s3fs -o use_path_request_style  -o url=http://minio-s3.test.net:3000  -o allow_other my-buckentname /mnt/s3bucket/
原文地址:https://www.cnblogs.com/huandada/p/12411623.html