注意

本文档适用于 Ceph 的开发版本。

radosgw -- rados REST 网关

概要

radosgw

描述

radosgw 是 RADOS 对象存储的 HTTP REST 网关,RADOS 是 Ceph 分布式存储系统的一部分。它使用 libfcgi 实现为 FastCGI 模块,可与任何支持 FastCGI 的 Web 服务器结合使用。

选项

-c ceph.conf, --conf=ceph.conf

使用 ceph.conf 配置文件而不是默认的 /etc/ceph/ceph.conf 来确定启动期间的监视器地址。

-m monaddress[:port]

连接到指定的监视器(而不是通过 ceph.conf 查找)。

-i ID, --id ID

设置 radosgw 名称的 ID 部分

-n TYPE.ID, --name TYPE.ID

设置网关的 rados 用户名(例如 client.radosgw.gateway)

--cluster NAME

设置集群名称(默认值:ceph)

-d

在前台运行,将日志输出到 stderr

-f

在前台运行,将日志输出到常规位置

--rgw-region=region

radosgw 运行的区域

--rgw-zone=zone

radosgw 运行的区域

配置

早期的 RADOS Gateway 必须配置 Apachemod_fastcgi。现在,使用 mod_proxy_fcgi 模块代替 mod_fastcgimod_proxy_fcgi 的工作方式与传统的 FastCGI 模块不同。此模块需要 mod_proxy 服务,该服务提供对 FastCGI 协议的支持。因此,为了能够处理 FastCGI 协议,mod_proxymod_proxy_fcgi 都必须存在于服务器中。与 mod_fastcgi 不同,mod_proxy_fcgi 无法启动应用程序进程。某些平台为此目的提供了 fcgistarter。但是,FastCGI 应用程序框架中可能提供了外部启动应用程序或进程管理功能。

Apache 必须配置为允许 mod_proxy_fcgi 与 localhost tcp 一起使用。

以下步骤展示了 Ceph 配置文件(即 /etc/ceph/ceph.conf)和网关配置文件(即 /etc/httpd/conf.d/rgw.conf (基于 RPM 的发行版) 或 /etc/apache2/conf-available/rgw.conf (基于 Debian 的发行版))与 localhost tcp 的配置

  1. 对于使用 localhost TCP 的 Apache 2.2 和早期版本的 Apache 2.4 的发行版,将以下内容追加到 /etc/ceph/ceph.conf

    [client.radosgw.gateway]
    host = {hostname}
    keyring = /etc/ceph/ceph.client.radosgw.keyring
    log_file = /var/log/ceph/client.radosgw.gateway.log
    rgw_frontends = fastcgi socket_port=9000 socket_host=0.0.0.0
    rgw_print_continue = false
    
  2. 在网关配置文件中添加以下内容

    对于 Debian/Ubuntu,添加到 /etc/apache2/conf-available/rgw.conf

    <VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www/html
    
    ErrorLog /var/log/apache2/rgw_error.log
    CustomLog /var/log/apache2/rgw_access.log combined
    
    # LogLevel debug
    
    RewriteEngine On
    
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
    
    SetEnv proxy-nokeepalive 1
    
    ProxyPass / fcgi://localhost:9000/
    
    </VirtualHost>
    

    对于 CentOS/RHEL,添加到 /etc/httpd/conf.d/rgw.conf

    <VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www/html
    
    ErrorLog /var/log/httpd/rgw_error.log
    CustomLog /var/log/httpd/rgw_access.log combined
    
    # LogLevel debug
    
    RewriteEngine On
    
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
    
    SetEnv proxy-nokeepalive 1
    
    ProxyPass / fcgi://localhost:9000/
    
    </VirtualHost>
    
  3. 在网关配置文件中添加以下内容

    对于 CentOS/RHEL,添加到 /etc/httpd/conf.d/rgw.conf

    <VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www/html
    
    ErrorLog /var/log/httpd/rgw_error.log
    CustomLog /var/log/httpd/rgw_access.log combined
    
    # LogLevel debug
    
    RewriteEngine On
    
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
    
    SetEnv proxy-nokeepalive 1
    
    ProxyPass / unix:///var/run/ceph/ceph.radosgw.gateway.fastcgi.sock|fcgi://localhost:9000/
    
    </VirtualHost>
    
  4. 为 radosgw 生成用于与集群进行身份验证的密钥。

    ceph-authtool -C -n client.radosgw.gateway --gen-key /etc/ceph/keyring.radosgw.gateway
    ceph-authtool -n client.radosgw.gateway --cap mon 'allow rw' --cap osd 'allow rwx' /etc/ceph/keyring.radosgw.gateway
    
  5. 将密钥添加到身份验证条目中。

    ceph auth add client.radosgw.gateway --in-file=keyring.radosgw.gateway
    
  6. 启动 Apache 和 radosgw。

    Debian/Ubuntu

    sudo /etc/init.d/apache2 start
    sudo /etc/init.d/radosgw start
    

    CentOS/RHEL

    sudo apachectl start
    sudo /etc/init.d/ceph-radosgw start
    

用法日志

radosgw 维护一个异步用法日志。它积累有关用户操作的统计信息并定期刷新。可以通过 radosgw-admin 访问和管理日志。

正在记录的信息包括总数据传输、总操作和总成功操作。数据以小时分辨率在存储桶所有者下核算,除非操作是在服务上完成的(例如,在列出存储桶时),在这种情况下,它是在操作用户下核算的。

以下是一个示例配置

[client.radosgw.gateway]
    rgw_enable_usage_log = true
    rgw_usage_log_tick_interval = 30
    rgw_usage_log_flush_threshold = 1024
    rgw_usage_max_shards = 32
    rgw_usage_max_user_shards = 1

分片的总数决定了保存用法日志信息的对象总数。每个用户的分片数指定保存单个用户用法信息的对象数。tick interval 配置日志刷新之间的秒数,flush threshold 指定在诉诸同步刷新之前可以保留的条目数。

可用性

radosgw 是 Ceph 的一部分,Ceph 是一个可大规模扩展的开源分布式存储系统。请参阅 https://docs.ceph.net.cn 上的 Ceph 文档以获取更多信息。

另请参阅

ceph(8) radosgw-admin(8)

由 Ceph 基金会为您呈现

Ceph 文档是由非营利性 Ceph 基金会 资助和托管的社区资源。如果您希望支持这项工作和我们的其他努力,请考虑 立即加入