1. 清理可能存在的历史记录
rm -rf /var/run/ceph/*
rm -rf /var/log/ceph/*
rm -rf /var/lib/ceph/*
rm -rf /usr/local/etc/ceph/*
rm -rf /etc/ceph/ceph.client.radosgw.keyring
rm -rf /etc/ceph/ceph.client.admin.keyring
2. 为rgw创建keyring
ceph-authtool --create-keyring /etc/ceph/ceph.client.radosgw.keyring
chmod +r /etc/ceph/ceph.client.radosgw.keyring
3. 创建一个用户并生成key
ceph-authtool /etc/ceph/ceph.client.radosgw.keyring -n client.radosgw.gw1 --gen-key #user is gw1
ceph-authtool -n client.radosgw.gw1 --cap osd 'allow rwx' --cap mon 'allow rwx'
4. 配置ceph.conf
在rgw服务器添加ceph.conf, 并拷贝到/etc/ceph和/usr/local/etc/ceph
for example:
[global]
fsid = 1dfee97f-c803-4b89-87fe-7b65013b31ca
auth cluster required = cephx
auth service required = cephx
auth client required = cephx
osd journal size = 1024
filestore xattr use omap = true
osd pool default size = 2
osd pool default min size = 1
osd pool default pg num = 128
osd pool default pgp num = 128
osd crush chooseleaf type = 0
[mon.mon1]
host = mon_node
mon addr = 10.24.25.27:6789
[client.radosgw.gw1]
host = GWNODE1
keyring = /etc/ceph/ceph.client.radosgw.keyring
rgw socket path = /var/run/ceph/ceph.radosgw.gw1.fastcgi.sock
log file = /var/log/ceph/client.radosgw.gw1.log
rgw print continue = true
rgw enable ops log = true
5. 在管理服务器上rados集群添加key
#scp admin:/etc/ceph/ceph.client.admin.keyring /etc/ceph/ceph.client.admin.keyring
ceph -k /etc/ceph/ceph.client.admin.keyring auth add client.radosgw.gw1 -i /etc/ceph/ceph.client.radosgw.keyring
6. 将keyring拷贝到rgw服务器
scp /etc/ceph/ceph.client.radosgw.keyring ceph@{hostname}:/home/ceph
ssh {hostname}
mv ceph.client.radosgw.keyring /etc/ceph/ceph.client.radosgw.keyring
7. 添加fastcgi脚本
cd /var/www/html/
vi s3gw.fcgi
#!/bin/sh
exec /usr/bin/radosgw -c /etc/ceph/ceph.conf -n client.radosgw.gw1
chmod +x s3gw.fcgi
chown apache:apache s3gw.fcgi
8. 创建数据目录
mkdir -p /var/lib/ceph/radosgw/ceph-radosgw.gw1
[修改fastcgi.conf]
vi /etc/httpd/conf.d/fastcgi.conf
将FastCgiWrapper On改为Off
9. 添加apache代理脚本
cd /etc/httpd/conf.d/
vi rgw.conf:
FastCgiExternalServer /var/www/html/s3gw.fcgi -socket /var/run/ceph/ceph.radosgw.gw1.fastcgi.sock
<VirtualHost *:80>
ServerName {hostname or domainName}
ServerAdmin {administrator email}
DocumentRoot /var/www/html
RewriteEngine On
RewriteRule ^/(.*) /s3gw.fcgi?%{QUERY_STRING} [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
<IfModule mod_fastcgi.c>
<Directory /var/www/html>
Options +ExecCGI
AllowOverride All
SetHandler fastcgi-script
Order allow,deny
Allow from all
AuthBasicAuthoritative Off
</Directory>
</IfModule>
AllowEncodedSlashes On
ErrorLog /var/log/httpd/error.log
CustomLog /var/log/httpd/access.log combined
ServerSignature Off
</VirtualHost>
10. 修改Apache的serverName
vi /etc/httpd/conf/httpd.conf
ServerName {fqdn}
11. 调整设置
service iptables stop
setenforce 0
sed -i "s/DEFAULT_USER='www-data'/DEFAULT_USER='root'/g" /etc/init.d/ceph-radosgw
sed -i "s/DEFAULT_USER='apache'/DEFAULT_USER='root'/g" /etc/init.d/ceph-radosgw
12. 启动rgw服务
sudo /etc/init.d/httpd restart
sudo /etc/init.d/ceph-radosgw start
13. 验证
得到200的response即部署成功
curl -X GET http://127.0.0.1 -i
14. 创建RGW用户【可选】
radosgw-admin user create --uid={username} --display-name="{display-name}"
创建普通用户
radosgw-admin user create --uid=xxx --display-name="xxx" --access-key="xxx" --secret="xxx"
创建admin用户
radosgw-admin user create --uid=admin --display-name=admin --caps="users=*;buckets=*;metadata=*;usage=*;zone=*" --system
来源:oschina
链接:https://my.oschina.net/u/2407124/blog/653202