系统运输
要使用REST接口,请首先为S3接口创建第一个Ceph对象网关用户,然后为Swift接口创建子用户。 最后,您需要确保创建的用户可以访问网关。
创建radosgw用户以访问s3界面
运行以下命令创建用户并记录access_key和secret_key : 不记得也没关系。 可以用radosgw-admin userinfouid=S3显示
[ root @ ceph-node1~ ] # radosgw-adminuser createuid=& amp; #039; S3&; #039; display-name=& amp; #039; S3用户& amp; #039;
{
&; #039; user_id&; #039; &; #039; s3&; #039;
&; #039; display_name&; #039; &; #039; S3用户& amp; #039;
&; #039; 电子邮件& amp; #039; &; #039; 在、
&; #039; suspended&; #039; 0,
&; #039; max_buckets&; #039; 1000,
&; #039; auid&; #039; 0,
&; #039; 子用户& amp; #039; [],
&; #039; keys&; #039; [
{
&; #039; 用户& amp; #039; &; #039; s3&; #039;
&; #039; access_key&; #039; &; #039; wnxrgpk6xgwo8xrlwrua&; #039;
&; #039; secret_key&; #039; &; #039; seg qx 8f z8 H5 arm1pvpygiewp 4g L9 qjkrymi 09 AVP & amp; #039;
}
]、
&; #039; swift_keys&; #039; [],
&; #039; caps&; #039; [],
&; #039; op_mask&; #039; &; #039; 读、写、删除& amp; #039;
&; #039; default_placement&; #039; &; #039; 在、
&; #039; placement_tags&; #039; [],
&; #039; bucket_quota&; #039; {
&; #039; 启用& amp; #039; false,
&; #039; check_on_raw&; #039; false,
&; #039; max_size&; #039;-1,
&; #039; max_size_kb&; #039; 0,
&; #039; max_objects&; #039;-1
(,
&; #039; user_quota&; #039; {
&; #039; 启用& amp; #039; false,
&; #039; check_on_raw&; #039; false,
&; #039; max_size&; #039;-1,
&; #039; max_size_kb&; #039; 0,
&; #039; max_objects&; #039;-1
(,
&; #039; temp_url_keys&; #039; [],
&; #039; type&; #039; &; #039; rgw&; #039;
&; #039; mfa_ids&; #039; []
}
创建radosgw用户以访问swift界面
要访问swift界面,必须创建swift子用户并记录s3:swift的secret_key
[ root @ ceph-node1~ ] # radosgw-adminsubusercreateuid=S3sub user=S3:swiftaccess=full
{
&; #039; user_id&; #039; &; #039; s3&; #039;
&; #039; display_name&; #039; &; #039; S3用户& amp; #039;
&; #039; 电子邮件& amp; #039; &; #039; 在、
&; #039; suspended&; #039; 0,
&; #039; max_buckets&; #039; 1000,
&; #039; auid&; #039; 0,
&; #039; 子用户& amp; #039; [
{
&; #039; id&; #039; &; #039; s3:swift&; #039;
&; #039; 人与人; #039; &; #039; 全控制& amp; #039;
}
]、
&; #039; keys&; #039; [
{
&; #039; 用户& amp; #039; &; #039; s3&; #039;
&; #039; access_key&; #039; &; #039; wnxrgpk6xgwo8xrlwrua&; #039;
&; #039; secret_key&; #039; &; #039; seg qx 8f z8 H5 arm1pvpygiewp 4g L9 qjkrymi 09 AVP & amp; #039;
}
]、
&; #039; swift_keys&; #039; [
{
&; #039; 用户& amp; #039; &; #039; s3:swift&; #039;
&; #039; secret_key&; #039; &; #039; cz B1 ex w6 xry 7ie 41 gfll0xqnlamllc 569 DC9fg1r & amp; #039;
}
]、
&; #039; caps&; #039; [],
&; #039; op_mask&; #039; &; #039; 读、写、删除& amp; #039;
&; #039; default_placement&; #039; &; #039; 在、
&; #039; placement_tags&; #039; [],
&; #039; bucket_quota&; #039; {
&; #039; 启用& amp; #039; false,
&; #039; check_on_raw&; #039; false,
&; #039; max_size&; #039;-1,
&; #039; max_size_kb&; #039; 0,
&; #039; max_objects&; #039;-1
(,
&; #039; user_quota&; #039; {
&; #039; 启用& amp; #039; false,
&; #039; check_on_raw&; #039; false,
&; #039; max_size&; #039;-1,
&; #039; max_size_kb&; #039; 0,
&; #039; max_objects&; #039;-1
(,
&; #039; temp_url_keys&; #039; [],
&; #039; type&; #039; &; #039; rgw&; #039;
&; #039; mfa_ids&; #039; []
}
s3接口测试
S3要验证访问,必须创建并运行Python测试脚本。 S3访问测试脚本连接到radosgw,创建新的存储桶,并列出所有存储桶。 access_key_id和secret_access_key的值来自radosgw-admin命令返回的S3用户的acceess
[ root @ ceph-node1~ ] yuminstallpython-boto-y
[root@ceph-node1 ~]vim s3test.py
导入
import boto.s3.connection
access_key=\\&; quot; wnxrgpk6xgwo8xrlwrua\\\&; quot;
secret_key=\\&; quot; seg qx 8f z8 H5 arm1pvpygiewp 4g L9 qjkrymi 09 AVP\& amp; quot;
conn=boto.connect_s3 (
aws_access_key_id=access_key,
AWS _ secret _ access _ key=secret _ key,
host=\\&; quot; ceph-node1\\&; quot;port=7480,
is_secure=False,
calling _ format=boto.S3.connection.ordinarycallingformat (
)
bucket=Conn.create_bucket ( ( )\&; #039; my-first-S3-bucket )\\&; #039; ) ) ) ) )。
forbucketinconn.get _ all _ buckets (
print { name }\\\t { created }.format ( )
name=bucket.name,
created=bucket.creation_date,
)
root @ ceph-node1~ ] python S3 test.py
my-first-S3-bucket 2019-12-13t 02:58:44.604 z
也可以使用名为s3cmd的命令行工具
root @ ceph-node1~ ] yum installs3cmd-y
root @ ceph-node1~ ] s3cmdconfigure
配置中必须填写s3用户的secret_key和access_key,以及S3 Endpoint和target Amazon S3。 填写这两台主机的主机名和端口,例如ceph-node1:7480
root@ceph-node1 ~]s3cmd ls #查看现有bucket
2019-12-1302:58 S3://my-first-S3-bucket
root @ ceph-node1~ ] S3 cmd mbs3://my-second-S3-bucket #创建bucket
root @ ceph-node1~ ] S3 cmd put/etc/hosts S3://my-second-S3-bucket #将文件放入刚才创建的bucket中
[ root @ ceph-node1] # S3 cmdlsss3://
2019-12-1303:08575 S3://my-second-S3-bucket/hosts
测试swift界面
root @ ceph-node1~ ] yuminstallpython-pip-y
root @ ceph-node1~ ] pip installupgrade python-swift client
创建备份
[ root @ liuning S3 ] # swift-a http://glusterfs-node1: 7480/auth/1.0-us3:swift-k e58 xcqrowx2bmm so36 knwuypeurdpbdbdruspbdrusosth
在swift界面中查看此现有bucket
[ root @ liuning S3 ] # swift-a http://glusterfs-node1: 7480/auth/1.0-us3:swift-k e58 xcqrowx2bmm so36 knwuypeurdpbdbdruspbdrusosth
my-first-s3-bucket
我的第一个仓库
my-second-s3-bucket
请稍候,可能会出现以下错误: 如果不行,请删除刚才的用户并新建,然后使用新的secret_key
authgetfailed:http://ceph-node1: 7480/auth/1.0403 forbidden [ first 60 charsofresponse ] { & amp; #039; 代码& amp; #039; &; #039; 访问定义& amp; #039;&; #039;
failedtransactionid:tx 0000000000000000000013-005 df 3022 d-e2a1- default
现在,您已经完成了s3和swift界面的构建和测试。 如果需要更多使用案例和api,请参阅man或ceph官方网站
详情请访问云服务器、域名注册、虚拟主机的问题,请访问西部数码代理商官方网站: www.chenqinet.cn