Last active
May 28, 2019 17:54
-
-
Save drakonstein/cb76c7696e65522ab0e699b7ea1ab1c4 to your computer and use it in GitHub Desktop.
Split Ceph Filestore OSDs offline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
merge_num=-2 | |
split_num=16 | |
while [[ "$(ceph health)" != "HEALTH_OK" ]]; do | |
sleep 10 | |
done | |
# Some method to set your ceph.conf file to the subfolder splitting settings you want. | |
# If you are not changing the ceph.conf settings, then you can start the osd at the end of the loop instead of at the end. | |
conf=/etc/ceph/ceph.conf | |
if ! grep -q '^\[global\]' $conf; then | |
echo $conf is badly formed | |
exit | |
fi | |
merge=$(grep -E filestore.merge.threshold $conf) | |
merge=${merge:-false} | |
split=$(grep -E filestore.split.multiple $conf) | |
split=${split:-false} | |
if [[ "$merge" != false ]]; then | |
sudo sed -i "/filestore.merge.threshold/c filestore_merge_threshold = $merge_num" $conf | |
else | |
sudo sed -i "/^\[global\]/a filestore_merge_threshold = $merge_num" $conf | |
fi | |
if [[ "$split" != false ]]; then | |
sudo sed -i "/filestore.split.multiple/c filestore_split_multiple = $split_num" $conf | |
else | |
sudo sed -i "/^\[global\]/a filestore_split_multiple = $split_num" $conf | |
fi | |
ceph osd set noout | |
sudo systemctl stop ceph.target && sleep 30 | |
for osd in $(sudo mount | grep -Eo ceph-[0-9]+ | cut -d- -f2 | sort -nu); do | |
for run_in_background in true; do | |
echo "Starting osd $osd" | |
sudo -u ceph ceph-osd --flush-journal -i=${osd} | |
for pool in $(ceph osd lspools | gawk 'BEGIN {RS=","} {print $2}'); do | |
sudo -u ceph ceph-objectstore-tool --data-path /var/lib/ceph/osd/ceph-${osd} \ | |
--journal-path /var/lib/ceph/osd/ceph-${osd}/journal \ | |
--log-file=/var/log/ceph/objectstore_tool.${osd}.log \ | |
--op apply-layout-settings \ | |
--pool $pool \ | |
--debug | |
done | |
echo "Finished osd.${osd}" | |
# sudo systemctl start ceph-osd@${osd}.service | |
done & | |
done | |
wait | |
# set ceph.conf back to normal before starting the OSDs | |
if [[ "$merge" != false ]]; then | |
sudo sed -i "/filestore.merge.threshold/c \\${merge}" $conf | |
else | |
sudo sed -i "/filestore.merge.threshold/d" $conf | |
fi | |
if [[ "$merge" != false ]]; then | |
sudo sed -i "/filestore.split.multiple/c \\${split}" $conf | |
else | |
sudo sed -i "/filestore.merge.multiple/d" $conf | |
fi | |
echo starting OSDs | |
sudo systemctl start ceph.target | |
while true; do | |
stat=$(ceph osd stat) | |
up=$(echo "$stat" | grep -Eo '[[:digit:]]+\s+up' | awk '{print $1}') | |
in=$(echo "$stat" | grep -Eo '[[:digit:]]+\s+in' | awk '{print $1}') | |
if (( $up == $in )); then | |
ceph tell osd.\* injectargs --osd_max_backfills=3 | |
ceph osd unset noout | |
break | |
else | |
sleep 10 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment