Ceph RGW远程同步(multisite)机制研究

本文深入探讨了Ceph 10.2.3版本中RGW(Rados Gateway)的远程同步(multisite)机制。介绍了bucket实例、对象存储、数据日志池以及不同类型的shards。在写入对象时,Ceph类确保以有序的方式记录log,这是跨站点数据同步的关键。同步依赖于log的顺序处理,以保证数据一致性。

说明:

   本文基于ceph 10.2.3的;

   远程同步配置,见http://blog.youkuaiyun.com/for_tech/article/details/68927956

   文中以secondary site为本地,所以local和secondary意思相同;remote和source意思相同;


+=======================================================================+

|                     Remote Site (Source Site)                         |
+=======================================================================+



0.1 Pool: {source-zone}.rgw.data.root

    Bucket instances;

0.2 Pool: {source-zone}.rgw.buckets.data

    Objects;

0.3 Pool: {source-zone}.rgw.buckets.index
    For example, we have 4 buckets, each bucket has 3 shards (rgw_override_bucket_index_max_shards=3)
    bucket-0 shard0     .dir.{key-of-bucket-0}.0
    bucket-0 shard1     .dir.{key-of-bucket-0}.1
    bucket-0 shard2     .dir.{key-of-bucket-0}.2
    bucket-1 shard0     .dir.{key-of-bucket-1}.0
    bucket-1 shard1     .dir.{key-of-bucket-1}.1
    bucket-1 shard2     .dir.{key-of-bucket-1}.2
    bucket-2 shard0     .dir.{key-of-bucket-2}.0
    bucket-2 shard1     .dir.{key-of-bucket-2}.1
    bucket-2 shard2     .dir.{key-of-bucket-2}.2
    bucket-3 shard0     .dir.{key-of-bucket-3}.0
    bucket-3 shard1     .dir.{key-of-bucket-3}.1
    bucket-3 shard2     .dir.{key-of-bucket-3}.2

0.4 Pool: {source-zone}.rgw.log

for example, rgw_data_log_num_shards=4

    data_log.0
    data_log.1
    data_log.2
    data_log.3

0.5 map between bucket shards to data log shards 

    there are

         {bucket-number}*rgw_override_bucket_index_max_shards (12 in our example)
    bucket shards, and
         rgw_data_log_num_shards (4 in our example)
    data log shards;

    These bucket shards are mapped to these data log shards, see function choose_oid()

        bucket-0 shard0 -------- \
        bucket-0 shard1            \
        bucket-0 shard2              \
        bucket-1 shard0                \
        bucket-1 shard1                   data_log.0
        bucket-1 shard2     map to        data_log.1
        bucket-2 shard0                   data_log.2
        bucket-2 shard1                   data_log.3
        bucket-2 shard2                /
        bucket-3 shard0              /
        bucket-3 shard1            /
        bucket-3 shard2 -------- /

      Important: there are 2 kinds of shards:
            data-log-shard:  [0, rgw_data_log_num_shards)
            bucket-shard  :  [0, rgw_override_bucket_index_max_shards)

0.6 Writing an object 

    When an object (OBJ_444) in put into bucket-B, shardS

     A. the object is written into pool  {source-zone}.rgw.buckets.data
     B. write log into pool={source-zone}.rgw.buckets.index, obj=.dir.{key-of-bucket-B}.S as KV pairs:
            OBJ_444             ==> info of OBJ_444, such as owner, content-type ...
            .0_00000000001.4.2  ==> write OBJ_444 state=CLS_RGW_STATE_PENDING_MODIFY
            .0_00000000002.5.3  ==> write OBJ_444 state=CLS_RGW_STATE_COMPLETE
        update omap header to

            .0_00000000002.5.3

        Important: these logs are written by the "Ceph classes", so that the markers (the omap key, such as
           .0_00000000001.4.2, .0_00000000002.5.3) are guaranteed ordered. The order is the key to sync data

           between sites (secondary site needs to process the logs in the same order.)

           "Ceph Classes": Ceph loads .so classes stored in the osd class dir directory dynamically
           (i.e., $libdir/rados-classes by default). When you implement a class, you can create new
           object methods that have the ability to call the native methods in the Ceph Object Store,
           or other class methods you incorporate via libraries or create yourself. On writes, Ceph
           Classes can call native or class methods, perform any series of operations on the inbound
           data and generate a resulting write transaction that Ceph will apply atomically. On reads,
           Ceph Classes can call native or class methods, perform any series of operations on the
           outbound data and return the data to the client.

     C. If bucket-B shardS is mapped to data_log.X, then
        write log into  pool={source-zone}.rgw.log,  obj=data_log.X as KV pair
            1_1489979397.374156_23.1 ==> some info like bucket-B shardS has modification, timestampT
        update omap header to

            1_1489979397.374156_23.1

        Important: these logs are written by the "Ceph classes", so that the markers (the omap key, such as
           1_1489979397.374156_23.1) are guaranteed ordered. The order is the key to sync data between 

           sites (secondary site needs to process the logs in the same order.)


      Important: the data log shard and bucket shard are very similar in that:
            modifications are logged as KV paris;

            latest marker are recorded as omap header;

            the markers are guaranteed ordered. 

