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 = 123456
bucket_location = US
cloudfront_host = 192.168.1.10:8080
cloudfront_resource = /2010-07-15/distribution
default_mime_type = binary/octet-stream
delete_removed = False
dry_run = False
encoding = UTF-8
encrypt = False
follow_symlinks = False
force = False
get_continue = False
gpg_command = /usr/bin/gpg
gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
gpg_passphrase =
guess_mime_type = True
host_base = 192.168.1.10:8080
host_bucket = 192.168.1.10:8080/%(bucket)
human_readable_sizes = False
list_md5 = False
log_target_prefix =
preserve_attrs = True
progress_meter = True
proxy_host =
proxy_port = 0
recursive = False
recv_chunk = 4096
reduced_redundancy = False
secret_key = 123456
send_chunk = 96
simpledb_host = sdb.amazonaws.com
skip_existing = False
socket_timeout = 300
urlencoding_mode = normal
use_https = False
verbosity = WARNING
signature_v2 = True
在上面的配置中需要进行修改的配置项为
cloudfront_host
host_base
host_bucket
access_key
secret_key
s3cmd 操作
1、创建bucket
s3cmd mb s3://test
Bucket 's3://test/' created
2、上传object
# s3cmd put osd.sh s3://test
upload: 'osd.sh' -> 's3://test/osd.sh' [1 of 1]
1472 of 1472 100% in 2s 628.87 B/s done
3、查看bucket
# s3cmd ls
2018-07-03 08:32 s3://test
4、查看指定bucket内的object
# s3cmd ls s3://test
2018-07-03 08:58 1472 s3://test/osd.sh
5、下载文件到本地
# s3cmd get s3://test/osd.sh test.sh
download: '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.sh
delete: 's3://test/osd.sh'
7、删除bucket
# s3cmd rb s3://test/
Bucket 's3://test/' removed