云存储命令行工具---libs3

ceph 的客户端有很多,有s3cmd、cloudberryExplorer等,今天介绍另一个libs3

一、 安装

Libs3是RGW s3接口的命令行工具,与s3cmd类似,使用C++生成。

1、 包的获取

https://github.com/bji/libs3,clone or download即可

2、 在centos上安装一些库文件

yum install libcurl* libxml2*.

3、 将包放到centos上,解压,安装

unzip libs3-master.zip
cd libs3-master
make && make install
ldconfig

ldconfig作用是让动态链接库为系统所共享

二、 常见使用

1、 帮助

直接输入s3就有帮助出来

2、 设置accesskey等

安装完s3后,需要设置环境变量,如下:

export S3_ACCESS_KEY_ID=F5VGVPII3G9R1T8JYC2Z
export S3_SECRET_ACCESS_KEY=OpMn7JxGrKdMziRkY82oFurbfRmZLPm5qNxb3dHE
export S3_HOSTNAME=10.3.0.1(你的rgw接口IP)

3、 常用命令:

查看buckets

# s3 -u list
Bucket Created 
-------------------------------------------------------- --------------------
new 2016-10-19T02:44:55Z
xfdfd 2016-10-18T23:05:54Z

-u表示使用http,没有-u使用https

查看bucket下objects

# s3 -u list xfdfd
Key Last Modified Size 
-------------------------------------------------- -------------------- -----
Comments.txt 2016-10-19T01:14:02Z 67
apache-jmeter-2.13.zip 2016-10-19T02:09:27Z 35M
apache-jmeter-3.0.zip 2016-10-19T02:27:15Z 45M
ffmpeg-2.7.2-1.x86_64.rpm 2016-10-19T18:47:46Z 7.01M
security_test_report.html 2016-10-19T01:14:02Z 38580

创建bucket

# s3 -u create test

创建一个test的bucket

上传object

# s3 -u put new/ffmpeg-2.7.2-1.x86_64.rpm filename=ffmpeg-2.7.2-1.x86_64.rpm 

在new这个bucket下上传文件ffmpeg-2.7.2-1.x86_64.rpm

如果你不想看到进度,可以加noStatus=true 屏蔽

 如:

s3 -u  put bucket1/xxxx filename=xxxx noStatus=true

查看分片上传信息:

# s3 -u listmultiparts new

中断上传

# s3 -u abortmp new/object upload-id=xxxxx

拷贝

# s3 -u copy new/100MB.bin new2/100MB.bin

获取文件

# s3 -u get new/cosbench-master.zip -s filename=ss.zip


删除文件

# s3 -u delete new/ffmpeg-2.7.2-1.x86_64.rpm
原文地址:https://www.cnblogs.com/landhu/p/5981654.html