1. 相关软件包
1.1 安装软件包
#在管理节点的工作目录下,给 Ceph 对象网关节点安装Ceph对象所需的软件包
#ceph-deploy install --rgw <node1> [<node2> ...]
$ ceph-deploy install --rgw ceph-bench-osd03.gz01
2. 管理RGW节点
2.1 添加管理节点权限
#为了让你的 Ceph 对象网关节点成为管理节点,可以在管理节点的工作目录下执行以下命令
#ceph-deploy admin <node-name>
$ cd /etc/ceph/
$ ceph-deploy admin ceph-bench-osd03.gz01
3. RGW实例
3.1 安装RGW实例
#ceph-deploy rgw create <gateway-node1>
$ ceph-deploy rgw create ceph-bench-osd03.gz01
3.2 查看服务
$ curl http://ceph-bench-osd03.gz01:7480 -v
* About to connect() to ceph-bench-osd03.gz01 port 7480 (#0)
* Trying 127.0.0.1...
* Connected to ceph-bench-osd03.gz01 (127.0.0.1) port 7480 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: ceph-bench-osd03.gz01:7480
> Accept: */*
>
< HTTP/1.1 200 OK
< x-amz-request-id: tx000000000000000000002-005a0be6f6-1e598-default
< Content-Type: application/xml
< Content-Length: 214
< Date: Wed, 15 Nov 2017 07:04:22 GMT
<
* Connection #0 to host ceph-bench-osd03.gz01 left intact
<?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>
4. S3用户
4.1 创建S3用户
#想正常的访问RGW,需要创建相应的RGW用户,并赋予相应的权限,radosgw-admin命令实现了这些功能。
#创建一个名为testuser的用户
$ radosgw-admin user create --uid="testuser" --display-name="First User"
2017-11-15 15:06:56.718127 7f33b5844c40 0 WARNING: detected a version of libcurl which contains a bug in curl_multi_wait(). enabling a workaround that may degrade performance slightly.
{
"user_id": "testuser",
"display_name": "First User",
"email": "",
"suspended": 0,
"max_buckets": 1000,
"auid": 0,
"subusers": [
{
"id": "testuser:swift",
"permissions": "full-control"
}
],
"keys": [
{
"user": "testuser",
"access_key": "GI1GHD6ZOTIVF2R24GQ6",
"secret_key": "UeEubdXgOegAqgzYRsDNPycFLE98ninUN3fFgbia"
}
],
"swift_keys": [
{
"user": "testuser:swift",
"secret_key": "cOSLCYgZzvUmIMtSngr2BG553nb3LsJ0Z7PPNgiW"
}
],
"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"
}
#ps:需要记住返回结果中keys->access_key和keys->secret_key的值,用于S3接口访问确认
4.2 测试S3接口
4.2.1 安装依赖库
#说明:需要创建一个Python测试脚本来测试S3访问。该脚本会连接RGW,创建一个bucket并列出所有的bucket。
# 其中,变量access_key和secret_access的值,来自于创建S3用户命令时,radosgw-admin命令返回的keys->access_key和keys->secret_key。
执行以下步骤,首先安装python-boto库,该库用于连接S3:
$ yum install python-boto
4.2.2 创建测试DEMO
$ cat s3_test.py
import boto.s3.connection
access_key = 'GI1GHD6ZOTIVF2R24GQ6'
secret_key = 'UeEubdXgOegAqgzYRsDNPycFLE98ninUN3fFgbia'
conn = boto.connect_s3(
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
host='ceph-bench-osd03.gz01', port=7480,
is_secure=False, calling_format=boto.s3.connection.OrdinaryCallingFormat(),
)
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,
)
4.2.3 执行测试
$ python s3_test.py
my-new-bucket 2017-10-12T08:48:36.201Z
5. Swift用户
5.1 创建Swift用户
#Swift用户是作为子用户subuser被创建的,执行以下命令
$ radosgw-admin subuser create --uid=testuser --subuser=testuser:swift --access=full
2017-11-15 15:12:11.073416 7fa91ace2c40 0 WARNING: detected a version of libcurl which contains a bug in curl_multi_wait(). enabling a workaround that may degrade performance slightly.
{
"user_id": "testuser",
"display_name": "First User",
"email": "",
"suspended": 0,
"max_buckets": 1000,
"auid": 0,
"subusers": [
{
"id": "testuser:swift",
"permissions": "full-control"
}
],
"keys": [
{
"user": "testuser",
"access_key": "GI1GHD6ZOTIVF2R24GQ6",
"secret_key": "UeEubdXgOegAqgzYRsDNPycFLE98ninUN3fFgbia"
}
],
"swift_keys": [
{
"user": "testuser:swift",
"secret_key": "96jl0Cg12T1izmD0CWKUqQFRrnjEBrJGoW2KYNUT"
}
],
"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"
}
#ps:需要记住返回结果中swift_keys->secret_key的值,用于Swift接口访问确认。
5.2 测试Swift接口
5.2.1 安装依赖包
sudo yum install python-setuptools
sudo easy_install pip
sudo pip install python-swiftclient
5.2.2 执行测试
#swift -A http://{IP ADDRESS}:{port}/auth/1.0 -U testuser:swift -K '{swift_secret_key}' list
#替换{IP ADDRESS}、{port}、{swift_secret_key}等相关参数,其中{swift_secret_key}为创建Swift用户时,radosgw-admin命令返回的swift_keys->secret_key的值
$ swift -A http://ceph-bench-osd03.gz01:7480/auth/1.0 -U testuser:swift -K '96jl0Cg12T1izmD0CWKUqQFRrnjEBrJGoW2KYNUT' list
my-new-bucket