Skip to content

Instantly share code, notes, and snippets.

@tomzo
Last active October 21, 2015 13:12
Show Gist options
  • Save tomzo/053856d075e1c0bd212c to your computer and use it in GitHub Desktop.
Save tomzo/053856d075e1c0bd212c to your computer and use it in GitHub Desktop.
Ceph reweight OSD slowly
#!/bin/bash
# Usage:
# ceph-reweight-slowly <OSD-ID> <IN or OUT>
#
# OUT will reweight osd from 1 to 0 in 0.1 decrements.
# E.g. when removing osd 1 from cluster: `ceph-reweight-slowly 1 out`
# IN will reweight osd from 0 to 1 in 0.1 increments.
# E.g. when adding osd 5 to cluster: `ceph-reweight-slowly 5 in`
#
# This has minimal impact on cluster performance.
# Definitely lower than when reweighting at once
set -e
OSD=$1
DIRECTION=$2
if [ -z "$OSD" ]; then
echo "Please specify osd number"
exit 1
fi
if [ -z "$DIRECTION" ]; then
echo "Please specify direction (in or out)"
exit 1
fi
if [[ $DIRECTION == "out" ]]
then
for i in 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.0
do
echo "Reweighting OSD $OSD to $i and waiting"
ceph osd reweight $1 $i
sleep 30
while [ $(ceph -s | grep backfil -c) -gt 0 ]; do echo -n .;sleep 30; done
done
echo "OSD reweighted to 0"
elif [[ $DIRECTION == "in" ]]
then
for i in 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
do
echo "Reweighting OSD $OSD to $i and waiting"
ceph osd reweight $1 $i
sleep 30
while [ $(ceph -s | grep backfil -c) -gt 0 ]; do echo -n .;sleep 30; done
done
echo "OSD reweighted to 1"
else
echo "Direction must be in or out"
exit 1;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment