SeaweedFS学习笔记:S3-API


SeaweedFS可以兼容Amazon S3 API。

1. 实现机制

weed s3 命令可以启动一个无状态的gateway去作为Amazon S3 API和SeaweedFS Filer之间的桥梁。
S3的每个桶对应SeaweadFS的一个Collection。

2. 支持更多的桶

S3每个桶都有自己的Collection,通常来说一个Collection需要使用7个Volume,每个Volume默认最大size是30GB, 如果创建很多个桶,建议把Volume的最大size调小或者限制Volume的增长速度,否则Volume很快就会耗尽。

2.1 Volume的最大size调小

-volumeSizeLimitMB, weed master 命令行选项

2.2 限制Volume的增长速度

-volumeGrowthCountweed shell 参数,

fs.configure -locationPrefix=/buckets/ -volumeGrowthCount=1 -apply

如果启动的replication,则需要更多的volume,volume的增长需要稍微调大,例如replication为001时,volumeGrowthCount则应不小于2。

 fs.configure -locationPrefix=/buckets/ -replication=001 -volumeGrowthCount=2 -apply

3. 启动S3 gateway服务

./weed s3 # 单独启动一个s3 gateway服务

./weed filer -s3 #启动filer服务的时候同时启动s3 gateway服务,两个服务在同一个进程

S3 gateway服务的默认端口为8333。

4. 通过s3cmd操作SeaweedFS

4.1 s3cmd的安装

参考:https://s3tools.org/download

4.2 配置

s3cmd --configure

...

New settings:
	  Access Key: any_no_empty_key
  Secret Key: any_no_empty_key
  Default Region: US
  S3 Endpoint: localhost:8333
  DNS-style bucket+hostname:port template for accessing a bucket: localhost:8333
  Encryption password:
  Path to GPG program: /usr/local/bin/gpg
  Use HTTPS protocol: False
  HTTP Proxy server name:
  HTTP Proxy server port: 0

在命令行执行s3cmd --configure
S3 Endpoint 填写 S3 gateway 的地址,默认为localhost:8333。

4.3 s3cmd使用案例

# 创建桶
$ s3cmd mb s3://newbucket
Bucket 's3://newbucket/' created

# 查看桶的列表
$ s3cmd ls s3://
2019-01-01 01:30  s3://newbucket

# 上传文件到桶
$ s3cmd put /etc/passwd s3://newbucket
WARNING: Module python-magic is not available. Guessing MIME types based on file extensions.
upload: '/etc/passwd' -> 's3://newbucket/passwd'  [1 of 1]
 6804 of 6804   100% in    0s    87.93 kB/s  done

# 下载文件到本地
$ s3cmd get s3://newbucket/passwd
download: 's3://newbucket/passwd' -> './passwd'  [1 of 1]
 6804 of 6804   100% in    0s   595.33 kB/s  done

# 修改本地文件
$ vi passwd

# 同步本地文件到桶
$ s3cmd sync passwd s3://newbucket/
WARNING: Module python-magic is not available. Guessing MIME types based on file extensions.
upload: 'passwd' -> 's3://newbucket/passwd'  [1 of 1]
 22 of 22   100% in    0s     6.45 kB/s  done
Done. Uploaded 22 bytes in 1.0 seconds, 22.00 B/s.

# 查看桶的文件列表
$ s3cmd ls s3://newbucket/
2019-01-01 01:32         22   s3://newbucket/passwd

# 删除桶的文件
$ s3cmd del s3://newbucket/passwd
delete: 's3://newbucket/passwd'

# 删除桶
$ s3cmd rb s3://newbucket
Bucket 's3://newbucket/' removed


5. 参考文档下载

《小文件存储SeaweedFS技术指南》

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

修破立生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值