Replace (one or more!) ceph journal disk
Simple script used to replace journal disk. I regenerate journal UUID for convenience but you can also keep as it is.
The layout is the following :
disk /dev/sda : 5 journal partitions -> 5 OSD (OSD.40 to OSD.44)
disk /dev/sdb : 5 journal partitions -> 5 OSD (OSD.45 to OSD.49)
disk /dev/sdc : 5 journal partitions -> 5 OSD (OSD.50 to OSD.59)
First, set the noout flag to prevent any data migration.
ceph osd set noout
Then stop each OSD which are related to the first journal disk.
#!/bin/bash
partitions="1 2 3 4 5"
num=40
for partition in $partitions
do
systemctl stop ceph-osd@$num.service
ceph-osd -i $num --flush-journal
((num++))
done
Hotswap the first journal disk, then execute the following script :
#!/bin/bash
partitions="1 2 3 4 5"
# First OSD number
num=40
# Disk
disk=sda
for partition in $partitions
do
journal_uuid=$(uuidgen)
sgdisk --new=$partition:0:+5120M --change-name=$partition:'ceph journal' --partition-guid=$partition:$journal_uuid --typecode=$partition:$journal_uuid --mbrtogpt -- /dev/$disk
partprobe /dev/$disk
mv /var/lib/ceph/osd/ceph-$num/journal /var/lib/ceph/osd/ceph-$num/journal.old
ln -s /dev/disk/by-partuuid/$journal_uuid /var/lib/ceph/osd/ceph-$num/journal
mv /var/lib/ceph/osd/ceph-$num/journal_uuid /var/lib/ceph/osd/ceph-$num/journal_uuid.old
echo $journal_uuid > /var/lib/ceph/osd/ceph-$num/journal_uuid
chown -R ceph. /var/lib/ceph/osd/ceph-$num/journal
chown ceph. /var/lib/ceph/osd/ceph-$num/journal_uuid
ceph-osd -i $num --mkjournal
chown ceph. /dev/$disk$partition
systemctl start ceph-osd@$num.service
((num++))
done
Process if necessary with sdb
and sdc
and adjust the OSD start number in the script.
Last step : unset the noout flag
ceph osd unset noout
Source file :
Github link
Reference:
Sébastien Han blog