Ceph with multipath

multipath code block in this doesn't work.
I tried fixing it up but still doesn't work
Bash:
for f in $(multipath -l |  grep dm-  | awk '{ print $1 }')
do
    pvcreate --metadatasize 250k -y -ff /dev/mapper/$f-part1
    vgcreate vg$f /dev/mapper/$f-part1
    lvcreate -n lv0 -l 100%FREE vg$f
    ceph-volume lvm prepare --data /dev/vg$f/lv0
done

ceph-volume lvm activate --all

I get
Code:
  Physical volume "/dev/mapper/35000cca03100fe6c" successfully created.
  Volume group "vg35000cca03100fe6c" successfully created
  Logical volume "lv0" created.
Running command: /usr/bin/ceph-authtool --gen-print-key
Running command: /usr/bin/ceph --cluster ceph --name client.bootstrap-osd --keyring /var/lib/ceph/bootstrap-osd/ceph.keyring -i - osd new 895b1b2b-2677-4d1b-8274-605c3567ad55
 stderr: 2022-07-28T13:09:06.065+0100 7fd9f8f8e700 -1 auth: unable to find a keyring on /etc/pve/priv/ceph.client.bootstrap-osd.keyring: (2) No such file or directory
 stderr: 2022-07-28T13:09:06.065+0100 7fd9f8f8e700 -1 AuthRegistry(0x7fd9f405b868) no keyring found at /etc/pve/priv/ceph.client.bootstrap-osd.keyring, disabling cephx
 stderr: 2022-07-28T13:09:06.069+0100 7fd9f359e700 -1 auth: unable to find a keyring on /var/lib/ceph/bootstrap-osd/ceph.keyring: (2) No such file or directory
 stderr: 2022-07-28T13:09:06.069+0100 7fd9f359e700 -1 AuthRegistry(0x7fd9f405b868) no keyring found at /var/lib/ceph/bootstrap-osd/ceph.keyring, disabling cephx
 stderr: 2022-07-28T13:09:06.069+0100 7fd9f359e700 -1 auth: unable to find a keyring on /var/lib/ceph/bootstrap-osd/ceph.keyring: (2) No such file or directory
 stderr: 2022-07-28T13:09:06.069+0100 7fd9f359e700 -1 AuthRegistry(0x7fd9f4061d40) no keyring found at /var/lib/ceph/bootstrap-osd/ceph.keyring, disabling cephx
 stderr: 2022-07-28T13:09:06.069+0100 7fd9f359e700 -1 auth: unable to find a keyring on /var/lib/ceph/bootstrap-osd/ceph.keyring: (2) No such file or directory
 stderr: 2022-07-28T13:09:06.069+0100 7fd9f359e700 -1 AuthRegistry(0x7fd9f359d0d0) no keyring found at /var/lib/ceph/bootstrap-osd/ceph.keyring, disabling cephx
 stderr: [errno 2] RADOS object not found (error connecting to the cluster)
-->  RuntimeError: Unable to create a new OSD id
Your missing the keyring

See https://forum.proxmox.com/threads/u...-found-error-connecting-to-the-cluster.78961/
 
Btw, i changed my script a little bit. My multipath devices are named "mpathXX". If yours are named different, you need to change the script.

Bash:
#!/bin/bash

DRYRUN=0

if [[ "$1" == "--dryrun" ]]
then
    DRYRUN=1
fi

readarray -t cdevs < <(ceph-volume lvm list | grep -o -E "/dev/mapper/mpath.*" | sed 's/\/dev\/mapper\///g')
declare -a skipped

for mdev in $(multipath -l)
do
    if [[ " ${cdevs[*]} " =~ " ${mdev} " ]]
    then
        skipped+=("${mdev}")
    elif [[ $DRYRUN -eq 1 ]]
    then
        echo "> Would create OSD from ${mdev}"
    else
        echo "> Creating OSD from ${mdev}"
        pvcreate --metadatasize 250k -y -ff /dev/mapper/${mdev}
        vgcreate vg${mdev} /dev/mapper/${mdev}
        lvcreate -n lv0 -l 100%FREE vg${mdev}
        ceph-volume lvm prepare --data /dev/vg${mdev}/lv0
    fi
done

echo "> You need to activate the new OSDs with \"ceph-volume lvm activate --all\""

if [[ "${#skipped[@]}" -gt 0 ]]
then
    echo -e "\n> Following devices are already in OSD map and have been skipped.\n"

    for d in "${skipped[@]}"
    do
        echo ">> ${d}"
    done
fi
 
Last edited:
And in case someone needs a script to list OSDs with corresponding devices (incl. multipath and their member disks) as well as not used multipath devices.

Bash:
#!/bin/bash

data=$(ceph-volume lvm list --format json)

ar=($(echo $data | jq -r 'to_entries | sort_by(.key | tonumber) | map(.key + ":" + .value[0].lv_size + ":" + (.value[0].devices | join( ",")))' | tr -d '[],"'))
mapped=($(ls /dev/mapper/mpath*))

