zoukankan      html  css  js  c++  java
  • ceph高可用分布式存储集群12-S3cmd详解

    S3cmd(s3cmd)是免费的命令行工具和客户端,用于在Amazon S3和其他使用S3协议的云存储服务提供商(例如Google Cloud Storage或DreamHost DreamObjects)中上载,检索和管理数据。最适合熟悉命令行程序的高级用户。它也是批处理脚本和自动备份到S3(由cron等触发)的理想选择。

    S3cmd用Python编写。它是根据GNU公共许可证v2(GPLv2)提供的一个开源项目,可免费用于商业和私人用途。您只需要向Amazon支付使用其存储的费用。

    自S3cmd于2008年首次发布以来,它已添加了许多功能和选项。…我们最近统计了60多个命令行选项,包括分段上传,加密,增量备份,s3同步,ACL和元数据管理,S3存储桶大小,存储桶政策以及更多内容!

    一:安装方法

    yum install s3cmd -y

    二:使用方法

    通过s3cmd —help查看具体使用方法;
    1.配置Access Key ID 和 Secret Access Key
    s3cmd —configure
    2.列举所有的Buckets
    s3cmd ls
    3.创建 bucket,且 bucket 名称是唯一的,不能重复。
    s3cmd mb s3://my-bucket-name
    4.删除空 bucket
    s3cmd rb s3://my-bucket-name
    5.列举 Bucket 中的内容
    s3cmd ls s3://my-bucket-name
    6.上传 file.txt 到某个 bucket
    s3cmd put file.txt s3://my-bucket-name/file.txt
    7.上传并将权限设置为所有人可读
    s3cmd put —acl-public file.txt s3://my-bucket-name/file.txt
    8.批量上传文件
    s3cmd put ./ s3://my-bucket-name/
    9.下载文件
    s3cmd get s3://my-bucket-name/file.txt file.txt
    10.批量下载
    s3cmd get s3://my-bucket-name/
     ./
    11.删除文件
    s3cmd del s3://my-bucket-name/file.txt
    12.来获得对应的bucket所占用的空间大小
    s3cmd du -H s3://my-bucket-name

    三:文件夹处理规则

    带”/“斜杠的 dir1,相当于上传yh目录下的所有文件,即类似 “cp ./ “
    $ s3cmd put -r yh s3://yaohong-bucket
    四:同步方法
    1.同步当前目录下所有文件
    s3cmd sync ./ s3://yaohong-bucket/
    2.加 “—dry-run”参数后,仅列出需要同步的项目,不实际进行同步。
    s3cmd sync —dry-run ./ s3://my-bucket-name/
    3.加 “ —delete-removed”参数后,会删除本地不存在的文件。
    s3cmd sync —delete-removed ./ s3://my-bucket-name/
    4.加 “ —skip-existing”参数后,不进行MD5校验,直接跳过本地已存在的文件。
    s3cmd sync —skip-existing ./ s3://my-bucket-name/
    高级同步
    排除、包含规则(—exclude 、—include)
    file1-1.txt被排除,file2-2.txt同样是txt格式却能被包含
    $ 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
    从文件中载入排除或包含规则。(—exclude-from、—include-from)
    s3cmd sync —exclude-from pictures.exclude ./ s3://my-bucket-name/
    排除或包含规则支持正则表达式
    —rexclude 、—rinclude、—rexclude-from、—rinclude-from

    作者:Dexter_Wang   工作岗位:某互联网公司资深云计算与存储工程师  联系邮箱:993852246@qq.com

  • 相关阅读:
    八款常用的 Python GUI 开发框架推荐
    scrapy + mogoDB 网站爬虫
    tkinter界面卡死的解决办法
    通过核心API启动单个或多个scrapy爬虫
    爬虫怎样绕过验证码?
    Python爬虫入门教程 33-100 电影评论数据抓取 scrapy
    Python开发 之 Websocket 的使用示例
    StringBuffer详解
    其实python正则表达式就这样简单明了
    ABAP和Java里的单例模式攻击
  • 原文地址:https://www.cnblogs.com/dexter-wang/p/14962812.html
Copyright © 2011-2022 走看看