S3FS是google开发的一款支持将对象存储中的bucket以文件形式导出的文件系统接口,是基于FUSE开发文件系统,允许Linux挂载S3的存储桶在本地文件系统,S3FS能够保持对象原来的格式。
一.ubuntu系统
sudo apt-get update
sudo apt-get install s3fs
touch /etc/passwd-s3fs (文件可以随便起名或者放哪个目录下,不过后面参数数值也需要随之改动)
chmod 600 /etc/passwd-s3fs (修改权限)
echo ak:sk >/etc/passwd-s3fs (将ak和sk写入到文件中,ak,sk从各云服务商获取)
mkdir /s3fs #创建挂载目录(随便起名)
s3fs bucket_name /s3fs -o passwd_file=/etc/passwd-s3fs -o url=http://rgw_ip:port -o use_path_request_style -o allow_other
将挂载信息写入/etc/fstab中
echo "s3fs#bucket_name /s3fs fuse _netdev,passwd_file=/etc/passwd-s3fs,allow_other,use_path_request_style,url=http://rgw_ip:port 0 0" >>/etc/fstab
挂载效果
二.centos系统
yum -y install epel-release
yum -y install s3fs-fuse
后面步骤同上
注意挂载加一个参数 指定挂载大小 -o bucket_size=一个可选的整数,后面跟一个乘法后缀(GB、 GiB、 TB、 TiB、 PB、 PiB、 EB、 EiB)(中间没有空格)
列如:s3fs bucket_name /s3fs -o passwd_file=/etc/passwd-s3fs -o url=http://rgw_ip:port -o use_path_request_style -o allow_other -o bucket_size=100TB
将挂载信息写入/etc/fstab中
echo "s3fs#bucket_name /s3fs fuse _netdev,passwd_file=/etc/passwd-s3fs,allow_other,use_path_request_style,bucket_size=100TB,url=http://rgw_ip:port 0 0" >>/etc/fstab
挂载效果