ceph radosgw模块介绍

ceph object store模式

一、总体概括。

ceph对象网关存储指的是,通过在librados库基础上对外提供Restful API的方式来访问ceph集群。ceph对象网关通常指的是radosgw程序,该程序建立在librados库基础上且该程序是一个FastCGI模块,该模块向上提供兼容S3以及Swift的接口。

radosgw是一个基于FastCGI的模块,因此需要依赖apache和FastCGI。当有外部ceph对象存储请求到达时apache首先接收到该请求,之后将该请求转发给FastCGI模块,最后FastCGI模块再将该请求发送给radosgw,radosgw通过librados与ceph集群通信。

二、手动安装ceph object store。

由于radosgw是一个FastCGI模块,因此需要安装apache等软件。具体安装步骤如下:

1)安装apache:

#apt-get install apache2 libapache2-mod-fastcgi

2)配置apache:

A)在apache配置文件中添加向外提供服务的服务器地址。apache配置文件位于/etc/apach2/apache2.conf文件,在该文件中添加如下信息:

ServerName {fqdn} #其中{fqdn}可以通过命令hostname -f获取

B)使能rewrite模块和FastCGI模块:

#a2enmod rewrite

#a2enmod fastcgi

C)重新启动apache:

#service apache2 restart

3)启用apache ssl功能:

A)安装openssl及其依赖库:

#apt-get install openssl ssl-cert

B)在apache中使能ssl模块:

#a2enmod ssl

C)为apache ssl创建证书:

#mkdir -p /etc/apache2/ssl

#openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

之后可以在/etc/apache2/ssl/目录下看到apache证书

D)重新启动apache:

#service apache2 restart

4)安装ceph object gateway:

#apt-get install radosgw radosgw-agent

三、配置ceph object gateway。

1、在ceph配置文件中添加网关配置。在安装radosgw的机器上的ceph配置文件(/etc/ceph/ceph.conf)中添加如下内容:

[client.radosgw.gateway]

host = {host-name}

keyring = /etc/ceph/ceph.client.radosgw.keyring

rgw socket path = /tmp/radosgw.sock

log file = /var/log/ceph/radosgw.log

其中:

host指出配置radosgw服务的物理机的host name;

keyring指出用户client.radosgw.gateway访问ceph集群的keyring文件的位置;

2、将修改后的ceph配置文件分发到所有安装radosgw的机器上;

3、为radosgw创建数据目录:

#mkdir -p /var/lib/ceph/radosgw/ceph-radosgw.gateway

4、创建网关配置文件(修改apache配置文件)。这里需要在/etc/apache2/site-available目录下创建一个新的关于radosgw的配置文件rgw.conf。该配置文件的内容如下:

FastCgiExternalServer /var/www/s3gw.fcgi -socket /tmp/radosgw.sock

NameVirtualHost *:443

NameVirtualHost *:80


<VirtualHost *:80>

        ServerName {fqdn}

        ServerAlias {fqdn}

        ServerAdmin {email.address}

        DocumentRoot /var/www

        RewriteEngine On

        RewriteRule  ^/(.*) /s3gw.fcgi?%{QUERY_STRING} [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

        <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>


<VirtualHost *:443>

        ServerName {fqdn}

        ServerAlias {fqdn}

        DocumentRoot /var/www

        RewriteEngine On

        RewriteRule  ^/(.*) /s3gw.fcgi?%{QUERY_STRING} [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

        <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

        SSLEngine on

        SSLCertificateFile /etc/apache2/ssl/apache.crt

        SSLCertificateKeyFile /etc/apache2/ssl/apache.key

</VirtualHost>


5、使能rgw.conf配置,关闭apache默认处理。

#a2ensite rgw.conf

#a2dissite default

6、创建ceph对象网关启动脚本。在/var/www/目录下创建ceph对象网关启动脚本s3gw.fcgi。该脚本内容如下:

#!/bin/sh

exec /usr/bin/radosgw -c /etc/ceph/ceph.conf -n client.radosgw.gateway

创建完毕后设置该脚本为可执行模式。

7、为ceph对象网关存储创建ceph用户及其访问权限。

#ceph-authtool --create-keyring /etc/ceph/ceph.radosgw.gateway.keyring

#chmod +r /etc/ceph/ceph.radosgw.gateway.keyring

#ceph-authtool /etc/ceph/ceph.radosgw.gateway.keyring -n client.radosgw.gateway —gen-key

#ceph-authtool -n client.radosgw.gateway --cap osd 'allow rwx' --cap mon 'allow rw' /etc/ceph/ceph.radosgw.gateway.keyring

#ceph -k /etc/ceph/ceph.client.admin.keyring auth add client.radosgw.gateway -i /etc/ceph/ceph.radosgw.gateway.keyring

8、在ceph集群中为radosgw创建默认pools。

radosgw默认使用的pools有如下几个:.rgw, .rgw.control, .rgw.gc, .log, .intent-log, .usage, .users, .users.email, .users.swift, .users.uid。通过使用#ceph osd pool create命令来创建这些pools。注意要根据ceph集群中OSDs的数量合理的分配各个pools上的PGs数量。

9、重新启动各服务。

#service apache2 restart

#/etc/init.d/radosgw start

到此radosgw的配置就完成了,若使用S3或openstack swift方式通过radosgw访问ceph集群时,需要在radosgw上创建对应的用户及其访问key,对于openstack swift来说还要在ceph配置文件中的client.radosgw.gateway节点下配置keystone相关信息。


转载于:https://my.oschina.net/linuxhunter/blog/542668

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值