自学内容网 自学内容网

ceph rgw 桶分片之reshard

Ceph RGW(RADOS Gateway)的 reshard 功能是用来动态调整对象存储的分片(shard)数量,从而优化性能和存储利用率。随着数据量的增加,初始的分片设置可能无法满足性能需求,因此 reshard 功能允许用户在不影响服务可用性的情况下进行调整。 
 
### Reshard 功能的详细说明: 
 
1. **分片的概念**: 
   - 在 Ceph RGW 中,分片是将对象存储桶的对象分散到多个分片(shard)中,以便更好地管理和访问数据。每个分片可以被视为一个小的对象存储区域。 
 
2. **动态调整**: 
   - Reshard 功能允许用户根据负载和数据量的变化,动态调整存储桶的分片数量。用户可以增加或减少分片的数量,以适应不同的使用场景。 
 
3. **性能优化**: 
   - 通过增加分片数量,可以提高并发访问的性能,因为多个分片可以同时处理请求。相反,当数据量减少时,可以减少分片数量,从而节省资源。 
 
4. **无缝操作**: 
   - Resharding 过程是无缝的,用户在调整分片数量时,不会影响到正在进行的读写操作。这使得系统能够在高可用性和高性能之间取得平衡。 
 
5. **管理工具**: 
   - Ceph 提供了一些命令行工具和 API 来管理 reshard 操作。用户可以使用这些工具来查看当前的分片状态,执行 reshard 操作,以及监控性能。 
 
6. **监控和优化**: 
   - 在执行 reshard 操作后,建议监控系统的性能,确保调整后的分片数量能够满足当前的负载需求。 
 
### 使用场景: 
- 当存储桶中的对象数量显著增加时,可能需要增加分片数量以保持良好的性能。 
- 当存储桶中的对象数量减少时,可以考虑减少分片数量,以节省资源和提高管理效率。 
 

### 桶分片操作:
1. 查看桶的状态详情。
radosgw-admin bucket stats --bucket abccc

root@u22c01:~# radosgw-admin bucket stats --bucket abccc
{
    "bucket": "abccc",
    "num_shards": 37,   # 一共有37个分片
    "tenant": "",
    "zonegroup": "844b2a85-e5d8-40a4-a875-a941523e251c",
    "placement_rule": "default-placement",
    "explicit_placement": {
        "data_pool": "",
        "data_extra_pool": "",
        "index_pool": ""
    },
    "id": "b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9",   # 桶分片索引
    "marker": "b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.1",
    "index_type": "Normal",
    "owner": "test",
    "ver": "0#190,1#189,2#183,3#190,4#182,5#201,6#191,7#197,8#174,9#183,10#188,11#194,12#204,13#192,14#190,15#171,16#196,17#191,18#202,19#196,20#196,21#194,22#185,23#185,24#179,25#191,26#185,27#197,28#176,29#180,30#191,31#196,32#184,33#185,34#194,35#188,36#208",
    "master_ver": "0#0,1#0,2#0,3#0,4#0,5#0,6#0,7#0,8#0,9#0,10#0,11#0,12#0,13#0,14#0,15#0,16#0,17#0,18#0,19#0,20#0,21#0,22#0,23#0,24#0,25#0,26#0,27#0,28#0,29#0,30#0,31#0,32#0,33#0,34#0,35#0,36#0",
    "mtime": "2024-09-26T10:31:16.678406Z",
    "creation_time": "2024-09-25T13:57:53.525125Z",
    "max_marker": "0#,1#,2#,3#,4#,5#,6#,7#,8#,9#,10#,11#,12#,13#,14#,15#,16#,17#,18#,19#,20#,21#,22#,23#,24#,25#,26#,27#,28#,29#,30#,31#,32#,33#,34#,35#,36#",
    "usage": {
        "rgw.main": {
            "size": 7851037,
            "size_actual": 684150784,
            "size_utilized": 7851037,
            "size_kb": 7668,
            "size_kb_actual": 668116,
            "size_kb_utilized": 7668,
            "num_objects": 166905
        }
    },
    "bucket_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": -1,
        "max_size_kb": 0,
        "max_objects": -1
    }
}


2. 查看桶分片索引

root@u22c01:~# rados ls -p default.rgw.buckets.index | grep b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9 | sort
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.0
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.1
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.10
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.11
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.12
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.13
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.14
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.15
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.16
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.17
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.18
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.19
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.2
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.20
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.21
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.22
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.23
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.24
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.25
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.26
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.27
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.28
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.29
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.3
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.30
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.31
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.32
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.33
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.34
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.35
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.36
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.4
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.5
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.6
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.7
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.8
.dir.b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9.9
root@u22c01:~#

3. 修改桶分片数
root@u22c01:~# radosgw-admin reshard add --bucket abccc --num-shards 64 --yes-i-really-mean-it

4. 查看当前分片操作中的桶

root@u22c01:~# radosgw-admin reshard add --bucket abccc --num-shards 64 --yes-i-really-mean-it
root@u22c01:~# radosgw-admin reshard list
[
    {
        "time": "2024-09-26T15:03:32.555544Z",
        "tenant": "",
        "bucket_name": "abccc",
        "bucket_id": "b8e366d3-0ab0-454e-9323-680528f5eccc.1054223.9",
        "new_instance_id": "",
        "old_num_shards": 37,
        "tentative_new_num_shards": 64
    }
]

5. 影响桶分片参数
    "rgw_dynamic_resharding": "true",    # 是否开启自动分片
    "rgw_max_objs_per_shard": "100000", # 单分片,最多容纳的文件数,建议在100000-125000万之间

### 总结: 
Ceph RGW 的 reshard 功能是一个强大的工具,可以帮助用户根据实际需求动态调整存储桶的分片数量,从而优化性能和资源利用率。通过合理使用该功能,用户可以确保其对象存储系统在面对变化的负载时,始终保持高效和可靠。 

备注:

        ceph 14 ,如果桶根目录下有中文文件夹或者中文文件,在发生分片时,会丢失。可以将中文文件/文件夹放到子目录里面,一级目录使用字母。ceph 17没有这个问题


原文地址:https://blog.csdn.net/liuy5277/article/details/142579996

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!