共計 3736 個字符,預計需要花費 10 分鐘才能閱讀完成。
這篇文章將為大家詳細講解有關 Infernalis 版本 radosgw 如何搭建配置,丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
1. 安裝 apache。
#apt-get install apache2 libapache2-mod-fastcgi
2. 配置 apache。
在 apache 配置文件中添加服務器名稱,即:在 /etc/apache2/apache2.conf 文件添加如下內容:
ServerName {fqdn}
其中 fqdn 是 hostname - f 的輸出結果。
使能 apache 相關模塊。
a2enmod proxy_fcgi
a2enmod fastcgi
a2enmod rewrite
啟動 apache。
#service apache2 start
3. 安裝 radosgw 模塊。
#apt-get install radosgw
4. 創建 radosgw 用戶和 keyring。
為 rgw 創建 keyring。
#ceph-authtool –create-keyring /etc/ceph/ceph.client.radosgw.keyring
#chmod +r /etc/ceph/ceph.client.radosgw.keyring
為 rgw 用戶生成 key。
#ceph-authtool /etc/ceph/ceph.client.radosgw.keyring -n client.radosgw.gateway –gen-key
為 rgw 用戶創建權限。
#ceph-authtool -n client.radosgw.gateway –cap osd allow rwx –cap mon allow rwx /etc/ceph/ceph.client.radosgw.keyring
將 rgw 用戶添加到 ceph 集群。
#ceph -k /etc/ceph/ceph.client.admin.keyring auth add client.radosgw.gateway -i /etc/ceph/ceph.client.radosgw.keyring
分發 rgw 的 keyring。
通過 ssh 命令將 /etc/ceph/ceph.client.radosgw.keyring 復制到其他 rgw 節點上。
5. 創建 pool。
當創建的 rgw 用戶有寫權限,則 rgw 會自動的創建所需的 pools,因此該步驟可以省略。
6. 配置 rgw。
在 /etc/ceph/ceph.conf 中添加如下內容:
[client.radosgw.gateway]
host = ceph-node1
keyring = /etc/ceph/ceph.client.radosgw.keyring
rgw socket path = /tmp/radosgw.sock
log file = /var/log/radosgw/client.radosgw.gateway.log
rgw print continue = false
創建 rgw 工作目錄:
#mkdir -p /var/lib/ceph/radosgw/ceph-radosgw.gateway
創建 rgwlog 目錄
#mkdir -p /var/log/radosgw
7. 啟動 rgw。
#/etc/init.d/radosgw start
8. 配置 radosgw 網關。
在 /etc/apache2/site-available/ 目錄下創建 rgw.conf 文件且該文件內容如下:
FastCgiExternalServer /var/www/s3gw.fcgi -socket /tmp/radosgw.sock
VirtualHost *:80
ServerName ceph-node1
ServerAlias ceph-node1
DocumentRoot /var/www
RewriteEngine On
RewriteRule ^/(.*) /s3gw.fcgi?%{QUERY_STRING} [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
IfModule mod_headers.c
Header set Access-Control-Allow-Origin *
Header set Access-Control-Allow-Methods HEAD,GET,PUT,POST,DELETE,OPTIONS
Header set Access-Control-Allow-Headers authorization,content-type,x-amz-date,x-amz-user-agent,content-md5,neunn-token,neunn-user-id,x-amz-copy-source,x-amz-acl,neunn-radosgw-user-id,neunn-user-adminops
Header set Access-Control-Expose-Headers ETag
/IfModule
IfModule mod_fastcgi.c
Directory /var/www
Options +ExecCGI
AllowOverride All
SetHandler fastcgi-script
Order allow,deny
Allow from all
AuthBasicAuthoritative Off
/Directory
/IfModule
AllowEncodedSlashes On
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
ServerSignature Off
/VirtualHost
另外在 /var/www/ 目錄下創建一個可執行文件 s3gw.fcgi 且該文件內容如下:
#!/bin/sh
exec /usr/bin/radosgw -c /etc/ceph/ceph.conf -n client.radosgw.gateway
9. 重新啟動 apache。
使能 rgw 模塊。
#a2ensite rgw.conf
#a2dissite 000-default
重啟 apache。
#service apache2 restart
10. 創建 S3 用戶。
#radosgw-admin user create –uid= testuser –display-name= First User
輸出內容如下:
{user_id : testuser ,
display_name : First User ,
email : ,
suspended : 0,
max_buckets : 1000,
auid : 0,
subusers : [],
keys : [
{user : testuser ,
access_key : I0PJDPCIYZ665MW88W9R ,
secret_key : dxaXZ8U90SXydYzyS5ivamEP20hkLSUViiaR+ZDA }],
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 : []}
其中比較重要的是 access_key 和 secret_key。
11. 設置 S3 用戶的訪問權限。
#radosgw-admin caps add –uid=testuser –caps= users=*
#radosgw-admin caps add –uid=testuser –caps= buckets=*
#radosgw-admin caps add –uid=testuser –caps= metadata=*
#radosgw-admin caps add –uid=testuser –caps= usage=*
#radosgw-admin caps add –uid=testuser –caps= zone=*
12. 使用瀏覽器訪問 radosgw。
使用通用瀏覽器訪問 radosgw 的 80 端口后,在瀏覽器上會出現如下信息:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
ListAllMyBucketsResult xmlns= http://s3.amazonaws.com/doc/2006-03-01/
Owner
ID anonymous /ID
DisplayName/
/Owner
Buckets/
/ListAllMyBucketsResult
出現該信息表示 radosgw 已經搭建成功。
關于“Infernalis 版本 radosgw 如何搭建配置”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。