### Ceph RGW 简介 Ceph RGWCeph Object Gateway)是 Ceph 存储系统中的对象网关服务,它提供了与 Amazon S3 和 OpenStack Swift 兼容的接口,允许用户通过熟悉的 API 来访问 Ceph 存储集群中的对象存储。这使得 Ceph 能够无缝集成到使用 S3 或 Swift 协议的现有应用程序和云环境中。 ### 功能特性 - **多协议支持**:Ceph RGW 支持 S3 和 Swift 两种广泛使用的对象存储协议,为不同需求的用户提供了灵活的选择。例如,使用 Amazon S3 API 的应用程序可以直接与 Ceph RGW 交互,而使用 OpenStack Swift 的云环境也能轻松集成 Ceph 存储。 - **数据冗余与高可用性**:依托 Ceph 存储集群的强大特性,Ceph RGW 能够实现数据的多副本存储和自动数据修复。当某个存储节点出现故障时,系统会自动将数据副本复制到其他可用节点,确保数据的安全性和服务的连续性。 - **用户认证与授权**:支持多种认证方式,如 AWS 风格的访问密钥认证,可对不同用户或用户组进行细粒度的权限控制。管理员可以根据业务需求,为用户分配不同的读写权限,保护数据的安全性。 - **数据版本控制**:允许用户对存储的对象进行版本管理,方便在数据被误删除或修改时进行恢复。每个对象的不同版本都会被保存,用户可以随时访问和恢复到指定版本。 - **多租户支持**:Ceph RGW 可以在一个存储集群中为多个租户提供独立的存储服务,每个租户有自己的命名空间和权限控制,实现资源的隔离和共享。 ### 配置方法 以下是一个简单的 Ceph RGW 配置示例: 1. **安装 Ceph RGW**:在 Ceph 集群节点上安装 Ceph RGW 服务。 ```bash sudo apt-get install radosgw radosgw-agent ``` 2. **配置 Ceph RGW**:编辑 Ceph 配置文件 `/etc/ceph/ceph.conf`,添加以下内容: ```plaintext [client.rgw.gateway] host = <hostname> rgw frontends = civetweb port=8080 rgw zone = <zone-name> rgw realm = <realm-name> ``` 其中,`<hostname>` 是运行 RGW 服务的节点主机名,`port` 是 RGW 服务监听的端口号,`<zone-name>` 和 `<realm-name>` 是 RGW 区域和领域的名称。 3. **创建 RGW 用户**:使用 `radosgw-admin` 工具创建 RGW 用户,并获取访问密钥。 ```bash radosgw-admin user create --uid="testuser" --display-name="Test User" ``` 该命令将创建一个名为 `testuser` 的 RGW 用户,并返回该用户的访问密钥(Access Key 和 Secret Key)。 ### 使用指南 以下是一个使用 s3fs 挂载 Ceph RGW 存储的示例: ```bash s3fs ceph-rgw /home/s3fs -o passwd_file=~/.passwd-s3fs -o use_path_request_style -o url=http://192.168.123.172:7480 ``` 其中,`ceph-rgw` 是存储桶名称,`/home/s3fs` 是挂载点,`~/.passwd-s3fs` 是存储访问密钥的文件,`http://192.168.123.172:7480` 是 Ceph RGW 服务的 URL。 ### 相关技术信息 - **架构设计**:Ceph RGW 基于 Ceph 的 RADOS(Reliable Autonomic Distributed Object Store)层构建,通过中间件层将 S3 和 Swift 协议的请求转换为 RADOS 对象操作。这种架构使得 Ceph RGW 能够充分利用 Ceph 集群的分布式存储能力,同时提供灵活的接口。 - **性能优化**:可以通过调整 Ceph RGW 的配置参数、优化网络环境和存储硬件等方式来提高性能。例如,增加 RGW 前端的并发连接数、使用高速网络和 SSD 存储设备等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值