真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Ceph配置S3和swift接口訪問(wèn)集群-創(chuàng)新互聯(lián)

要使用REST接口,我們首先要為S3接口創(chuàng)建一個(gè)初始的Ceph對(duì)象網(wǎng)關(guān)用戶,然后為Swift界面創(chuàng)建一個(gè)子用戶,最后,我們需要驗(yàn)證創(chuàng)建的用戶是否能夠訪問(wèn)網(wǎng)關(guān)。

在三臺(tái)等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供做網(wǎng)站、網(wǎng)站建設(shè) 網(wǎng)站設(shè)計(jì)制作按需定制開(kāi)發(fā),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站設(shè)計(jì),全網(wǎng)營(yíng)銷推廣,成都外貿(mào)網(wǎng)站建設(shè),三臺(tái)網(wǎng)站建設(shè)費(fèi)用合理。

創(chuàng)建用以訪問(wèn)s3接口的radosgw用戶

執(zhí)行如下命令創(chuàng)建用戶,記錄下access_key和secret_key,沒(méi)記住也沒(méi)關(guān)系,可以使用radosgw-admin user info --uid=s3查看


[root@ceph-node1 ~]# radosgw-admin user create --uid="s3" --display-name="s3 user"
{
"user_id": "s3",
"display_name": "s3 user",
"email": "",
"suspended": 0,
"max_buckets": 1000,
"auid": 0,
"subusers": [],
"keys": [
{
"user": "s3",
"access_key": "WNXRGPK6XGWO8XRLWRUA",
"secret_key": "Segqx8fZ8H5arM1Pvpygiewp4gl9Qjkrymi09aVP"
}
],
"swift_keys": [],
"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",
"mfa_ids": []
}

創(chuàng)建用以訪問(wèn)swift接口的radosgw用戶

進(jìn)行swift接口訪問(wèn),需要?jiǎng)?chuàng)建一個(gè)Swift子用戶,記錄下s3:swift的secret_key


[root@ceph-node1 ~]#radosgw-admin subuser create --uid=s3 --subuser=s3:swift --access=full
{
"user_id": "s3",
"display_name": "s3 user",
"email": "",
"suspended": 0,
"max_buckets": 1000,
"auid": 0,
"subusers": [
{
"id": "s3:swift",
"permissions": "full-control"
}
],
"keys": [
{
"user": "s3",
"access_key": "WNXRGPK6XGWO8XRLWRUA",
"secret_key": "Segqx8fZ8H5arM1Pvpygiewp4gl9Qjkrymi09aVP"
}
],
"swift_keys": [
{
"user": "s3:swift",
"secret_key": "czb1ExW6XRy7iE41gFLL0xQNlamLLc569DC9FG1r"
}
],
"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",
"mfa_ids": []
}

測(cè)試s3接口

我們需要編寫并運(yùn)行Python測(cè)試腳本來(lái)驗(yàn)證S3訪問(wèn), S3訪問(wèn)測(cè)試腳本將連接到radosgw,創(chuàng)建一個(gè)新的存儲(chǔ)桶并列出所有存儲(chǔ)桶, access_key_id和secret_access_key的值取自radosgw-admin命令返回的s3用戶的access_key和secret_key的值,另外需要修改主機(jī)名(host)和端口(port)


[root@ceph-node1 ~]yum install python-boto -y


[root@ceph-node1 ~]vim s3test.py

import boto
import boto.s3.connection
access_key = 'WNXRGPK6XGWO8XRLWRUA'
secret_key = 'Segqx8fZ8H5arM1Pvpygiewp4gl9Qjkrymi09aVP'
conn = boto.connect_s3(
    aws_access_key_id = access_key,
    aws_secret_access_key = secret_key,
    host = 'ceph-node1', port=7480,
    is_secure=False,
    calling_format = boto.s3.connection.OrdinaryCallingFormat(),
)
bucket = conn.create_bucket('my-first-s3-bucket')
for bucket in conn.get_all_buckets():
        print "{name}\t{created}".format(
                name = bucket.name,
                created = bucket.creation_date,
)

root@ceph-node1 ~]python s3test.py
my-first-s3-bucket 2019-12-13T02:58:44.604Z


也可以使用s3cmd這個(gè)命令行工具

root@ceph-node1 ~]yum install s3cmd -y


root@ceph-node1 ~]s3cmd --configure

配置里需要填寫s3用戶的secret_key和access_key,以及S3 Endpoint和target Amazon S3,這兩個(gè)填寫radosgw的主機(jī)的主機(jī)名和端口,如ceph-node1:7480


root@ceph-node1 ~]s3cmd ls #查看已有bucket
2019-12-13 02:58 s3://my-first-s3-bucket
root@ceph-node1 ~]s3cmd mb s3://my-second-s3-bucket #創(chuàng)建一個(gè)bucket
root@ceph-node1 ~]s3cmd put /etc/hosts s3://my-second-s3-bucket #給剛才創(chuàng)建的bucket中放入一個(gè)文件
[root@ceph-node1]# s3cmd ls s3://my-second-s3-bucket #查看桶中文件
2019-12-13 03:08 575 s3://my-second-s3-bucket/hosts

測(cè)試swift接口

root@ceph-node1 ~]yum install python-pip -y
root@ceph-node1 ~]pip install --upgrade python-swiftclient


創(chuàng)建一個(gè)bucket
[root@liuning s3]# swift -A http://glusterfs-node1:7480/auth/1.0 -U s3:swift -K e58xcqROWx2bMMSo36KnNWUYpEUrdPbDruNWezqr post my-first-swift-bucket


用swift接口查看這個(gè)已有的bucket
[root@liuning s3]# swift -A http://glusterfs-node1:7480/auth/1.0 -U s3:swift -K e58xcqROWx2bMMSo36KnNWUYpEUrdPbDruNWezqr list
my-first-s3-bucket
my-first-swift-bucket
my-second-s3-bucket

注意可能會(huì)出現(xiàn)下面這個(gè)錯(cuò)誤,等一會(huì)就好了,要是不行就把剛才的用戶刪除了重新創(chuàng)建一個(gè),使用新的secret_key

Auth GET failed: http://ceph-node1:7480/auth/1.0 403 Forbidden [first 60 chars of response] {"Code":"AccessDenied","RequestId":"tx000000000000000000013-
Failed Transaction ID: tx000000000000000000013-005df3022d-e2a1-default


至此,s3和swift接口的搭建和測(cè)試已經(jīng)完成,如需更多使用實(shí)例和api,可以查閱man或ceph官網(wǎng)

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。


網(wǎng)站欄目:Ceph配置S3和swift接口訪問(wèn)集群-創(chuàng)新互聯(lián)
標(biāo)題網(wǎng)址:http://weahome.cn/article/joiop.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部