最近更新时间:2024.01.02 11:34:34
首次发布时间:2023.07.18 20:38:57
本文将介绍使用 Goofys 实现自动挂载,bing允许非root用户进行访问。
goofys是Google Cloud基于GO文件系统挂载对象存储桶的一个开源工具。本实验介绍如何自动挂载
参考:https://github.com/kahing/goofys
wget https://github.com/kahing/goofys/releases/latest/download/goofys
chmod +x goofys
./goofys --version
验证安装是否成功。回显如下则表示安装成功。获取火山引擎AccessKey 和SecretKey
登录火山引擎控制台
选择一级菜单“访问控制”—>选择二级菜单“密钥管理” 快捷入口
点击“新建密钥”,每个子账号最多拥有两个密钥
vim ~/.aws/credentials
[default] aws_access_key_id = Access_Key aws_secret_access_key = Secret_Key region = cn-beijing [user0] aws_access_key_id = Access_Key_user0 aws_secret_access_key = Access_Key_user0
mkdir /mnt
./goofys --subdomain --dir-mode=0755 --file-mode=0666 --profile default --endpoint https://tos-s3-cn-beijing.ivolces.com/ -o allow_other <bucket> <mountpoint>
参数说明:
--subdomian 使得goofys使用用virtual host模式访问TOS,默认会走Path模式
-o allow_other 允许一般用户访问桶
--file-mode value 文件的权限位
--dir-mode value 文件夹的权限位
--profile value value指定文件~/.aws/credentials
中的哪个密钥访问对象存储,例如 上述的default 、user0。不填则默认为匿名用户访问。
df -h
将火山引擎上的桶tos01(桶名)挂载到/mnt(挂载点)上,如图显示挂载成功
现在切换到其他用户,发现一般用户也可以访问
vim /etc/fstab
,在末尾中插入如下/root/goofys#<bucket> <mountpoint> fuse _netdev,allow_other,--file-mode=0666,--dir-mode=0777,--endpoint=https://tos-s3-cn-beijing.ivolces.com/,--profile=default 0 0
mount -a
即可挂载说明
/root/goofys
是goofys安装的位置--debug_s3
,重启后查看系统日志,查看自动挂载失败原因。通过以下命令可以实现桶的卸载
fusermount -u <mountpoint>
可能原因1:挂载点所在的目录一般用户无法访问。检查挂载点,比如挂载点在/root下面,一般用户无法访问/root
可能原因2:挂载命令里面少写参数-o allow_other
。这个参数表明允许一般用户访问挂载
可能原因3:fuse文件系统未安装
解决方案:下载fuse文件系统https://blog.csdn.net/pc620/article/details/6059118/
wget https://github.com/libfuse/libfuse/releases/download/fuse-2.9.6/fuse-2.9.6.tar.gz tar zxvf fuse-2.9.6.tar.gz cd fuse-2.9.6 ./configure
./configure make make install #注意:这一步一定要在root用户下进行
lsmod|grep fuse
若没成功则可通过:modprobe fuse
命令挂载fuse。