美文网首页Ceph
【ceph】安装-对象存储rgw

【ceph】安装-对象存储rgw

作者: 小醉90s | 来源:发表于2018-12-07 17:18 被阅读0次

    简介
    安装rgw对象存储网关并创建用户和桶

    部署rgw

    ceph-deploy rgw create ceph-object-01  ceph-object-02 ceph-object-03
    

    创建池

    # 需要创建的池
    # cat pool.txt
    .rgw.root
    
    # 池创建脚本
    # cat create_pool.sh
    #!/bin/bash
    
    PG_NUM=10
    PGP_NUM=10
    SIZE=3
    
    for i in `cat ./pool`
            do
            ceph osd pool create $i $PG_NUM
            ceph osd pool set $i size $SIZE
            done
    
    for i in `cat ./pool`
            do
            ceph osd pool set $i pgp_num $PGP_NUM
            done
    
    # 创建池
    sh create_pool.sh
    

    重启网关

    systemctl restart ceph-radosgw.service
    

    测试访问ceph集群

    ceph -s -k /var/lib/ceph/radosgw/ceph-rgw.ceph-object-01/keyring --name client.rgw.ceph-object-01
    
      cluster:
        id:     44af5ebf-c482-4e09-8800-7134126de6a7
        health: HEALTH_OK
     
      services:
        mon: 3 daemons, quorum ceph-object-01,ceph-object-02,ceph-object-03
        mgr: ceph-object-01(active), standbys: ceph-object-02, ceph-object-03
        osd: 3 osds: 3 up, 3 in
        rgw: 3 daemons active
     
      data:
        pools:   17 pools, 162 pgs
        objects: 187 objects, 1.09KiB
        usage:   3.02GiB used, 2.72TiB / 2.73TiB avail
        pgs:     162 active+clean
    

    创建radosgw用户

    # radosgw-admin user create --uid=radosgw --display-name="radosgw"
    
    {
        "user_id": "radosgw",
        "display_name": "radosgw",
        "email": "",
        "suspended": 0,
        "max_buckets": 1000,
        "auid": 0,
        "subusers": [],
        "keys": [
            {
                "user": "radosgw",
                "access_key": "43HWEBWEQWMOO8KWDLGR",
                "secret_key": "KI3CsIJ1MF9VIkIh70OII59OOQ4BZzlbZyqamvf3"
            }
        ],
        "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"
    }
    
    

    注意:请把access_key和secret_key保存下来,如果忘记可以使用:radosgw-admin user info –uid … -k … --name …

    安装s3cmd客户端
    yum -y install s3cmd

    在家目录下创建.s3cfg

    # s3cmd --configure
    
    Enter new values or accept defaults in brackets with Enter.
    Refer to user manual for detailed description of all options.
    
    Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables.
    Access Key: OAOGLIF4DWUUXJGKPJ6J
    Secret Key: kJ3SyUCZM4dfRml6Fue6OjvB1WAKTAvLTnirWfYE
    Default Region [US]: 
    
    Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3.
    S3 Endpoint [s3.amazonaws.com]: 
    
    Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be used
    if the target S3 system supports dns based buckets.
    DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]: 
    
    Encryption password is used to protect your files from reading
    by unauthorized persons while in transfer to S3
    Encryption password: 
    Path to GPG program [/usr/bin/gpg]: 
    
    When using secure HTTPS protocol all communication with Amazon S3
    servers is protected from 3rd party eavesdropping. This method is
    slower than plain HTTP, and can only be proxied with Python 2.7 or newer
    Use HTTPS protocol [Yes]: no   
    
    On some networks all internet access must go through a HTTP proxy.
    Try setting it here if you can't connect to S3 directly
    HTTP Proxy server name: 
    
    New settings:
      Access Key: OAOGLIF4DWUUXJGKPJ6J
      Secret Key: kJ3SyUCZM4dfRml6Fue6OjvB1WAKTAvLTnirWfYE
      Default Region: US
      S3 Endpoint: s3.amazonaws.com
      DNS-style bucket+hostname:port template for accessing a bucket: %(bucket)s.s3.amazonaws.com
      Encryption password: 
      Path to GPG program: /usr/bin/gpg
      Use HTTPS protocol: False
      HTTP Proxy server name: 
      HTTP Proxy server port: 0
    
    Test access with supplied credentials? [Y/n] n
    
    Save settings? [y/N] y
    Configuration saved to '/root/.s3cfg'
    

    编辑.s3cfg文件,修改host_base和host_bucket

    # cat /root/.s3cfg 
    [default]
    access_key = OAOGLIF4DWUUXJGKPJ6J
    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 = ceph-object-01:7480
    content_disposition = 
    content_type = 
    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
    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 = ceph-object-01:7480
    host_bucket = %(bucket)s.ceph-object-01:7480
    human_readable_sizes = False
    invalidate_default_index_on_cf = False
    invalidate_default_index_root_on_cf = True
    invalidate_on_cf = False
    kms_key = 
    limit = -1
    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 = 65536
    reduced_redundancy = False
    requester_pays = False
    restore_days = 1
    restore_priority = Standard
    secret_key = kJ3SyUCZM4dfRml6Fue6OjvB1WAKTAvLTnirWfYE
    send_chunk = 65536
    server_side_encryption = False
    signature_v2 = False
    signurl_use_https = False
    simpledb_host = sdb.amazonaws.com
    skip_existing = False
    socket_timeout = 300
    stats = False
    stop_on_error = False
    storage_class = 
    throttle_max = 100
    upload_id = 
    urlencoding_mode = normal
    use_http_expect = False
    use_https = False
    use_mime_magic = True
    verbosity = WARNING
    website_endpoint = http://%(bucket)s.s3-website-%(location)s.ceph-object-01:7480/
    website_error = 
    website_index = index.html
    

    说明:
    host_base:主机端口
    host_bucket:存储空间
    cloudfront_host:
    website_endpoint:访问域名

    创建桶并放入文件

    # s3cmd mb s3://First-bucket
    Bucket 's3://First-bucket/' created
    # s3cmd ls
    # s3cmd put -r /root/my-cluster s3://First-bucket
    # s3cmd ls s3://First-bucket/my-cluster/
                           DIR   s3://First-bucket/my-cluster/backup/
                           DIR   s3://First-bucket/my-cluster/rgw/
    2018-12-05 13:07     88714   s3://First-bucket/my-cluster/ceph-deploy-ceph.log
    2018-12-05 13:07        71   s3://First-bucket/my-cluster/ceph.bootstrap-mds.keyring
    2018-12-05 13:07        71   s3://First-bucket/my-cluster/ceph.bootstrap-mgr.keyring
    2018-12-05 13:07        71   s3://First-bucket/my-cluster/ceph.bootstrap-osd.keyring
    2018-12-05 13:07        71   s3://First-bucket/my-cluster/ceph.bootstrap-rgw.keyring
    2018-12-05 13:07        63   s3://First-bucket/my-cluster/ceph.client.admin.keyring
    2018-12-05 13:07       259   s3://First-bucket/my-cluster/ceph.conf
    2018-12-05 13:07        73   s3://First-bucket/my-cluster/ceph.mon.keyring
    

    相关文章

      网友评论

        本文标题:【ceph】安装-对象存储rgw

        本文链接:https://www.haomeiwen.com/subject/cgqxhqtx.html