08-手动部署Ceph15.2.5(octopus)rgw的简单使用

基于RGW的Swift API使用

RGW的Swift API使用

1. 创建一个访问用户

bash> radosgw-admin user create --uid="ping" --subuser="ping:swift" --display-name="Dai Ping" --email=daiping_zy@139.com --access=full
bash> radosgw-admin user list               #查看有哪些用户
bash> radosgw-admin user info --uid=ping    #查看用户信息
---
{
    "user_id": "ping",
    "display_name": "Dai Ping",
    "email": "daiping_zy@139.com",
    "suspended": 0,
    "max_buckets": 1000,
    "subusers": [
        {
            "id": "ping:swift",
            "permissions": "full-control"
        }
    ],
    "keys": [
        {
            "user": "ping",
            "access_key": "O970LW7W6LF6AOPP9490",
            "secret_key": "RtlTkeLYS00AewlGVgCaUeRKeMpmBSW7RhkojShA"
        }
    ],
    "swift_keys": [
        {
            "user": "ping:swift",
            "secret_key": "1ryjKfCAykfCkgAY6Zp7FaPGonRNZ5ZgsK6QU4YY"
        }
    ],
    "caps": [],
    "op_mask": "read, write, delete",
    "default_placement": "",
    "default_storage_class": "",
    "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",
    "mfa_ids": []
}

2. 部份Swift的常用的接口列表

使用流程.png

Swift用户认证

请求信息:
    GET http://192.168.10.42:3245/auth
    Reauest Headers(头部信息中需要添加以下字段):
        X-Auth-User: ping:swift
        X-Auth-Key: 1ryjKfCAykfCkgAY6Zp7FaPGonRNZ5ZgsK6QU4YY
返回信息:
    Status Code: 204 No Content
    connection: Keep-Alive
    content-type: application/json; charset=utf-8
    date: Wed, 04 Nov 2020 02:57:18 GMT
    x-auth-token: AUTH_rgwtk0a00000070696e673a7377696674b7bd00b43a6987cd0e6aa35fb3bd9711e3a4d39b55f5300dccc227061bd7de6a7a1963d3
    x-openstack-request-id: tx000000000000000000114-005fa2188e-20bdb-default
    x-storage-token: AUTH_rgwtk0a00000070696e673a7377696674b7bd00b43a6987cd0e6aa35fb3bd9711e3a4d39b55f5300dccc227061bd7de6a7a1963d3
    x-storage-url: http://192.168.10.42:3245/swift/v1
    x-trans-id: tx000000000000000000114-005fa2188e-20bdb-default
说明:
    返回信息Headers中的 “x-auth-token”,用在于在其它接口中使用,需要保存下来。每次认证该token则会更新。

存储桶相关操作-↓

Amazon S3 API使用术语“存储桶”来描述数据容器。当您听到有人在Swift API中引用“存储桶”时,“存储桶”一词可能会被解释为与“容器”一词等效。

创建存储桶:

    PUT http://192.168.10.42:3245/swift/v1/{container} 
    Reauest Headers(头部信息中需要添加以下字段):
        X-Auth-Token: {auth-token}
        X-Container-Read: {comma-separated-uids}    #Required No,允许其他人读
        X-Container-Write: {comma-separated-uids}   #Required No,允许其他人写
        X-Container-Meta-{key}: {value}             #Required No

获取存储桶下的对象列表:

    GET http://192.168.10.42:3245/swift/v1/{container}
    Reauest Headers(头部信息中需要添加以下字段):
        X-Auth-Token: {auth-token}
    Parmameters:
    String    format              #json|xml
    String    prefix              #user def
    String    marker              #Returns a list of results greater than the marker value.
    Integer   limit               #Limits the number of results to the specified value.0 - 10,000
    String    delimiter           #The delimiter between the prefix and the rest of the object name.
    String    path                #The pseudo-hierarchical path of the objects.
    Boolean   allow_unordered     #允许无序返回结果,与delimiter排斥

存储桶访问列表修改(允许其他人访问自己的存储桶):

    POST  http://192.168.10.42:3245/swift/v1/{container}
    Reauest Headers(头部信息中需要添加以下字段):
        X-Auth-Token: {auth-token}
        X-Container-Read: *
        X-Container-Write: {uid1}, {uid2}, {uid3}

删除存储桶:

    DELETE  http://192.168.10.42:3245/swift/v1/{container}
    Reauest Headers(头部信息中需要添加以下字段):
        X-Auth-Token: {auth-token}

对象相关操作

创建/更新一个对象(Object):

    PUT http://192.168.10.42:3245/swift/v1/{container}/{object} HTTP/1.1
    Reauest Headers(头部信息中需要添加以下字段):
        X-Auth-Token: {auth-token}
        ETag            #An MD5 hash of the object’s contents. Recommended.
        Content-Type    #The type of content the object contains.
        Transfer-Encoding   #Indicates whether the object is part of a larger aggregate object. Valid Values: chunked
    BODY为对象内容

复制一个对象:

    PUT http://192.168.10.42:3245/swift/v1/{dest-container}/{dest-object}
    Reauest Headers(头部信息中需要添加以下字段):
        X-Copy-From: {source-container}/{source-object}
        X-Auth-Token: {auth-token}
--或者:
    COPY http://192.168.10.42:3245/swift/v1/{source-container}/{source-object}
    Reauest Headers(头部信息中需要添加以下字段):
        Destination: {dest-container}/{dest-object}
        X-Auth-Token: {auth-token}
----
    可选header信息:
        Copy-If-Match
        Copy-If-None-Match

删除一个对象:

    DELETE http://192.168.10.42:3245/swift/v1/{container}/{object} 
    Reauest Headers(头部信息中需要添加以下字段):
        X-Auth-Token: {auth-token}

获取一个对象:

    GET http://192.168.10.42:3245/swift/v1/{container}/{object}
    Reauest Headers(头部信息中需要添加以下字段):
        X-Auth-Token: {auth-token}
----
    可选header信息:
        range   #To retrieve a subset of an object’s contents, you may specify a byte range.
        If-Modified-Since   #Only copies if modified since the date/time of the source object’s last_modified attribute.
        If-Unmodified-Since #Only copies if not modified since the date/time of the source object’s last_modified attribute.
        Copy-If-Match       #Copies only if the ETag in the request matches the source object’s ETag.
        Copy-If-None-Match  #Copies only if the ETag in the request does not match the source object’s ETag.

Ceph 15.25 手动部署系列笔记

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,919评论 6 502
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,567评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,316评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,294评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,318评论 6 390
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,245评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,120评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,964评论 0 275
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,376评论 1 313
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,592评论 2 333
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,764评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,460评论 5 344
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,070评论 3 327
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,697评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,846评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,819评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,665评论 2 354