CEPH Object Gateway


參考文檔:

一.環境准備

1. Ceph Object Gateway框架

Ceph Object Gateway是對象存儲接口,構建在librados之上,為應用提供restful類型的網關。其支持兩種接口:

  1. S3-compatible API:兼容AWS S3 Restful接口;
  2. Swift-compaible API:兼容Openstack Swift接口。

2. 環境

以《CEPH LIO iSCSI Gateway》中的環境為基礎,即:

Hostname

IP

Service

Remark

ceph01

public:172.30.200.57

cluster:192.30.200.57

 

1. centos7.5 with kernel v4.18.7-1;

2. ceph-13.2.1 mimic (stable),已部署

3. ntp已部署;

4. 禁用selinux;

5. 禁用firewalld或iptables,rgw內嵌civetweb默認采用7480端口。

ceph02

public:172.30.200.58

cluster:192.30.200.58

 

ceph03

public:172.30.200.59

cluster:192.30.200.59

 

ceph-client

172.30.200.50

   

二.部署Ceph RGW

1. 創建ceph mds

# 通過部署服務器部署,格式:ceph-deploy install --rgw Gateway-NODE1 [Gateway-NODE2 …]; # 如因網絡原因導致安裝不成功,可在各節點獨立安裝:ceph-radosgw ceph-common
[root@ceph01 ~]# su - cephde
[cephde@ceph01 ~]$ cd cephcluster/ [cephde@ceph01 cephcluster]$ ceph-deploy install --rgw ceph01 ceph02 ceph03

2. 創建對象網關實例

Ceph 對象存儲使用 Ceph 對象網關守護進程( radosgw ,RGW),內嵌了Civetweb服務器與FastCGI 模塊。

其中Civetweb服務器默認使用tcp 7480端口。

1)變更默認端口(option)

# 變更Civetweb服務器默認端口,可修改ceph.conf文件,增加[client.rgw.<GATEWAY-NODE>]字段,其中“GATEWAY-NODE”為所在網關節點的短主機名,即:hostname -s; # 可在部署服務器修改后分發到各網關節點,也可在各網關節點獨立修改; # [client.rgw.<GATEWAY-NODE>]字段與[global]字段在相同層級,且1個網關節點使用1個字段,其中”client”表示客戶端配置,“rgw”表示客戶端類型,“GATEWAY-NODE”標識實例名;
[cephde@ceph01 cephcluster]$ cat ceph.conf [client.rgw.ceph01] rgw_frontends = "civetweb port=80" [client.rgw.ceph02] rgw_frontends = "civetweb port=80" [client.rgw.ceph03] rgw_frontends = "civetweb port=80" 

# 從部署服務器分發ceph.conf
[cephde@ceph01 cephcluster]$ ceph-deploy --overwrite-conf config push ceph01 ceph02 ceph03

2)創建實例

# 在部署服務器創建實例; # 創建后,在各網關節點對應的守護進程啟動; # 如果ceph.conf配置文件變更,可在對應節點重啟服務
[cephde@ceph01 cephcluster]$ ceph-deploy rgw create ceph01 ceph02 ceph03

 

# 查看服務
[root@ceph01 ~]# systemctl status ceph-radosgw@rgw.ceph01

 

# 查看端口
[root@ceph01 ~]# netstat -tunlp | grep radosgw

 

# 創建實例后,同時創建部分默認pool; # 或:”rados df” 與 “ceph osd pool ls”
[root@ceph01 ~]# ceph osd lspools

 

3)訪問

# 格式:http://RGW-IP:port [root@ceph01 ~]# curl http://172.30.200.57 # 如果網關實例正常運行,響應如下: <?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>

三.驗證

使用REST接口驗證,步驟如下:

  1. 首先創建適用於s3接口的ceph對象網關用戶;
  2. 基於已創建的用戶,創建適用於swift接口的子用戶
  3. 驗證用戶是否能訪問網關。

1. 創建用戶

1)創建用於S3訪問的RADOSGW用戶

# “--uid”與“--display-name”自定義; # 返回結果中,keys->access_keykeys->secret_key 是訪問驗證時需要的值
[root@ceph01 ~]# radosgw-admin user create --uid="objectuser" --display-name="Object Stoage User"

 

2)創建SWITF用戶

Swift用戶創建分兩步:

  1. 創建子用戶
  2. 生成秘鑰。
# 創建子用戶,基於已創建的s3用戶; # 賦予全權限
[root@ceph01 ~]# radosgw-admin subuser create --uid=objectuser --subuser=objectuser:swift --access=full

 

# 生成秘鑰; # 返回結果中,swift_keys ->secret_key 是訪問驗證時需要的值
[root@ceph01 ~]# radosgw-admin key create --subuser=objectuser:swift --key-type=swift --gen-secret

 

2. 訪問驗證

1)測試S3訪問

測試采用python腳本完成,腳本流程如下:測試腳本連接radosgw,創建bucket,list bucket。

# 客戶端需要安裝python-boto
[root@ceph-client ~]# yum install -y python-boto

# 編輯測試腳本; # 注意”access_key”,”secret_key”,”host”與”port”值修改
[root@ceph-client ~]# vim s3.py
import boto.s3.connection access_key = 'YT6ZE7N82VOY82CP5F1D' secret_key = 'tvRcE4sLh7YOrBBgcLUAWL4Czdqrak2UBg5DsOcy' conn = boto.connect_s3( aws_access_key_id=access_key, aws_secret_access_key=secret_key, host='172.30.200.57', port=80, 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, ) # 運行腳本,返回結果符合預期
[root@ceph-client ~]# python s3.py

 

2)測試Swift訪問

測試采用swift客戶端進行。

# 安裝swift客戶端
[root@ceph-client ~]# yum install python-setuptools
[root@ceph-client ~]# easy_install pip
[root@ceph-client ~]# pip install --upgrade setuptools
[root@ceph-client ~]# pip install --upgrade python-swiftclient

# 命令格式:swift -A http://{IP ADDRESS}:{port}/auth/1.0 -U USER:swift -K '{swift_secret_key}' list; # 這里基於s3測試生成的bucket,list bucker,返回結果符合預期
[root@ceph-client ~]# swift -A http://172.30.200.57/auth/1.0 -U objectuser:swift -K '9mm3yJT6CQ62A1II0AqENu3LDKmBxcEwy1kXBspn' list

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM