您好,登錄后才能下訂單哦!
這篇文章主要介紹“Ceph對象存儲網關的安裝配置”,在日常操作中,相信很多人在Ceph對象存儲網關的安裝配置問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Ceph對象存儲網關的安裝配置”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
基于已部署好的Ceph集群,部署一個網關服務器,進行對象存儲服務。操作系統CentOS6.5 CEPH0.94.3其實基于librados可以直接進行訪問,但是我看了百度,UCLOUD的對象存儲,用戶在網頁上進行文件的上傳、下載時,都通過web服務器間接和存儲集群打交道,進行了一層隔離,而不是直接和集群進行通信操作。我得理解是便于訪問控制以及隔離。
Ceph rados-gateway依賴Apache和FastCGI, 用戶的請求先到web服務器,再走rados-gateway進入集群之中。
sudo yum install httpd Package httpd-2.2.15-47.el6.centos.x86_64 already installed and latest version
sudo vim /etc/httpd/conf/httpd.conf
將ServerName的注釋號去掉,添加上自己網關服務器的IP地址
272 # If your host doesn't have a registered DNS name, enter its IP address here. 273 # You will have to access it by its address anyway, and this will make 274 # redirections work in a sensible way. 275 # 276 ServerName 101.67.163.34:80
在配置中增加如下信息,加載mod_proxy_fcgi
<IfModule !proxy_fcgi_module> LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so </IfModule>
此處需注意,需要將該段內容加載LoadModule系列的后面,否則會報如下錯誤:
sudo service httpd start Starting httpd: httpd: Syntax error on line 129 of /etc/httpd/conf/httpd.conf: Cannot load /etc/httpd/modules/mod_proxy_fcgi.so into server: /etc/httpd/modules/mod_proxy_fcgi.so: undefined symbol: ap_proxy_release_connection
修改配置中的LISTEN字段,將網關所在主機的IP地址添加進去
# Listen: Allows you to bind Apache to specific IP addresses and/or # ports, in addition to the default. See also the <VirtualHost> # directive. # # Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) # Listen 101.67.163.34:80 #Listen 80
秘鑰文件生成
sudo yum install mod_ssl openssl openssl genrsa -out ca.key 2048 openssl req -new -key ca.key -out ca.csr openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt
文件目錄放置sudo cp ca.crt /etc/pki/tls/certs
sudo cp ca.key /etc/pki/tls/private/ca.key sudo cp ca.csr /etc/pki/tls/private/ca.csr
配置文件修改/etc/httpd/conf.d/ssl.conf.
SSLCertificateFile /etc/pki/tls/certs/ca.crt SSLCertificateKeyFile /etc/pki/tls/private/ca.key
重啟httpd服務sudo service httpd restart
sudo yum install ceph-radosgw
至此,相關依賴包安裝完畢
ceph網關其實是ceph集群的一個客戶端,用戶通過這個網關間接訪問ceph集群,作為客戶端,它需要準備如下內容:
網關名稱,此處用gateway稱呼
一個可以訪問存儲集群的用戶以及對應的KEYRING
數據資源池,這個由ceph集群提供
為網關服務示例準備一個數據存放空間
在ceph.conf配置文件中設置gateway信息
創建gateway keyring,一開始該文件為空
sudo ceph-authtool --create-keyring /etc/ceph/ceph.client.radosgw.keyring sudo chmod +r /etc/ceph/ceph.client.radosgw.keyring
創建網關用戶名以及key 此處名字為 client.radosgw.gateway
sudo ceph-authtool /etc/ceph/ceph.client.radosgw.keyring -n client.radosgw.gateway --gen-key
為KEYRING添加權限
sudo ceph-authtool -n client.radosgw.gateway --cap osd 'allow rwx' --cap mon 'allow rwx' /etc/ceph/ceph.client.radosgw.keyring
將key添加到集群中
sudo ceph -k /etc/ceph/ceph.client.admin.keyring auth add client.radosgw.gateway -i /etc/ceph/ceph.client.radosgw.keyring
將相關的KEYRING文件拷貝到rados-gateway所在的主機 /etc/ceph/目錄下
.rgw.root .rgw.control .rgw.gc .rgw.buckets .rgw.buckets.index .rgw.buckets.extra .log .intent-log .usage .users .users.email .users.swift .users.uid
[root@gnop029-ct-zhejiang_wenzhou-16-34 conf]# ceph osd lspools 4 rbd,6 pool-1,7 pool-2,8 .rgw,9 .rgw.root,10 .rgw.control,11 .rgw.gc,12 .rgw.buckets,13 .rgw.buckets.index,14 .log,15 .intent-log,16 .usage,17 .users,18 .users.email,19 .users.swift,20 .users.uid
[client.radosgw.gateway] host=ceph-24 keyring=/etc/ceph/ceph.client.radosgw.keyring rgw socket path=/var/run/ceph/ceph.radosgw.gateway.fastcgi.sock log file=/var/log/radosgw/client.radosgw.gateway.log rgw frontends=fastcgi socket_port=9000 socket_host=0.0.0.0 rgw print continue=false
創建數據目錄
sudo mkdir -p /var/lib/ceph/radosgw/ceph-radosgw.gateway 調整apache運行權限 sudo chown apache:apache /var/run/ceph
調整日志權限
sudo chown apache:apache /var/log/radosgw/client.radosgw.gateway.log
啟動網關服務sudo /etc/init.d/ceph-radosgw start
一個配置文件,用于web server和FastCGI之間的交互
sudo vi /etc/httpd/conf.d/rgw.conf
<VirtualHost *:80> ServerName 101.67.163.34 DocumentRoot /var/www/html ErrorLog /var/log/httpd/rgw_error.log CustomLog /var/log/httpd/rgw_access.log combined RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] SetEnv proxy-nokeepalive 1 ProxyPass / fcgi://101.67.163.34:9000/ </VirtualHost>
其中標紅的地方是要根據實際情況填寫
radosgw-admin user create --uid=xuwenping --display-name="ceph xuwenping" --email=xuwenping@d***n.com { "user_id": "xuwenping", "display_name": "ceph xuwenping", "email": "xuwenping@dnion.com", "suspended": 0, "max_buckets": 1000, "auid": 0, "subusers": [], "keys": [ { "user": "xuwenping", "access_key": "4J3GD7GJIJKSDCVS1I9T", "secret_key": "yfmxvzQdWT4EmVDijOFp6oNt4kZ25y9wRVARas4I" } ], "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": [] }
創建SWIFT類型USER
sudo radosgw-admin subuser create --uid=xuwenping --subuser=xuwenping :swift --access=full 2015-10-10 14:19:19.854951 7f402eadc8a0 0 max_buckets=1000 specified=0 { "user_id": "xuwenping", "display_name": "ceph xuwenping", "email": "xuwenping@dnion.com", "suspended": 0, "max_buckets": 1000, "auid": 0, "subusers": [ { "id": "xuwenping:swift", "permissions": "full-control" } ], "keys": [ { "user": "xuwenping", "access_key": "4J3GD7GJIJKSDCVS1I9T", "secret_key": "yfmxvzQdWT4EmVDijOFp6oNt4kZ25y9wRVARas4I" }, { "user": "xuwenping:swift", "access_key": "PEIT99BBWMZP31BD6S3I", "secret_key": "" } ], "swift_keys": [ { "user": "xuwenping:swift", "secret_key": "qWHPhvUy4md1XSa2PSbcxUyMU5YXodlqxt0ZC2hn" } ], "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": [] }
編寫了一段python代碼,用于訪問網關,并創建bucket,并通過list方法羅列出當前所有的bucket (官方示例)
依賴庫安裝
sudo yum install python-boto
import boto import boto.s3.connection access_key = '4J3GD7GJIJKSDCVS1I9T' secret_key = 'yfmxvzQdWT4EmVDijOFp6oNt4kZ25y9wRVARas4I' conn = boto.connect_s3( aws_access_key_id = access_key, aws_secret_access_key = secret_key, host = '101.67.163.34', 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}\t{created}".format( name = bucket.name, created = bucket.creation_date, )
運行結果
[root@gnop029-ct-zhejiang_wenzhou-16-34 ceph-rados]# python s3test.py my-new-bucket 2015-10-10T06:23:48.000Z
至此,Ceph集群的對象存儲網關安裝設置完畢
附:
有時候通過yum安裝軟件是報如下錯誤:
Downloading Packages: warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 GPG key retrieval failed: [Errno 14] Could not open/read file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
在執行 安裝命令時帶上如下參數即可:
yum install mod_proxy_fcgi --nogpgcheck
到此,關于“Ceph對象存儲網關的安裝配置”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。