Ceph分布式radosgw对象存储融合Swift、S3的访问应用

                     **Ceph分布式radosgw对象存储融合Swift 、S3的访问应用**

Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
确保集群状态正常:前半部分配置参照 https://blog.51cto.com/jdonghong/244175 上半部分配置。
安装RGW实例
[root@master idc-cluster]# ceph-deploy install --rgw client1 client2 client3
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用

我们提供的服务有:网站制作、成都网站设计、微信公众号开发、网站优化、网站认证、寿光ssl等。为上千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的寿光网站制作公司

[root@master idc-cluster]# ceph-deploy rgw create client{1..3}
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
添加管理节点权限
[root@master idc-cluster]# ceph-deploy admin client{1..3}
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
创建S3用户
[root@client1 ceph]# radosgw-admin user create --uid="testuser" --display-name="idc jerry"
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
[root@client1 ceph]# radosgw-admin user create --uid="testuser" --display-name="idc jerry"
{
"user_id": "testuser",
"display_name": "idc jerry",
"email": "",
"suspended": 0,
"max_buckets": 1000,
"auid": 0,
"subusers": [],
"keys": [
{
"user": "testuser",
"access_key": "VWWLX9UP2T9185XLXPF6",
"secret_key": "nwbZ9ufh4tWU8j8XtAoEdVv7WkMAkpRNms9Q39p5j"
}
],
"swift_keys": [],
"caps": [],
"op_mask": "read, write, delete",
"default_placement": "",
"placement_tags": [],
"bucket_quota": {
"enabled": false,
"max_size_kb": -1,
"max_objects": -1
},
"user_quota": {
"enabled": false,
"max_size_kb": -1,
"max_objects": -1
},
"temp_url_keys": []
}
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
[root@master idc-cluster]# curl http://client1:7480 -v
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
查看所有用户
[root@client1 ceph]# radosgw-admin metadata list user
[
"testuser"
]

查看用户信息
[root@client1 ceph]# radosgw-admin user info --uid=testuser
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
查看所有桶
[root@client1 ceph]# radosgw-admin bucket list
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
查看桶内对象
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
查看池
[root@client1 ceph]# rados lspools
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
测试S3接口
[root@BDDB ceph]# yum install python-boto
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
创建测试DEMO
[root@BDDB ceph]# cat s3_test.py
import boto.s3.connection
access_key = 'VWWLX9UP2T9185XLXPF6'
secret_key = 'nwbZ9ufh4tWU8j8XtAoEdVv7WkMAkpRNms9Q39p5j'
conn = boto.connect_s3(
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
host='client1', 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,
)
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
执行测试
[root@BDDB ceph]# python s3_test.py
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
创建Swift用户
要通过 Swift 访问对象网关,需要 Swift 用户,我们创建subuser作为子用户。使用命令

[root@client1 ~]# radosgw-admin user create --uid="jerry" --subuser="jerry":swift --display-name="idc_jerry" --access=full --email=jwenshan@163.com
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
[root@client1 ~]# radosgw-admin user create --uid="jerry" --subuser="jerry":swift --display-name="idc_jerry" --access=full --email=jwenshan@163.com
{
"user_id": "jerry",
"display_name": "idc_jerry",
"email": "jwenshan@163.com",
"suspended": 0,
"max_buckets": 1000,
"auid": 0,
"subusers": [
{
"id": "jerry:swift",
"permissions": "full-control"
}
],
"keys": [
{
"user": "jerry",
"access_key": "L709JEL05ID5NU2N08TY",
"secret_key": "8XhbwWsWiLylOO9lahYI7WUJ3RpBpQAjmaXUUevp"
}
],
"swift_keys": [
{
"user": "jerry:swift",
"secret_key": "lePlwWwWk6enUqJXhM5hAAq7bI96EyBEDaRLyypG"
}
],
"caps": [],
"op_mask": "read, write, delete",
"default_placement": "",
"placement_tags": [],
"bucket_quota": {
"enabled": false,
"max_size_kb": -1,
"max_objects": -1
},
"user_quota": {
"enabled": false,
"max_size_kb": -1,
"max_objects": -1
},
"temp_url_keys": []
}
创建密钥(这步省略因为上面通过一条命令直接一起创建了)
[root@client1 ~]# radosgw-admin key create --subuser=jerry:swift --key-type=swift --gen-secret
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
{
"user_id": "jerry",
"display_name": "idc_jerry--access=full",
"email": "",
"suspended": 0,
"max_buckets": 1000,
"auid": 0,
"subusers": [
{
"id": "jerry:swift",
"permissions": ""
}
],
"keys": [
{
"user": "jerry",
"access_key": "R97T9XMKI9FBYBSQ3C55",
"secret_key": "UgDVkoHRW9f8vGxAVGCS9smyUPn6YooxdNC04V83"
}
],
"swift_keys": [
{
"user": "jerry:swift",
"secret_key": "eQK89OYXPGIjFtI1Yk4gjABaO7PYph4HeJjbaDYO"
}
],
"caps": [],
"op_mask": "read, write, delete",
"default_placement": "",
"placement_tags": [],
"bucket_quota": {
"enabled": false,
"max_size_kb": -1,
"max_objects": -1
},
"user_quota": {
"enabled": false,
"max_size_kb": -1,
"max_objects": -1
},
"temp_url_keys": []
}
测试Swift接口(另找一个客户端结点测试)
需要测试SWIFT客户端安装依赖包
yum install python-setuptools
easy_install pip
pip install python-swiftclient
前提:记得先创建桶,不然不方便后续观察和应用(执行脚本)
[root@BDDB ceph]# cat s3_test.py
import boto.s3.connection
access_key = "L709JEL05ID5NU2N08TY"
secret_key = "8XhbwWsWiLylOO9lahYI7WUJ3RpBpQAjmaXUUevp"
conn = boto.connect_s3(
aws_access_key_id=access_key,
aws_secret_access_key=secret_key,
host='client2', port=7480,
is_secure=False, calling_format=boto.s3.connection.OrdinaryCallingFormat(),
)
bucket = conn.create_bucket('isc_tong') #本例执行了两次脚本创建了两个桶idc_tong和isc_tong
for bucket in conn.get_all_buckets():
print "{name} {created}".format(
name=bucket.name,
created=bucket.creation_date,
)
执行测试:
[root@BDDB ceph]# swift -A http://client2:7480/auth/1.0 -U jerry:swift -K "lePlwWwWk6enUqJXhM5hAAq7bI96EyBEDaRLyypG" list
idc_tong

Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
[root@BDDB ceph]# swift -A http://client2:7480/auth/1.0 -U jerry:swift -K "lePlwWwWk6enUqJXhM5hAAq7bI96EyBEDaRLyypG" stat
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
[root@BDDB ceph]# swift -A http://client2:7480/auth/1.0 -U jerry:swift -K "lePlwWwWk6enUqJXhM5hAAq7bI96EyBEDaRLyypG" list
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
测试swift接口访问对象存储成功。
附引入环境变量方式配置(方便管理配置):
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
[root@BDDB ceph]# export ST_USER=jerry:swift
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
[root@BDDB ceph]# export ST_AUTH=http://client1:7480/auth/1.0
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
[root@BDDB ceph]# export ST_KEY="lePlwWwWk6enUqJXhM5hAAq7bI96EyBEDaRLyypG"
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
[root@BDDB ceph]# swift stat idc_tong
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
上传文件到tong:
[root@BDDB ceph]# swift upload idc_tong ceph.conf

Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
[root@BDDB ceph]# swift stat idc_tong
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
[root@BDDB ceph]# swift stat idc_tong
Account: v1
Container: idc_tong
Objects: 1
Bytes: 369
Read ACL:
Write ACL:
Sync To:
Sync Key:
X-Timestamp: 1567152118.91934
X-Container-Bytes-Used-Actual: 4096
X-Storage-Policy: default-placement
X-Trans-Id: tx00000000000000000001a-005d68e068-d368-default
Accept-Ranges: bytes
Content-Type: text/plain; charset=utf-8
效果展示:

Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
查看桶中存储内容:
[root@BDDB ceph]# swift list idc_tong

Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
[root@BDDB ceph]# ls
ceph.client.admin.keyring ceph.conf rbdmap s3_test.py tmpGnDYcT
[root@BDDB ceph]# swift upload idc_tong s3_test.py
s3_test.py
[root@BDDB ceph]# swift list idc_tong
ceph.conf
s3_test.py
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用
下载(Using the download Command)
[root@BDDB data]# swift download idc_tong ceph.conf
Ceph分布式radosgw对象存储融合Swift 、S3的访问应用


本文标题:Ceph分布式radosgw对象存储融合Swift、S3的访问应用
当前地址:http://pwwzsj.com/article/ghsece.html