软件安装
需要安装三个软件
安装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
- 先clone下仓库
git clone https://github.com/aliyun/ossfs.git
- 安装编译需要的依赖
brew install autoconf automake libtool libxml2 pkg-config
- 编译安装
./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
命令来查看:
- 显示当前用户的 uid
id -u $(whoami)
- 获得当前用户的 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
命令详细说明:
发表评论