1、安装s3cmd
# yum -y install s3cmd
2、创建s3用户
# radosgw-admin user create --uid=admin --access-key=123456 --secret-key=123456 --display-name=admin{"user_id": "admin","display_name": "admin","email": "","suspended": 0,"max_buckets": 1000,"auid": 0,"subusers": [],"keys": [{"user": "admin","access_key": "123456","secret_key": "123456"}],"swift_keys": [],"caps": [],"op_mask": "read, write, delete","default_placement": "","placement_tags": [],"bucket_quota": {"enabled": false,"check_on_raw": false,"max_size": -1,"max_size_kb": 0,"max_objects": -1},"user_quota": {"enabled": false,"check_on_raw": false,"max_size": -1,"max_size_kb": 0,"max_objects": -1},"temp_url_keys": [],"type": "rgw"}
3、配置s3cmd
在root目录下创建.s3cfg文件,并写入以下内容[root@node1 ~]# vim .s3cfg[default]access_key = 123456bucket_location = UScloudfront_host = 192.168.1.10:8080cloudfront_resource = /2010-07-15/distributiondefault_mime_type = binary/octet-streamdelete_removed = Falsedry_run = Falseencoding = UTF-8encrypt = Falsefollow_symlinks = Falseforce = Falseget_continue = Falsegpg_command = /usr/bin/gpggpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)sgpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)sgpg_passphrase =guess_mime_type = Truehost_base = 192.168.1.10:8080host_bucket = 192.168.1.10:8080/%(bucket)human_readable_sizes = Falselist_md5 = Falselog_target_prefix =preserve_attrs = Trueprogress_meter = Trueproxy_host =proxy_port = 0recursive = Falserecv_chunk = 4096reduced_redundancy = Falsesecret_key = 123456send_chunk = 96simpledb_host = sdb.amazonaws.comskip_existing = Falsesocket_timeout = 300urlencoding_mode = normaluse_https = Falseverbosity = WARNINGsignature_v2 = True
在上面的配置中需要进行修改的配置项为
cloudfront_hosthost_basehost_bucketaccess_keysecret_key
s3cmd 操作
1、创建bucket
s3cmd mb s3://testBucket 's3://test/' created
2、上传object
# s3cmd put osd.sh s3://testupload: 'osd.sh' -> 's3://test/osd.sh' [1 of 1]1472 of 1472 100% in 2s 628.87 B/s done
3、查看bucket
# s3cmd ls2018-07-03 08:32 s3://test
4、查看指定bucket内的object
# s3cmd ls s3://test2018-07-03 08:58 1472 s3://test/osd.sh
5、下载文件到本地
# s3cmd get s3://test/osd.sh test.shdownload: 's3://test/osd.sh' -> 'test.sh' [1 of 1]1472 of 1472 100% in 0s 153.24 kB/s done
6、删除object
# s3cmd rm s3://test/osd.shdelete: 's3://test/osd.sh'
7、删除bucket
# s3cmd rb s3://test/Bucket 's3://test/' removed
