目的
测试实现 cephfs snapshot mirror 方法
实现两个集群 (CephFS) 实现数据同步
同步为异步方式
配合 snapshot schedule 实现两个 CephFS 集群异步自动数据统同步
参考
需求
主, 从 CephFS 集群
Ceph 必须满足 16 或上版本
主,从 Ceph 集群 fsid 不可以重复, CephFS 命名不可以重复
通过 snapshot 创建实现复制 snapshot 后数据至 从 CephFS 集群
CephFS 环境
测试主要用于验证数据同步及方法
CephFS 集群空间,性能暂不考虑
os | ceph | 角色 | CephFS 名称 | osd 分布 | ceph-mirror 进程 | mds 进程 |
---|---|---|---|---|---|---|
centos 8.4 | ceph-17.2.7-0 | 主 CephFS | test_fs | 3ssd(metadata) + 21 sata (datapool) | 3 | 3 |
centos 8.4 | ceph-17.2.7-0 | 从CephFS | snap_fs | 24sata (共用 data, metadatal) | 0 | 3 |
原理
CephFS 支持通过 cephfs-mirror工具将快照异步复制到远程 CephFS文件系统
快照的同步方法是镜像快照数据
测试总结
主 CephFS 集群器利用下文自动化文件创建脚本进行测试
每分钟创建 200 个 1MB 文件, 一小时 12000 个, 一天 288000 个文件
主集群器每小时创建一个 snapshot 并自动向从集群备份
当主 CephFS 集群文件数量达到一定程度 (当前约 2304000 个文件)snapshot mirror 无法完成
主 CephFS 集群所有 ceph-mds 进程不断故障 (mds 当前 32GB)
当前只对一个目录创建 snapshot, 并启动了 3 个 cephfs-mirror 进程,但只有一个 cephfs-mirror 进程负责对该目录进行数据同步
评估 snapshot mirrors 不可以用于生产
CephFS 主集群准备
创建用户
主 CephFS
首先在主 CephFS 创建用户用于 cephfs-mirror 进程使用
用户需要用于监视/通知操作的RADOS对象
需要数据池上的读取功能
参考命令
ceph auth get-or-create client.ns-yun-020057 mon 'profile cephfs-mirror' mds 'allow r' osd 'allow rw tag cephfs metadata=*, allow r tag cephfs data=*' mgr 'allow r'
[client.ns-yun-020057]
key = AQD...你的key...w==
从 CephFS
其次需要在从 CephFS 上创建用户
需要具备 mds, mgr, osd 具有访问功能
ceph fs authorize snap_fs client.snap_mirror / rwps
[client.snap_mirror]
key = AQD...你的key...w==
注意
上述命令虽然创建了用户
但用户没有 mgr 权限,因此需要手动添加权限否则后续会有问题
增加用户权限方法 (也可以参考这个命令直接创建用户)
# ceph auth caps client.snap_mirror mon 'allow r fsname=snap_fs' osd 'allow rw tag cephfs data=snap_fs' mds "allow rwps fsname=snap_fs" mgr "allow r"
updated caps for client.snap_mirror
启用 mirror 服务
只需要在 主 CephFS 集群中操作
安装软件
yum install -y cephfs-mirror.x86_64
导出之前创建的 client.ns-yun-020057 keyring
ceph auth get client.ns-yun-020057 -o /etc/ceph/vip-ceph.client.ns-yun-020057.keyring
启动 cephfs-mirror 服务
可以选择多个机器启动 cpehfs-mirror 服务(也可以一台服务器同时启动多个 cephfs-mirror 服务)实现并发同步多个目录
cephfs-mirror 使用简单的 M/N 策略共享同步负载,其中M是目录数,N是cephfs镜像守护进程数
多个 cephfs-mirror 进程提供了高可用方案
systemctl start cephfs-mirror@ns-yun-020057
systemctl enable cephfs-mirror@