echo -e "\n------------------------------"
echo -e "OSD count: ${#ar[@]}\n"

for f in "${ar[@]}"
do
        values=(${f//:/ })
        device=${values[2]}
        osd_id=${values[0]}
        size=$(numfmt --to iec ${values[1]})

        if [[ $device == *"/dev/mapper/mpath"* ]]; then
                mpath=$(multipath -ll -v2 $device | grep -o -E "sd[a-z]+" | tr '\n' ' ')
                serial=$(multipath -ll -v2 $device | grep -E -o "mpath[a-z]+ \([a-z0-9]+" | sed -E "s/mpath[a-z]+ \(//g")
                dev=$(echo $mpath | cut -d ' ' -f 2)
                serial2=$(smartctl -a "/dev/${dev}" | grep -i "serial number:" | tr -d ' ' | cut -d ':' -f 2)
                echo "OSD: ${osd_id} (${size}) / Device: ${device} / Multi: ${mpath} (Serial: $serial / $serial2)"

                for i in "${!mapped[@]}"; do
                        if [[ ${mapped[i]} = $device ]]; then
                                unset 'mapped[i]'
                        fi
                done
        else
                echo "OSD: ${osd_id} (${size}) / Device: ${device}"
        fi

done

echo -e "\n------------------------------"
echo "Unmapped device mapper devices: ${#mapped[@]}"
for f in "${mapped[@]}"
do
        mpath=$(multipath -ll -v2 $f | grep -o -E "sd[a-z]+" | tr '\n' ' ')
        serial=$(multipath -ll -v2 $f | grep -E -o "mpath[a-z]+ \([a-z0-9]+" | sed -E "s/mpath[a-z]+ \(//g")
        dev=$(echo $mpath | cut -d ' ' -f 2)
        serial2=$(smartctl -a "/dev/${dev}" | grep -i "serial number:" | tr -d ' ' | cut -d ':' -f 2)
        echo "Device: ${f} / Multi: ${mpath} (Serial: $serial / $serial2)"
done

Example output:
1659353333622.png
 
And in case someone needs a script to list OSDs with corresponding devices (incl. multipath and their member disks) as well as not used multipath devices.

Bash:
#!/bin/bash

data=$(ceph-volume lvm list --format json)

ar=($(echo $data | jq -r 'to_entries | sort_by(.key | tonumber) | map(.key + ":" + .value[0].lv_size + ":" + (.value[0].devices | join( ",")))' | tr -d '[],"'))
mapped=($(ls /dev/mapper/mpath*))

echo -e "\n------------------------------"
echo -e "OSD count: ${#ar[@]}\n"

for f in "${ar[@]}"
do
        values=(${f//:/ })
        device=${values[2]}
        osd_id=${values[0]}
        size=$(numfmt --to iec ${values[1]})

        if [[ $device == *"/dev/mapper/mpath"* ]]; then
                mpath=$(multipath -ll -v2 $device | grep -o -E "sd[a-z]+" | tr '\n' ' ')
                serial=$(multipath -ll -v2 $device | grep -E -o "mpath[a-z]+ \([a-z0-9]+" | sed -E "s/mpath[a-z]+ \(//g")
                dev=$(echo $mpath | cut -d ' ' -f 2)
                serial2=$(smartctl -a "/dev/${dev}" | grep -i "serial number:" | tr -d ' ' | cut -d ':' -f 2)
                echo "OSD: ${osd_id} (${size}) / Device: ${device} / Multi: ${mpath} (Serial: $serial / $serial2)"

                for i in "${!mapped[@]}"; do
                        if [[ ${mapped[i]} = $device ]]; then
                                unset 'mapped[i]'
                        fi
                done
        else
                echo "OSD: ${osd_id} (${size}) / Device: ${device}"
        fi

done

echo -e "\n------------------------------"
echo "Unmapped device mapper devices: ${#mapped[@]}"
for f in "${mapped[@]}"
do
        mpath=$(multipath -ll -v2 $f | grep -o -E "sd[a-z]+" | tr '\n' ' ')
        serial=$(multipath -ll -v2 $f | grep -E -o "mpath[a-z]+ \([a-z0-9]+" | sed -E "s/mpath[a-z]+ \(//g")
        dev=$(echo $mpath | cut -d ' ' -f 2)
        serial2=$(smartctl -a "/dev/${dev}" | grep -i "serial number:" | tr -d ' ' | cut -d ':' -f 2)
        echo "Device: ${f} / Multi: ${mpath} (Serial: $serial / $serial2)"
done

Example output:
View attachment 39553
do your machines boot ok after mapping up the multipath OSDs as my test machine hangs on until I remove the was links then I plug them in and it works. but its boots until I activate the multipath as a OSD.
 
On my side everything is working flawless.
Make sure your LVM config and HBA Drivers are setup right and included in the initramfs.
 
Last edited:
out of curiosity, is this still an issue?, is there a device name filter that can be adjusted?.

multipath for physical SAS redundancy is a must (multipath JBOD cages)
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!