1:安装和配置s3cmd
yum install s3cmd -y
2:配置s3cmd进行S3接口测试,初始化 s3cmd本地环境 将之前radosgw-admin创建的user的access_key和secret_key,根据本机实际进行赋值;
有些不知道什么意思,没有进行修改,但是s3cmd ls可以使用,所以后续再跟进着修改吧
注意更改access_key,host_base ,host_bucket ,secret_key
cloudfront:用到了边缘计算的概念,是类似于CDN,提供全球的内容分发服务,它在全球都有很多edge location,使你的客户能最小延迟的拿到数据。
原理:当你配置一个origin,CloudFront会在请求来的时候根据配置去相应的origin拿数据,并缓存到各个edge location。下次客户就直接在最近的edge location拿数据。Origin可以是Amazon S3 buckets,也可以是自己的Web Servers。你给客户的就是一个cloudfront.NET的域名。CloudFront确保每一次请求都是最近的edge location服务的。变化传播到全球的各个edge location需要15分钟左右。如果没有 cache control header的话,CloudFront默认会在24小时之后来的请求进行一次版本更新。注意CloudFront目前最大支持20GB的单个文件大小。CloudFront还允许你配置在全球的哪几个edge location进行服务,这样可以减少变化传播的时间和实际花费。CloudFront比CDN的优势在于快速的内容分发,不需要先于CDN建立合同等繁琐的过程,比较利于一个项目的启动。
simpledb_host:简单的数据库存储解决方案,它可以让开发人员利用通过Web服务请求方便地存储和查询数据项,从而节省时间。
[default]
access_key = 2BUU4SZFRDRADBJQBJ0B
access_token =
add_encoding_exts =
add_headers =
bucket_location = US
ca_certs_file =
cache_file =
check_ssl_certificate = True
check_ssl_hostname = True
cloudfront_host = 10.3.194.240:8086 #这里可以是cloudfront.amazonaws.com????
default_mime_type = binary/octet-stream
delay_updates = False
delete_after = False
delete_after_fetch = False
delete_removed = False
dry_run = False
enable_multipart = True
encoding = UTF-8
encrypt = False
expiry_date =
expiry_days =
expiry_prefix =
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 = 10.3.194.240:8086
host_bucket = 10.3.194.240:8086 #这里不知道有没有配置对,但是可以使用,先不管
human_readable_sizes = False
invalidate_default_index_on_cf = False
invalidate_default_index_root_on_cf = True
invalidate_on_cf = False
kms_key =
limitrate = 0
list_md5 = False
log_target_prefix =
long_listing = False
max_delete = -1
mime_type =
multipart_chunk_size_mb = 15
multipart_max_chunks = 10000
preserve_attrs = True
progress_meter = True
proxy_host =
proxy_port = 0
put_continue = False
recursive = False
recv_chunk = 4096
reduced_redundancy = False
requester_pays = False
restore_days = 1
secret_key = 3wrDcH222S4uplwGJa3Ua8VV7WkToLZ8t8DKqnuc
send_chunk = 4096
server_side_encryption = False
signature_v2 = False
simpledb_host = 10.3.194.240:8086 # sdb.amazonaws.com #这里还有待后续补充
skip_existing = False
socket_timeout = 10
stats = False
stop_on_error = False
storage_class =
urlencoding_mode = normal
use_https = False
use_mime_magic = True
verbosity = WARNING
website_endpoint = 10.3.194.240:8086
website_error =
website_index = index.html
3、s3cmd --configure
全部默认,遇到可选项选择y
4、s3cmd部分调试命令
常见命令
1)帮助命令:
s3cmd --help
2)创建一个名为bucket1的bucket:
s3cmd mb s3://bucket1
3)将bucketfile1写入到rgw这个bucket中 // 将bucket1下面的1.jpg拷贝出来
s3cmd put bucketfile1 s3://bucket1 /// s3cmd get s3://bucket1/1.jpg ./
4)列出rgw这个bucket中的文件列表:
s3cmd ls s3://bucket1
2017-08-17 01:59 150782 s3://bucket1/1.jpg
2017-08-17 02:05 105840 s3://bucket1/2.png
2017-08-17 02:05 913 s3://bucket1/网站.txt5)读取bucket中的1.jpg文件到本地:
s3cmd get s3://bucket1/1.jpg ./
6)得到对应的bucket所占用空间的大小
s3cmd du -H s3://bucket1
251k 3 objects s3://bucket1/
7)删除文件
s3cmd del s3://bucket1/1.jpg
8)批量整个桶文件下载
s3cmd get s3://bucket1/* ./
9)批量整个文件夹上传
s3cmd put home/liangwl s3://bucket1/
10)所有bucket列举
s3cmd ls
11)上传文件并设置权限
s3cmd put --acl-public file.txt s3://bucket1/file.txt
12)上传整个目录文件python_code /home/liangwl/python_code 与/home/liangwl/python_code/ 存在区别,选择前面一种比较合适
s3cmd put -r /home/liangwl/python_code s3://bucket3/
同步操作
同步是实用的功能,同步需要进行MD5操作,只有文件不同的时候才会被传输,具体可参考官方使用说明见《s3cmd sync HowTo》http://s3tools.org/s3cmd-sync
13)将该目录下的所有文件同步到bucket中
s3cmd sync ./ s3://bucket1/
14)将某个桶中所有的文件同步出来
s3cmd sync s3://bucket3 ./
15)加 "--dry-run"参数后,仅列出需要同步的项目,不实际进行同步
s3cmd sync --dry-run ./ s3://bucket1
16)加 " --delete-removed"参数后,会删除本地不存在的文件
s3cmd sync --delete-removed ./ s3://bucket3
s3cmd sync --delete-removed --force ./ s3://bucket1
17)加 " --skip-existing"参数后,不进行MD5校验,直接跳过本地已存在的文件
s3cmd sync --skip-existing ./ s3://bucket1
高级同步
1排除、包含规则(--exclude 、--include)
file1-1.txt被排除,file2-2.txt同样是txt格式却能被包含。
~/demo$ s3cmd sync --dry-run --exclude '*.txt' --include 'dir2/*' ./ s3://my-bucket-name/
exclude: dir1/file1-1.txt
upload: ./dir2/file2-2.txt -> s3://my-bucket-name/dir2/file2-2.txt
2从文件中载入排除或包含规则。(--exclude-from、--include-from)
s3cmd sync --exclude-from pictures.exclude ./ s3://my-bucket-name/
pictures.exclude 文件内容
# Hey, comments are allowed here ;-)
*.jpg
*.gif
3排除或包含规则支持正则表达式
--rexclude 、--rinclude、--rexclude-from、--rinclude-from