openSUSE Leap 16

Ceph Reef : オブジェクトゲートウェイを設定する2025/10/28

 

Ceph Object Gateway (RADOSGW) を設定して Amazon S3 や OpenStack Swift 互換 API 経由で Ceph クラスターにアクセスできるようにします。
当例では以下のような環境で [www] ホストに RADOSGW を設定します。

                                         |
        +--------------------+           |           +----------------------+
        |   [dlp.srv.world]  |10.0.0.30  |  10.0.0.31|    [www.srv.world]   |
        |     Ceph Client    +-----------+-----------+        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] 管理ノードから RADOSGW ホストへ必要なファイルを転送して、RADOSGW の設定をします。
# 公開鍵転送

node01:~ #
ssh-copy-id www

# RADOSGW ホストに必要なパッケージをインストール

node01:~ #
ssh www "zypper -n install ceph-radosgw python313-pip"
node01:~ #
vi /etc/ceph/ceph.conf
# 最終行に追記
# client.rgw.(ノード名)
[client.rgw.www]
# ノードの IP アドレス
host = 10.0.0.31
# ノードの DNS 名
rgw dns name = www.srv.world
keyring = /var/lib/ceph/radosgw/ceph-rgw.www/keyring
log file = /var/log/ceph/radosgw.gateway.log

# RADOSGW ホストに必要なファイルを転送

node01:~ #
scp /etc/ceph/ceph.conf www:/etc/ceph/

ceph.conf                                     100%  374   210.9KB/s   00:00
node01:~ #
scp /etc/ceph/ceph.client.admin.keyring www:/etc/ceph/

ceph.client.admin.keyring                     100%  151    56.0KB/s   00:00

# RADOSGW の設定

node01:~ # ssh www \
"mkdir -p /var/lib/ceph/radosgw/ceph-rgw.www; \
ceph auth get-or-create client.rgw.www osd 'allow rwx' mon 'allow rw' -o /var/lib/ceph/radosgw/ceph-rgw.www/keyring; \
chown ceph:ceph /etc/ceph/ceph.*; \
chown -R ceph:ceph /var/lib/ceph; \
systemctl enable --now ceph-radosgw@rgw.www; \
firewall-cmd --add-port=7480/tcp; firewall-cmd --runtime-to-permanent"

# 動作確認
# 一定時間経過後に以下のような応答があれば OK

node01:~ #
curl www.srv.world:7480

<?xml version="1.0" encoding="UTF-8"?><ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>anonymous</ID></Owner><Buckets></Buckets></ListAllMyBucketsResult>
[2] Object Gateway 設定ノードで、Object Gateway に認証アクセス可能な S3 互換ユーザーを作成しておきます。
# 例として [serverworld] ユーザー作成

www:~ #
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": "NHK0CPRPVG9G7F19KJ9W",
            "secret_key": "ipZD4tLddXcg5dJ6epn6LB4o9qlj5HJQDfqQ1NBp"
        }
    ],
    "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": []
}

# ユーザーの一覧

www:~ #
radosgw-admin user list

[
    "serverworld"
]

www:~ #
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": "NHK0CPRPVG9G7F19KJ9W",
            "secret_key": "ipZD4tLddXcg5dJ6epn6LB4o9qlj5HJQDfqQ1NBp"
        }
    ],
.....
.....
[3] 任意のコンピューター/任意のユーザーで Python テストスクリプトを作成して S3 インターフェースでアクセス可能か確認します。
suse@dlp:~>
pip3 install boto3
suse@dlp:~>
vi s3_test.py
import sys
import boto3
from botocore.config import Config

# [2] で作成したユーザーのアクセスキーとシークレットキー
session = boto3.session.Session(
    aws_access_key_id = 'NHK0CPRPVG9G7F19KJ9W',
    aws_secret_access_key = 'ipZD4tLddXcg5dJ6epn6LB4o9qlj5HJQDfqQ1NBp'
)

# Object Gateway のホストとポート
s3client = session.client(
    's3',
    endpoint_url = 'http://10.0.0.31:7480',
    config = Config()
)

# [my-new-bucket] 作成
bucket = s3client.create_bucket(Bucket = 'my-new-bucket')

# Bucket 一覧表示
print(s3client.list_buckets())

# [my-new-bucket] 削除
s3client.delete_bucket(Bucket = 'my-new-bucket')

suse@dlp:~>
python3 s3_test.py

{'ResponseMetadata': {'RequestId': 'tx000005aa07a5bd101d626-00690010f1-37b0-default', 'HostId': '', 'HTTPStatusCode': 200, 'HTTPHeaders': {'transfer-encoding': 'chunked', 'x-amz-request-id': 'tx000005aa07a5bd101d626-00690010f1-37b0-default', 'content-type': 'application/xml', 'date': 'Tue, 28 Oct 2025 00:40:17 GMT', 'connection': 'Keep-Alive'}, 'RetryAttempts': 0}, 'Buckets': [{'Name': 'my-new-bucket', 'CreationDate': datetime.datetime(2025, 10, 28, 0, 40, 14, 739000, tzinfo=tzutc())}], 'Owner': {'DisplayName': 'Server World', 'ID': 'serverworld'}}
関連コンテンツ