Ceph rgws客户端验证

修改/etc/ceph/ceph.conf文件,加入rados gw监听的端口

[client.rgw.rgws]
rgw_frontends = "civetweb port=80"

拷贝到各台机器上,然后在gateway上重新启动服务。

如果不知道具体的服务是什么,可以通过以下命令查看

[root@rgws ~]# systemctl list-units --type=service
UNIT                               LOAD   ACTIVE SUB     DESCRIPTION
auditd.service                     loaded active running Security Auditing Service
ceph-radosgw@rgw.rgws.service      loaded active running Ceph rados gateway
crond.service                      loaded active running Command Scheduler
dbus.service                       loaded active running D-Bus System Message Bus

重启完成,在客户端应该能通过curl访问

[root@cephclient ~]# curl http://rgws:80
<?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>

客户端安装python-boto

subscription-manager repos --enable=rhel-7-server-rh-common-rpms
sudo yum install python-boto

注册用户生成access_key和secret_key

radosgw-admin user create --uid="testuser" --display-name="First User"

{
    "user_id": "testuser",
    "display_name": "First User",
    "email": "",
    "suspended": 0,
    "max_buckets": 1000,
    "auid": 0,
    "subusers": [],
    "keys": [
        {
            "user": "testuser",
            "access_key": "4BV16CHJPD5T70FMFWFQ",
            "secret_key": "Q1ijCbo7RGAbWOebxNdimn85IDqc58qYBpTIrC5U"
        }
    ],
    "swift_keys": [],
    "caps": [],
    "op_mask": "read, write, delete",
    "default_placement": "",
    "placement_tags": [],
    "bucket_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": -1,

然后建立一个测试文件

[root@cephclient ~]# cat s3test.py 
import boto
import boto.s3.connection

access_key = "4BV16CHJPD5T70FMFWFQ"
secret_key = "Q1ijCbo7RGAbWOebxNdimn85IDqc58qYBpTIrC5U"

boto.config.add_section('s3')
boto.config.set('s3', 'use-sigv4', 'True')

conn = boto.connect_s3(
        aws_access_key_id = access_key,
        aws_secret_access_key = secret_key,
        host = 'rgws',
        port = 80,
        is_secure=False,
        calling_format = boto.s3.connection.OrdinaryCallingFormat(),
        )

conn.auth_region_name = 'public'

bucket = conn.create_bucket('my-new-bucket')
for bucket in conn.get_all_buckets():
    print "{name}	{created}".format(
        name = bucket.name,
        created = bucket.creation_date,
)

测试运行

[root@cephclient ~]# python s3test.py
my-new-bucket    2019-02-24T15:22:53.492Z
原文地址:https://www.cnblogs.com/ericnie/p/10382187.html