6.13. 在非并置场景中替换 OSD

当 OSD 在非并置场景中失败时,您可以替换 WAL/DB 设备。DB 和 WAL 设备的步骤相同。您需要为 DB 设备编辑 db_devices 下的 paths, 为 WAL 设备 编辑 wal_devices 下的 paths

先决条件

  • 一个正在运行的 Red Hat Ceph Storage 集群。
  • 守护进程是非并置的。
  • 失败的 OSD

流程

  1. 识别集群中的设备:

    示例

    [root@host01 ~]# lsblk
    
    NAME                                                                                                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda                                                                                                     8:0    0   20G  0 disk
    ├─sda1                                                                                                  8:1    0    1G  0 part /boot
    └─sda2                                                                                                  8:2    0   19G  0 part
      ├─rhel-root                                                                                         253:0    0   17G  0 lvm  /
      └─rhel-swap                                                                                         253:1    0    2G  0 lvm  [SWAP]
    sdb                                                                                                     8:16   0   10G  0 disk
    └─ceph--5726d3e9--4fdb--4eda--b56a--3e0df88d663f-osd--block--3ceb89ec--87ef--46b4--99c6--2a56bac09ff0 253:2    0   10G  0 lvm
    sdc                                                                                                     8:32   0   10G  0 disk
    └─ceph--d7c9ab50--f5c0--4be0--a8fd--e0313115f65c-osd--block--37c370df--1263--487f--a476--08e28bdbcd3c 253:4    0   10G  0 lvm
    sdd                                                                                                     8:48   0   10G  0 disk
    ├─ceph--1774f992--44f9--4e78--be7b--b403057cf5c3-osd--db--31b20150--4cbc--4c2c--9c8f--6f624f3bfd89    253:7    0  2.5G  0 lvm
    └─ceph--1774f992--44f9--4e78--be7b--b403057cf5c3-osd--db--1bee5101--dbab--4155--a02c--e5a747d38a56    253:9    0  2.5G  0 lvm
    sde                                                                                                     8:64   0   10G  0 disk
    sdf                                                                                                     8:80   0   10G  0 disk
    └─ceph--412ee99b--4303--4199--930a--0d976e1599a2-osd--block--3a99af02--7c73--4236--9879--1fad1fe6203d 253:6    0   10G  0 lvm
    sdg                                                                                                     8:96   0   10G  0 disk
    └─ceph--316ca066--aeb6--46e1--8c57--f12f279467b4-osd--block--58475365--51e7--42f2--9681--e0c921947ae6 253:8    0   10G  0 lvm
    sdh                                                                                                     8:112  0   10G  0 disk
    ├─ceph--d7064874--66cb--4a77--a7c2--8aa0b0125c3c-osd--db--0dfe6eca--ba58--438a--9510--d96e6814d853    253:3    0    5G  0 lvm
    └─ceph--d7064874--66cb--4a77--a7c2--8aa0b0125c3c-osd--db--26b70c30--8817--45de--8843--4c0932ad2429    253:5    0    5G  0 lvm
    sr0

  2. 登录到 Cephadm shell:

    示例

    [root@host01 ~]# cephadm shell

  3. 识别 OSD 及其 DB 设备:

    示例

    [ceph: root@host01 /]# ceph-volume lvm list /dev/sdh
    
    
    ====== osd.2 =======
    
      [db]          /dev/ceph-d7064874-66cb-4a77-a7c2-8aa0b0125c3c/osd-db-0dfe6eca-ba58-438a-9510-d96e6814d853
    
          block device              /dev/ceph-5726d3e9-4fdb-4eda-b56a-3e0df88d663f/osd-block-3ceb89ec-87ef-46b4-99c6-2a56bac09ff0
          block uuid                GkWLoo-f0jd-Apj2-Zmwj-ce0h-OY6J-UuW8aD
          cephx lockbox secret
          cluster fsid              fa0bd9dc-e4c4-11ed-8db4-001a4a00046e
          cluster name              ceph
          crush device class
          db device                 /dev/ceph-d7064874-66cb-4a77-a7c2-8aa0b0125c3c/osd-db-0dfe6eca-ba58-438a-9510-d96e6814d853
          db uuid                   6gSPoc-L39h-afN3-rDl6-kozT-AX9S-XR20xM
          encrypted                 0
          osd fsid                  3ceb89ec-87ef-46b4-99c6-2a56bac09ff0
          osd id                    2
          osdspec affinity          non-colocated
          type                      db
          vdo                       0
          devices                   /dev/sdh
    
    ====== osd.5 =======
    
      [db]          /dev/ceph-d7064874-66cb-4a77-a7c2-8aa0b0125c3c/osd-db-26b70c30-8817-45de-8843-4c0932ad2429
    
          block device              /dev/ceph-d7c9ab50-f5c0-4be0-a8fd-e0313115f65c/osd-block-37c370df-1263-487f-a476-08e28bdbcd3c
          block uuid                Eay3I7-fcz5-AWvp-kRcI-mJaH-n03V-Zr0wmJ
          cephx lockbox secret
          cluster fsid              fa0bd9dc-e4c4-11ed-8db4-001a4a00046e
          cluster name              ceph
          crush device class
          db device                 /dev/ceph-d7064874-66cb-4a77-a7c2-8aa0b0125c3c/osd-db-26b70c30-8817-45de-8843-4c0932ad2429
          db uuid                   mwSohP-u72r-DHcT-BPka-piwA-lSwx-w24N0M
          encrypted                 0
          osd fsid                  37c370df-1263-487f-a476-08e28bdbcd3c
          osd id                    5
          osdspec affinity          non-colocated
          type                      db
          vdo                       0
          devices                   /dev/sdh

  4. osds.yaml 文件中,将 unmanaged 参数设置为 true,否则 cephadm 会重新部署 OSD:

    示例

    [ceph: root@host01 /]# cat osds.yml
    service_type: osd
    service_id: non-colocated
    unmanaged: true
    placement:
      host_pattern: 'ceph*'
    data_devices:
      paths:
       - /dev/sdb
       - /dev/sdc
       - /dev/sdf
       - /dev/sdg
    db_devices:
      paths:
       - /dev/sdd
       - /dev/sdh

  5. 应用更新的规格文件:

    示例

    [ceph: root@host01 /]# ceph orch apply -i osds.yml
    
    Scheduled osd.non-colocated update...

  6. 检查状态:

    示例

    [ceph: root@host01 /]# ceph orch ls
    
    NAME           PORTS        RUNNING  REFRESHED  AGE  PLACEMENT
    alertmanager   ?:9093,9094      1/1  9m ago     4d   count:1
    crash                           3/4  4d ago     4d   *
    grafana        ?:3000           1/1  9m ago     4d   count:1
    mgr                             1/2  4d ago     4d   count:2
    mon                             3/5  4d ago     4d   count:5
    node-exporter  ?:9100           3/4  4d ago     4d   *
    osd.non-colocated                 8  4d ago     5s   <unmanaged>
    prometheus     ?:9095           1/1  9m ago     4d   count:1

  7. 移除 OSD。确保使用 --zap 选项删除 hte backend 服务和 --replace 选项来保留 OSD ID:

    示例

    [ceph: root@host01 /]# ceph orch osd rm 2 5 --zap --replace
    Scheduled OSD(s) for removal

  8. 检查状态:

    示例

    [ceph: root@host01 /]# ceph osd df tree | egrep -i "ID|host02|osd.2|osd.5"
    
    ID  CLASS  WEIGHT   REWEIGHT  SIZE     RAW USE  DATA     OMAP  META     AVAIL   %USE   VAR   PGS  STATUS     TYPE NAME
    -5         0.04877         -   55 GiB   15 GiB  4.1 MiB   0 B   60 MiB  40 GiB  27.27  1.17    -                 host02
     2    hdd  0.01219   1.00000   15 GiB  5.0 GiB  996 KiB   0 B   15 MiB  10 GiB  33.33  1.43    0  destroyed          osd.2
     5    hdd  0.01219   1.00000   15 GiB  5.0 GiB  1.0 MiB   0 B   15 MiB  10 GiB  33.33  1.43    0  destroyed          osd.5

  9. 编辑 osds.yaml 规格文件,将 unmanaged 参数改为 false,并在设备物理替换后替换 DB 设备的路径:

    示例

    [ceph: root@host01 /]# cat osds.yml
    service_type: osd
    service_id: non-colocated
    unmanaged: false
    placement:
      host_pattern: 'ceph01*'
    data_devices:
      paths:
       - /dev/sdb
       - /dev/sdc
       - /dev/sdf
       - /dev/sdg
    db_devices:
      paths:
       - /dev/sdd
       - /dev/sde

    在上例中,/dev/sdh 替换为 /dev/sde

    重要

    如果您使用同一主机规格文件替换单个 OSD 节点上的故障 DB 设备,请修改 host_pattern 选项以仅指定 OSD 节点,否则部署会失败,您无法在其他主机上找到新的 DB 设备。

  10. 使用 --dry-run 选项重新应用规格文件,以确保 OSD 应该使用新的 DB 设备部署:

    示例

    [ceph: root@host01 /]# ceph orch apply -i osds.yml --dry-run
    WARNING! Dry-Runs are snapshots of a certain point in time and are bound
    to the current inventory setup. If any of these conditions change, the
    preview will be invalid. Please make sure to have a minimal
    timeframe between planning and applying the specs.
    ####################
    SERVICESPEC PREVIEWS
    ####################
    +---------+------+--------+-------------+
    |SERVICE  |NAME  |ADD_TO  |REMOVE_FROM  |
    +---------+------+--------+-------------+
    +---------+------+--------+-------------+
    ################
    OSDSPEC PREVIEWS
    ################
    +---------+-------+-------+----------+----------+-----+
    |SERVICE  |NAME   |HOST   |DATA      |DB        |WAL  |
    +---------+-------+-------+----------+----------+-----+
    |osd      |non-colocated  |host02  |/dev/sdb  |/dev/sde  |-    |
    |osd      |non-colocated  |host02  |/dev/sdc  |/dev/sde  |-    |
    +---------+-------+-------+----------+----------+-----+

  11. 应用规格文件:

    示例

    [ceph: root@host01 /]# ceph orch apply -i osds.yml
    Scheduled osd.non-colocated update...

  12. 检查 OSD 是否已重新部署:

    示例

    [ceph: root@host01 /]# ceph osd df tree | egrep -i "ID|host02|osd.2|osd.5"
    
    ID  CLASS  WEIGHT   REWEIGHT  SIZE     RAW USE  DATA     OMAP  META     AVAIL   %USE   VAR   PGS  STATUS  TYPE NAME
    -5         0.04877         -   55 GiB   15 GiB  4.5 MiB   0 B   60 MiB  40 GiB  27.27  1.17    -              host host02
     2    hdd  0.01219   1.00000   15 GiB  5.0 GiB  1.1 MiB   0 B   15 MiB  10 GiB  33.33  1.43    0      up          osd.2
     5    hdd  0.01219   1.00000   15 GiB  5.0 GiB  1.1 MiB   0 B   15 MiB  10 GiB  33.33  1.43    0      up          osd.5

验证

  1. 在重新部署 OSDS 的 OSD 主机中,验证它们是否在新的 DB 设备上:

    示例

    [ceph: root@host01 /]# ceph-volume lvm list /dev/sde
    
    ====== osd.2 =======
    
      [db]          /dev/ceph-15ce813a-8a4c-46d9-ad99-7e0845baf15e/osd-db-1998a02e-5e67-42a9-b057-e02c22bbf461
    
          block device              /dev/ceph-a4afcb78-c804-4daf-b78f-3c7ad1ed0379/osd-block-564b3d2f-0f85-4289-899a-9f98a2641979
          block uuid                ITPVPa-CCQ5-BbFa-FZCn-FeYt-c5N4-ssdU41
          cephx lockbox secret
          cluster fsid              fa0bd9dc-e4c4-11ed-8db4-001a4a00046e
          cluster name              ceph
          crush device class
          db device                 /dev/ceph-15ce813a-8a4c-46d9-ad99-7e0845baf15e/osd-db-1998a02e-5e67-42a9-b057-e02c22bbf461
          db uuid                   HF1bYb-fTK7-0dcB-CHzW-xvNn-dCym-KKdU5e
          encrypted                 0
          osd fsid                  564b3d2f-0f85-4289-899a-9f98a2641979
          osd id                    2
          osdspec affinity          non-colocated
          type                      db
          vdo                       0
          devices                   /dev/sde
    
    ====== osd.5 =======
    
      [db]          /dev/ceph-15ce813a-8a4c-46d9-ad99-7e0845baf15e/osd-db-6c154191-846d-4e63-8c57-fc4b99e182bd
    
          block device              /dev/ceph-b37c8310-77f9-4163-964b-f17b4c29c537/osd-block-b42a4f1f-8e19-4416-a874-6ff5d305d97f
          block uuid                0LuPoz-ao7S-UL2t-BDIs-C9pl-ct8J-xh5ep4
          cephx lockbox secret
          cluster fsid              fa0bd9dc-e4c4-11ed-8db4-001a4a00046e
          cluster name              ceph
          crush device class
          db device                 /dev/ceph-15ce813a-8a4c-46d9-ad99-7e0845baf15e/osd-db-6c154191-846d-4e63-8c57-fc4b99e182bd
          db uuid                   SvmXms-iWkj-MTG7-VnJj-r5Mo-Moiw-MsbqVD
          encrypted                 0
          osd fsid                  b42a4f1f-8e19-4416-a874-6ff5d305d97f
          osd id                    5
          osdspec affinity          non-colocated
          type                      db
          vdo                       0
          devices                   /dev/sde