A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

概要:
局限性
ossfs提供的功能和性能和本地文件系统相比,具有一些局限性。具体包括:
  • 随机或者追加写文件会导致整个文件的重写。
  • 元数据操作,例如list directory,性能较差,因为需要远程访问oss服务器
  • 文件/文件夹的rename操作不是原子的
  • 多个客户端挂载同一个oss bucket时,依赖用户自行协调各个客户端的行为。例如避免多个客户端写同一个文件等等。
  • 不支持hard link。
  • 不适合用在高并发读/写的场景,这样会让系统的load升高
一、安装ossfs之前安装相应的依赖库:
Ubuntu 14.04:sudo apt-get install automake autotools-dev g++ git libcurl4-gnutls-dev \                     libfuse-dev libssl-dev libxml2-dev make pkg-configCentOS 7.0:sudo yum install automake gcc-c++ git libcurl-devel libxml2-devel \                 fuse-devel make openssl-devel
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
安装ossfs源码,可以从github上获取
git clone https://github.com/aliyun/ossfs.gitcd ossfs./autogen.sh./configuremakesudo make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
二、配置相应文件
设置bucket name, access key/id信息,将其存放在/etc/passwd-ossfs 文件中, 注意这个文件的权限必须正确设置,建议设为640。
echo my-bucket:my-access-key-id:my-access-key-secret > /etc/passwd-ossfschmod 640 /etc/passwd-ossfs
  • 1
  • 2
挂载oss相应的bucket到本地挂载点
ossfs my-bucket my-mount-point -ourl=my-oss-endpoint
example:将my-bucket这个bucket挂载到/tmp/ossfs目录下,AccessKeyId是faint, AccessKeySecret是123,oss endpoint是http://oss-cn-hangzhou.aliyuncs.comecho my-bucket:faint:123 > /etc/passwd-ossfschmod 640 /etc/passwd-ossfsmkdir /tmp/ossfsossfs my-bucket /tmp/ossfs -ourl=http://oss-cn-hangzhou.aliyuncs.com
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
卸载oss
卸载bucket:umount /tmp/ossfs # root userfusermount -u /tmp/ossfs # non-root user
  • 1
  • 2
  • 3
  • 4

遇到的问题:
ossfs test /ossfsfile -ourl=http://oss-cn-hangzhou.aliyuncs.com[ERR] curl.cpp:CheckBucket(2625): Check bucket failed, OSS response: <?xml version="1.0" encoding="UTF-8"?><Error>  <Code>RequestTimeTooSkewed</Code>  <Message>The difference between the request time and the current time is too large.</Message>  <RequestId>58F6D89ECBB6F0795271EEBA</RequestId>  <HostId>test.oss-cn-hangzhou.aliyuncs.com</HostId>  <MaxAllowedSkewMilliseconds>900000</MaxAllowedSkewMilliseconds>  <RequestTime>2017-04-19T04:21:16.000Z</RequestTime>  <ServerTime>2017-04-19T03:25:18.000Z</ServerTime></Error>[ERR] curl.cpp:CheckBucket(2625): Check bucket failed, OSS response: <?xml version="1.0" encoding="UTF-8"?><Error>  <Code>RequestTimeTooSkewed</Code>  <Message>The difference between the request time and the current time is too large.</Message>  <RequestId>58F6D89ECBB6F0795271EEC1</RequestId>  <HostId>test.oss-cn-hangzhou.aliyuncs.com</HostId>  <MaxAllowedSkewMilliseconds>900000</MaxAllowedSkewMilliseconds>  <RequestTime>2017-04-19T04:21:16.000Z</RequestTime>  <ServerTime>2017-04-19T03:25:18.000Z</ServerTime></Error>[CRT] s3fs.cpp:s3fs_check_service(3690): invalid credentials - result of checking service.ossfs: Check OSS service failed. Run with -f option for more details.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
上面的错误最主要的一句话为:
The difference between the request time and the current time is too large.
  • 1
意思是请求的时间和当前的时间差异太大
尝试查看本地时间
[root@storm1 tmp]# dateWed Apr 19 16:47:47 CST 2017
  • 1
  • 2
果然差距一个小时 只需更新同步时间即可
ntpdate cn.pool.ntp.org19 Apr 15:52:39 ntpdate[71442]: step time server 51.15.41.135 offset -3357.358058 sec
  • 1
  • 2
再次挂载
ossfs test /ossfsfile -ourl=http://oss-cn-hangzhou.aliyuncs.com
  • 1
在遇到错误的时候尝试添加debug信息日志
ossfs test /ossfsfile -ourl=http://oss-cn-hangzhou.aliyuncs.com -o dbglevel=debug -f -d > /tmp/fs.log 2>&1
  • 1
查看日志信息,并解决。

全文地址请点击:https://blog.csdn.net/kane_canpo ... 160?utm_source=copy

1 个回复

倒序浏览
奈斯
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马