TP CephFS-mirroring ANF CEPH 2022 du 03 au 07/10/2022 Sébastien Geiger # pour info cephadm est disponible depuis # https://download.ceph.com/rpm-17.2.3/el8/noarch/cephadm-17.2.3-0.el8.noarch.rpm #cluster A # depuis cephclt [almalinux@cephclt ~]$ for i in {1..4}; do ssh root@cna$i yum install -y podman lvm2; done [almalinux@cephclt ~]$ ssh cna1 [almalinux@cna1 ~]$ sudo yum -y install https://download.ceph.com/rpm-17.2.3/el8/noarch/cephadm-17.2.3-0.el8.noarch.rpm [almalinux@cna1 ~]$ monip=$(getent ahostsv4 cna1 |head -n 1| awk '{ print $1 }') [almalinux@cna1 ~]$ sudo cephadm bootstrap --mon-ip $monip --initial-dashboard-password demo1demo [almalinux@cna1 ~]$ for i in {2..4}; do ssh-copy-id -f -i /etc/ceph/ceph.pub root@cna$i; done [almalinux@cna1 ~]$ for i in {2..4}; do ssh root@cna$i yum -y install https://download.ceph.com/rpm-17.2.3/el8/noarch/cephadm-17.2.3-0.el8.noarch.rpm; done [almalinux@cna1 ~]$ sudo cephadm shell [ceph: root@cna1 /]# ceph -s # remarque regarder le nombre d'osd [ceph: root@cna1 /]# ceph orch host add cna2 [ceph: root@cna1 /]# ceph orch host add cna3 [ceph: root@cna1 /]# ceph orch host add cna4 [ceph: root@cna1 /]# ceph orch device ls [ceph: root@cna1 /]# ceph orch apply osd --all-available-devices [ceph: root@cna1 /]# ceph -W cephadm # attendre la fin du déployement des 8 osd [ceph: root@cna1 /]# ceph osd tree #cluster B # depuis cephclt [almalinux@cephclt ~]$ for i in {1..4}; do ssh root@cnb$i yum install -y podman lvm2; done [almalinux@cephclt ~]$ ssh cnb1 [almalinux@cnb1 ~]$ sudo yum -y install https://download.ceph.com/rpm-17.2.3/el8/noarch/cephadm-17.2.3-0.el8.noarch.rpm [almalinux@cnb1 ~]$ monip=$(getent ahostsv4 cnb1 |head -n 1| awk '{ print $1 }') [almalinux@cnb1 ~]$ sudo cephadm bootstrap --mon-ip $monip --initial-dashboard-password demo1demo [almalinux@cnb1 ~]$ for i in {2..4}; do ssh-copy-id -f -i /etc/ceph/ceph.pub root@cnb$i; done [almalinux@cnb1 ~]$ for i in {2..4}; do ssh root@cnb$i yum -y install https://download.ceph.com/rpm-17.2.3/el8/noarch/cephadm-17.2.3-0.el8.noarch.rpm; done [almalinux@cnb1 ~]$ sudo cephadm shell [ceph: root@cnb1 /]# ceph -s # remarque regarder le nombre d'osd [ceph: root@cnb1 /]# ceph orch host add cnb2 [ceph: root@cnb1 /]# ceph orch host add cnb3 [ceph: root@cnb1 /]# ceph orch host add cnb4 [ceph: root@cnb1 /]# ceph orch device ls [ceph: root@cnb1 /]# ceph orch apply osd --all-available-devices [ceph: root@cnb1 /]# ceph -W cephadm # attendre la fin [ceph: root@cnb1 /]# ceph osd tree #CephFS-mirroring Le système de fichiers Ceph (CephFS) prend en charge la réplication asynchrone vers un système de fichiers Ceph distant sur un autre cluster Ceph. La synchronisation des snapshots copie les données des snapshots vers un système de fichiers Ceph distant et crée un nouvel snapshot sur la cible distante avec le même nom. Vous pouvez configurer des répertoires spécifiques pour la synchronisation de snapshots. La gestion des miroirs CephFS est effectuée par le démon CephFS mirroring (cephfs-mirror). # Remarques : - Les "Hard linked files" sont synchronisée comme des fichiers séparés. - Seulement un service cephfs-mirror par cluster. il n'est pas encore possible d'avoir de multiple instance. - le TP permet de découvrir le fonctionnement de cephfs-mirroring. pour simplifier la configuration le montage montage du site de production et de backup est effectué sur le même client, avec l'utilisation des clés d'authentification du compte admin du cluster ceph. - Des actions sont a réaliser soit sur le cluster A ou B ou sur le client. vérifier bien d'ou vous lancer les différentes commandes. # creation de cephfs sur le sitea [almalinux@cephclt ~]$ ssh cna1 [almalinux@cna1 ~]$ sudo cephadm shell [ceph: root@cna1 /]# ceph fs volume create cephfs [ceph: root@cna1 /]# ceph orch apply cephfs-mirror cna3 # creation de cephfs sur le siteb [almalinux@cephclt ~]$ ssh cnb1 [almalinux@cnb1 ~]$ sudo cephadm shell [ceph: root@cnb1 /]# ceph fs volume create cephfs [ceph: root@cnb1 /]# ceph fs authorize cephfs client.mirror_remote / rwps [client.mirror_remote] key = AQB+wrpi/fnhKBAAIVBfPTNsz1kFhiepKqaOBg== [ceph: root@cna1 /]# ceph mgr module enable mirroring module 'mirroring' is already enabled [ceph: root@cna1 /]# ceph fs snapshot mirror enable cephfs {} [ceph: root@cnb1 /]# ceph mgr module enable mirroring [ceph: root@cnb1 /]# ceph fs snapshot mirror peer_bootstrap create cephfs client.mirror_remote remote-site {"token": "eyJmc2lkIjogIjU0NjBjMjQyLWY2MGMtMTFlYy04NWU3LWZhMTYzZTUwYjVkMSIsICJmaWxlc3lzdGVtIjogImNlcGhmcyIsICJ1c2VyIjogImNsaWVudC5taXJyb3JfcmVtb3RlIiwgInNpdGVfbmFtZSI6ICJyZW1vdGUtc2l0ZSIsICJrZXkiOiAiQVFCK3dycGkvZm5oS0JBQUlWQmZQVE5zejFrRmhpZXBLcWFPQmc9PSIsICJtb25faG9zdCI6ICJbdjI6MTcyLjE2LjcuNDA6MzMwMC8wLHYxOjE3Mi4xNi43LjQwOjY3ODkvMF0gW3YyOjE3Mi4xNi43Ljk5OjMzMDAvMCx2MToxNzIuMTYuNy45OTo2Nzg5LzBdIFt2MjoxNzIuMTYuNy4xNzY6MzMwMC8wLHYxOjE3Mi4xNi43LjE3Njo2Nzg5LzBdIFt2MjoxNzIuMTYuNy40MzozMzAwLzAsdjE6MTcyLjE2LjcuNDM6Njc4OS8wXSJ9"} [ceph: root@cna1 /]# ceph fs snapshot mirror peer_bootstrap import cephfs "eyJmc2lkIjogIjU0NjBjMjQyLWY2MGMtMTFlYy04NWU3LWZhMTYzZTUwYjVkMSIsICJmaWxlc3lzdGVtIjogImNlcGhmcyIsICJ1c2VyIjogImNsaWVudC5taXJyb3JfcmVtb3RlIiwgInNpdGVfbmFtZSI6ICJyZW1vdGUtc2l0ZSIsICJrZXkiOiAiQVFCK3dycGkvZm5oS0JBQUlWQmZQVE5zejFrRmhpZXBLcWFPQmc9PSIsICJtb25faG9zdCI6ICJbdjI6MTcyLjE2LjcuNDA6MzMwMC8wLHYxOjE3Mi4xNi43LjQwOjY3ODkvMF0gW3YyOjE3Mi4xNi43Ljk5OjMzMDAvMCx2MToxNzIuMTYuNy45OTo2Nzg5LzBdIFt2MjoxNzIuMTYuNy4xNzY6MzMwMC8wLHYxOjE3Mi4xNi43LjE3Njo2Nzg5LzBdIFt2MjoxNzIuMTYuNy40MzozMzAwLzAsdjE6MTcyLjE2LjcuNDM6Njc4OS8wXSJ9" {} [ceph: root@cna1 /]# ceph fs snapshot mirror peer_list cephfs {"2a75774b-1514-4a72-9cb2-19ad1589126e": {"client_name": "client.mirror_remote", "site_name": "remote-site", "fs_name": "cephfs", "mon_host": "[v2:172.16.7.40:3300/0,v1:172.16.7.40:6789/0] [v2:172.16.7.99:3300/0,v1:172.16.7.99:6789/0] [v2:172.16.7.176:3300/0,v1:172.16.7.176:6789/0] [v2:172.16.7.43:3300/0,v1:172.16.7.43:6789/0]"}} # remarque : c'est configuré assez facilement. # configuration du coté du client maintenant [root@cephclt ~]# yum install -y centos-release-ceph-pacific.noarch [root@cephclt ~]# yum install -y ceph-common [root@cephclt ~]# mkdir /prod/ [root@cephclt ~]# mkdir /back/ [ceph: root@cna1 /]# grep key /etc/ceph/ceph.keyring key = AQAX4LViZ7/bDBAAXI3DHp6JLRRzPyMs5RL7OQ== # remplacer la valeur en fonctionne de votre environnement [root@cephclt ~]# echo AQAX4LViZ7/bDBAAXI3DHp6JLRRzPyMs5RL7OQ== >/etc/ceph/sitea.cephfs [root@cephclt ~]# mount -t ceph cna1,cna2,cna3,cna4:/ /prod -o name=admin,secretfile=/etc/ceph/sitea.cephfs [root@cephclt ~]# df -h /prod Filesystem Size Used Avail Use% Mounted on 172.16.7.23,172.16.7.114,172.16.7.110,172.16.7.237:/ 102G 0 102G 0% /prod [root@cephclt ~]# mkdir /prod/rep1 [root@cephclt ~]# mkdir /prod/rep2 [root@cephclt ~]# echo file1 >/prod/rep1/file1 [root@cephclt ~]# echo file2 >/prod/rep2/file2 [ceph: root@cnb1 /]# grep key /etc/ceph/ceph.keyring key = AQCPlLlie3jLABAAFF5+4/2YdsiNcX7xEZ9QLA== [root@cephclt ~]# echo AQCPlLlie3jLABAAFF5+4/2YdsiNcX7xEZ9QLA== >/etc/ceph/siteb.cephfs [root@cephclt ~]# mount -t ceph cnb1,cnb2,cnb3,cnb4:/ /back -o name=admin,secretfile=/etc/ceph/siteb.cephfs [root@cephclt ~]# df -h /back Filesystem Size Used Avail Use% Mounted on 172.16.7.249,172.16.7.220,172.16.7.93,172.16.7.88:/ 102G 0 102G 0% /back # vérification si deja des fichiers ? [root@cephclt ~]# grep -R . /back # activation du mirror de rep1 [ceph: root@cna1 /]# ceph fs snapshot mirror add cephfs /rep1 {} [root@cephclt ~]# grep -R . /back # pas encore de mirror [root@cephclt ~]# mkdir /prod/rep1/.snap/s1 [root@cephclt ~]# grep -R . /back /back/rep1/file1:file1 # ok pour rep1 il faut faire un snap pour que la copie se réalise. #activation de rep2 [ceph: root@cna1 /]# ceph fs snapshot mirror add cephfs /rep2 {} [root@cephclt ~]# grep -R . /back /back/rep1/file1:file1 [root@cephclt ~]# mkdir /prod/rep2/.snap/s1 [root@cephclt ~]# grep -R . /back /back/rep2/file2:file2 /back/rep1/file1:file1 [root@cephclt ~]# ls /back/rep1/.snap/ s1 [root@cephclt ~]# ls /back/rep2/.snap/ s1 # ok le mirror snap fait sont travail # utilisation du module pour la gestion automatique des snaps sous CephFS [ceph: root@cna1 /]# ceph fs set cephfs allow_new_snaps true enabled new snapshots [ceph: root@cna1 /]# ceph mgr module enable snap_schedule [ceph: root@cna1 /]# ceph fs snap-schedule add /rep1 1h Schedule set for path /rep1 [ceph: root@cna1 /]# ceph fs snap-schedule retention add /rep1 h 24 Retention added to path /rep1 [ceph: root@cna1 /]# ceph fs snap-schedule add /rep2 2h Schedule set for path /rep2 [ceph: root@cna1 /]# ceph fs snap-schedule retention add /rep2 h 24 Retention added to path /rep2 [ceph: root@cna1 /]# ceph fs snap-schedule list / --recursive=true /rep1 1h 24h /rep2 2h 24h # par défaut, utiliser le module snap_schedule pour créer les snaps sur chaque branche. # il n'est pas possible de gérer une prédiode inférieur à l'heure [root@cephclt ~]# echo "activation schedule" > /prod/rep1/prod.txt [root@cephclt ~]# echo siteAprod >>/prod/rep1/prod.txt [root@cephclt ~]# mkdir /prod/rep1/.snap/s2 [root@cephclt ~]# grep -R . /back /back/rep2/file2:file2 /back/rep1/file1:file1 /back/rep1/prod.txt:activation schedule /back/rep1/prod.txt:siteAprod # Cluster A (sitea) est en production. tout va bien ;) le cluster B (siteb) recois les copies des fichiers. # vérification [ceph: root@cna1 /]# ceph -s cluster: id: eb65901a-f3d6-11ec-8d25-fa163ea7c9dc health: HEALTH_OK services: mon: 4 daemons, quorum cna1,cna2,cna3,cna4 (age 24h) mgr: cna1.ryzfcr(active, since 3h), standbys: cna2.opgfse mds: 1/1 daemons up, 1 standby osd: 8 osds: 8 up (since 24h), 8 in (since 24h) cephfs-mirror: 1 daemon active (1 hosts) data: volumes: 1/1 healthy pools: 3 pools, 49 pgs objects: 35 objects, 1.3 MiB usage: 191 MiB used, 320 GiB / 320 GiB avail pgs: 49 active+clean # On va faire un basculement vers le cluster B (siteb) [root@cephclt ~]# [root@cephclt ~]# umount /prod [root@cephclt ~]# umount /back [root@cephclt ~]# mount -t ceph cnb1,cnb2,cnb3,cnb4:/ /prod -o name=admin,secretfile=/etc/ceph/siteb.cephfs [root@cephclt ~]# mount -t ceph cna1,cna2,cna3,cna4:/ /back -o name=admin,secretfile=/etc/ceph/sitea.cephfs [root@cephclt ~]# echo "basculement siteb prod" >>/prod/rep1/prod.txt [root@cephclt ~]# grep -R . /prod/ /prod/rep2/file2:file2 /prod/rep1/file1:file1 /prod/rep1/prod.txt:activation schedule /prod/rep1/prod.txt:siteAprod /prod/rep1/prod.txt:basculement siteb prod [root@cephclt ~]# mkdir /prod/rep1/.snap/sitebprod # sync de la différence [root@cephclt ~]# rsync -arv /prod/ /back sending incremental file list ./ rep1/ rep1/prod.txt rep2/ sent 278 bytes received 50 bytes 656.00 bytes/sec total size is 65 speedup is 0.20 [root@cephclt ~]# umount /prod [root@cephclt ~]# umount /back [root@cephclt ~]# mount -t ceph cna1,cna2,cna3,cna4:/ /prod -o name=admin,secretfile=/etc/ceph/sitea.cephfs [root@cephclt ~]# mount -t ceph cnb1,cnb2,cnb3,cnb4:/ /back/ -o name=admin,secretfile=/etc/ceph/siteb.cephfs [root@cephclt ~]# echo "reprise prod sitea" >>/prod/rep1/prod.txt [root@cephclt ~]# grep -R . /prod/ /prod/rep2/file2:file2 /prod/rep1/file1:file1 /prod/rep1/prod.txt:activation schedule /prod/rep1/prod.txt:siteAprod /prod/rep1/prod.txt:basculement siteb prod /prod/rep1/prod.txt:reprise prod sitea [root@cephclt ~]# mkdir /prod/rep1/.snap/siteaprod [root@cephclt ~]# grep -R . /back /back/rep2/file2:file2 /back/rep1/file1:file1 /back/rep1/prod.txt:activation schedule /back/rep1/prod.txt:siteAprod /back/rep1/prod.txt:basculement siteb prod # il manque la ligne reprise prod sitea ! # probablement un probleme de point de reprise avec les snapshots # il faut repartir d'un même snapshot entre sitea et siteb, pour cela supprimer les snap du siteb qui ont été rajouté [root@cephclt ~]# rmdir /back/rep1/.snap/sitebprod # apres quelques secondes le mirroring applique les différences [root@cephclt ~]# grep -R . /back /back/rep2/file2:file2 /back/rep1/file1:file1 /back/rep1/prod.txt:activation schedule /back/rep1/prod.txt:siteAprod /back/rep1/prod.txt:basculement siteb prod /back/rep1/prod.txt:reprise prod sitea [root@cephclt ~]# # voila c'est corrigé. # sitea est a nouveau le primaire et les snaps sont a nouveau en mirroir vers siteb # vérification [root@cephclt ~]# ls /prod/rep1/.snap s1 scheduled-2022-06-28-10_00_00 scheduled-2022-06-28-12_00_00 sitea2 s2 scheduled-2022-06-28-11_00_00 scheduled-2022-06-28-13_00_00 siteaprod [root@cephclt ~]# ls /back/rep1/.snap s1 scheduled-2022-06-28-10_00_00 scheduled-2022-06-28-12_00_00 sitea2 s2 scheduled-2022-06-28-11_00_00 scheduled-2022-06-28-13_00_00 siteaprod # Remarque: on liste effectivement les mêmes snapshots sur sitea et siteb incluant les "scheduled snap" # Documentation : https://ceph.io/en/news/blog/2021/new-in-pacific-cephfs-updates/ https://access.redhat.com/documentation/us-us/red_hat_ceph_storage/5/html/file_system_guide/ceph-file-system-administration#ceph-file-system-mirroring_fs Remarques: cephfs-mirroring est stable depuis la version 16.2.5 d'après les remarques sur les forums c'est dommange qu'il n'y a pas de mode cephfs-mirroring tow-way pour gérer le basculement du site primaire au secondaire comme sous rbd-mirroring pas d'information de le dashbord concernant ce service fonctionnement simple et plutot facile a mettre en place. a noté que c'est sur sitea ou il faut installer le service cephfs-mirroring la fonction 'mirror peer_bootstrap import' fonctionne du premier cout;) question: avant de basculer de site, il faudrait passer cephfs en lecture seul pour eviter que certains clients puisse encore ecrir. j'ai pas trouvé de commande ou de sénario a ce sujet. # log cephfs-mirroring [almalinux@cephclt ~]$ ssh root@cna3 [root@cna3 ~]# cephadm ls |grep mirror "name": "cephfs-mirror.cna3.lnqvhf", [root@cna3 ~]# cephadm enter --name cephfs-mirror.cna3.lnqvhf Inferring fsid eb65901a-f3d6-11ec-8d25-fa163ea7c9dc # il y a 2 fichiers asok dans /var/run/ceph/ceph-client.xxxx.asok dont un avec des informations sur concernant le mirroring [ceph: root@cna3 /]# ceph --admin-daemon /var/run/ceph/ceph-client.cephfs-mirror.cna3.lnqvhf.6.94099788142120.asok help |grep mirror "fs mirror peer status cephfs@1 faf1841d-9315-457d-a06e-8a94782214be": "get peer mirror status", "fs mirror status cephfs@1": "get filesystem mirror status", # utiliser ces informations pour intéroger le daemon cephfs-mirror [ceph: root@cna3 /]# ceph --admin-daemon /var/run/ceph/ceph-client.cephfs-mirror.cna3.lnqvhf.6.94099788142120.asok fs mirror peer status cephfs@1 faf1841d-9315-457d-a06e-8a94782214be { "/rep1": { "state": "idle", "last_synced_snap": { "id": 14, "name": "scheduled-2022-06-28-14_00_01", "sync_duration": 0.81499630300000003, "sync_time_stamp": "339936.645480s" }, "snaps_synced": 4, "snaps_deleted": 0, "snaps_renamed": 0 }, "/rep2": { "state": "idle", "last_synced_snap": { "id": 13, "name": "scheduled-2022-06-28-14_00_00", "sync_duration": 0.75199658899999999, "sync_time_stamp": "339936.509480s" }, "snaps_synced": 1, "snaps_deleted": 0, "snaps_renamed": 0 } } [ceph: root@cna3 /]# ceph --admin-daemon /var/run/ceph/ceph-client.cephfs-mirror.cna3.lnqvhf.6.94099788142120.asok fs mirror status cephfs@1 { "rados_inst": "172.16.7.110:0/4103436696", "peers": { "faf1841d-9315-457d-a06e-8a94782214be": { "remote": { "client_name": "client.mirror_remote", "cluster_name": "remote-site", "fs_name": "cephfs" } } }, "snap_dirs": { "dir_count": 2 } } # systemctl fournit également des informations de log sur le service, comme par exemple le nom du snapshot qui posait un probleme lors de la reprise de la synchronisation [root@cna3 ~]# systemctl status ceph-eb65901a-f3d6-11ec-8d25-fa163ea7c9dc@cephfs-mirror.cna3.lnqvhf.service ... Jun 28 12:28:42 cna3 cephfs-mirror[174446]: cephfs::mirror::PeerReplayer(faf1841d-9315-457d-a06e-8a94782214be) build_snap_map: snap_path=/rep1/.snap/sitebprod has invalid metadata in remote snapshot ...