CentOS 7
Sponsored Link

Ceph Nautilus : Enable Object Gateway
2019/06/13
 
Enable Ceph Object Gateway (RADOSGW) to access to Ceph Cluster Storage via Amazon S3 or OpenStack Swift compatible API.
This example is based on the environment like follows.
                                         |
        +--------------------+           |           +----------------------+
        |   [dlp.srv.world]  |10.0.0.30  |  10.0.0.31| [client01.srv.world] |
        |    Ceph-Ansible    +-----------+-----------+        RADOSGW       |
        |                    |           |           |                      |
        +--------------------+           |           +----------------------+
            +----------------------------+----------------------------+
            |                            |                            |
            |10.0.0.51                   |10.0.0.52                   |10.0.0.53 
+-----------+-----------+    +-----------+-----------+    +-----------+-----------+
|   [node01.srv.world]  |    |   [node02.srv.world]  |    |   [node03.srv.world]  |
|     Object Storage    +----+     Object Storage    +----+     Object Storage    |
|     Monitor Daemon    |    |                       |    |                       |
|     Manager Daemon    |    |                       |    |                       |
+-----------------------+    +-----------------------+    +-----------------------+

[1] Enable Object Gateway on a Node which you'd like to set Object Gateway. It sets to [client01] on this exmaple.
The Ansible Playbook is existing one when creating initial setup, refer to here.
[cent@dlp ~]$
sudo vi /usr/share/ceph-ansible/group_vars/rgws.yml
# create new

# specify network interface for Object Gateway service

radosgw_interface: eth0
[cent@dlp ~]$
sudo vi /etc/ansible/hosts
# add to the end

[rgws]
client01.srv.world

[cent@dlp ~]$
cd /usr/share/ceph-ansible

[cent@dlp ceph-ansible]$
ansible-playbook site.yml --limit=rgws

.....
.....
PLAY RECAP *********************************************************************
client01.srv.world              : ok=162  changed=12   unreachable=0    failed=0    skipped=258  rescued=0    ignored=0


INSTALLER STATUS ***************************************************************
Install Ceph RGW            : Complete (0:01:02)
Install Ceph Client         : Complete (0:00:24)
.....
.....

# verify working (OK if following result is shown)

[cent@dlp ~]$
curl client01.srv.world:8080

<?xml version="1.0" encoding="UTF-8"?><ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>anonymous</ID><DisplayName></DisplayName></Owner><Buckets></Buckets></ListAllMyBucketsResult>
[2] On Object Gateway Node, Create a S3 compatible user who can authenticate to Object Gateway.
# for example, create [serverworld] user

[cent@client01 ~]$
sudo radosgw-admin user create --uid=serverworld --display-name="Server World" --email=admin@srv.world

{
    "user_id": "serverworld",
    "display_name": "Server World",
    "email": "admin@srv.world",
    "suspended": 0,
    "max_buckets": 1000,
    "subusers": [],
    "keys": [
        {
            "user": "serverworld",
            "access_key": "S8EJUA8O6N0YEIZM0YB9",
            "secret_key": "6zg4AhwYwptTjXBQot32a3qSCiAoyTASxjynBrBZ"
        }
    ],
    "swift_keys": [],
    "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": []
}

# show user list

[root@client01 ~]#
sudo radosgw-admin user list

[
    "serverworld"
]

[root@client01 ~]#
sudo radosgw-admin user info --uid=serverworld

{
    "user_id": "serverworld",
    "display_name": "Server World",
    "email": "admin@srv.world",
    "suspended": 0,
    "max_buckets": 1000,
    "subusers": [],
    "keys": [
        {
            "user": "serverworld",
            "access_key": "S8EJUA8O6N0YEIZM0YB9",
            "secret_key": "6zg4AhwYwptTjXBQot32a3qSCiAoyTASxjynBrBZ"
.....
.....
[3] Verify accessing with S3 interface to create Python test script on a Computer.
[root@dlp ~]#
yum -y install python-boto
[root@dlp ~]#
vi s3_test.py
import sys
import boto
import boto.s3.connection

# user's access-key and secret-key you added on [2] section
ACCESS_KEY = 'S8EJUA8O6N0YEIZM0YB9'
SECRET_KEY = '6zg4AhwYwptTjXBQot32a3qSCiAoyTASxjynBrBZ'

# Object Gateway's hostname and listeing port
HOST = 'client01.srv.world'
PORT = 8080

conn = boto.connect_s3(
    aws_access_key_id = ACCESS_KEY,
    aws_secret_access_key = SECRET_KEY,
    port = PORT,
    host = HOST,
    is_secure = False,
    calling_format = boto.s3.connection.OrdinaryCallingFormat(),
)

# create [my-new-bucket] bucket
bucket = conn.create_bucket('my-new-bucket')

# list own bucket list
for bucket in conn.get_all_buckets():
    print "{name}\t{created}".format(
        name = bucket.name,
        created = bucket.creation_date,
    )

[root@dlp ~]#
python s3_test.py

my-new-bucket 2019-06-13T05:37:13.653Z
Matched Content