当前位置: 代码网 > it编程>操作系统>苹果Mac > Mac挂载阿里云Oss

Mac挂载阿里云Oss

2024年08月03日 苹果Mac 我要评论
如何在Macos上面挂着阿里云oss

软件安装

需要安装三个软件

安装macfuse

github地址:https://github.com/s3fs-fuse/s3fs-fuse

使用brew安装

brew install --cask macfuse
#brew install gromgit/fuse/s3fs-mac

ossfs安装

本安装参考该博主的文档:https://www.itpony.com/show/58.html
阿里云官方文档:https://help.aliyun.com/zh/oss/developer-reference/use-ossfs-to-mount-an-oss-bucket-to-the-local-directories-of-an-ecs-instance/?spm=5176.8466032.help.dexternal.78ce1450dpxgil

目前阿里云没有提供mac直接安装的方法,需要自己手动编译

github地址:https://github.com/aliyun/ossfs

  1. 先clone下仓库
git clone https://github.com/aliyun/ossfs.git
  1. 安装编译需要的依赖
brew install autoconf automake libtool libxml2 pkg-config
  1. 编译安装
./autogen.sh
./configure
sudo make
sudo make install

ps: 我在这里make的时候报了个错

mix_direct_read_test.cc:74:31: error: no matching function for call to 'min' size_t buf_size = std::min(mb, sub_total_size - offset); ^~~~~~~~ /library/developer/commandlinetools/sdks/macosx.sdk/usr/include/c++/v1/__algorithm/min.h:40:1: note: candidate template ignored: deduced conflicting types for parameter '_tp' ('size_t' (aka 'unsigned long') vs. 'unsigned long long') min(_libcpp_lifetimebound const _tp& __a, _libcpp_lifetimebound const _tp& __b) ^ /library/developer/commandlinetools/sdks/macosx.sdk/usr/include/c++/v1/__algorithm/min.h:51:1: note: candidate template ignored: could not match 'initializer_list<_tp>' against 'size_t' (aka 'unsigned long') min(initializer_list<_tp> __t, _compare __comp) ^ /library/developer/commandlinetools/sdks/macosx.sdk/usr/include/c++/v1/__algorithm/min.h:60:1: note: candidate function template not viable: requires single argument '__t', but 2 arguments were provided min(initializer_list<_tp> __t) ^ /library/developer/commandlinetools/sdks/macosx.sdk/usr/include/c++/v1/__algorithm/min.h:31:1: note: candidate function template not viable: requires 3 arguments, but 2 were provided min(_libcpp_lifetimebound const _tp& __a, _libcpp_lifetimebound const _tp& __b, _compare __comp) ^ 1 error generated. make[2]: *** [mix_direct_read_test.o] error 1 make[1]: *** [all-recursive] error 1 make: *** [all] error 2

根据网上找到的解决方法是:

挂载

可以使用非root挂载,否则每次都要sudo比较麻烦,而且在finder还看不到。

先查询当前用户的uid和gid,可以使用id命令来查看:

  1. 显示当前用户的 uid
id -u $(whoami)
  1. 获得当前用户的 gid
id -g $(whoami)

创建passwd-ossfs,可以在当前用户目录下创建一个.passwd-ossfs,后续通过指定密钥文件进行挂载,文件创建成功后需要设置为600的权限,否则会被程序会拒绝

sudo sh -c 'echo bucket-test:ltaibzcdvcmq****:mok8x0y9hxq31coh7a5e2mzeuz**** > ~/.passwd-ossfs'
sudo chmod 600 /etc/passwd-ossfs

上面都做好之后就可以挂载了,可以参考使用下面命令

ossfs your-bucket /users/mac/oss -o url=http://oss-cn-hangzhou.aliyuncs.com -o passwd_file=/users/mac/.passwd-ossfs -o uid=501 -o gid=20

命令详细说明:

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com