Created
February 13, 2019 18:32
Revisions
-
drakonstein created this gist
Feb 13, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,53 @@ #!/bin/bash # Name: osd_omap_compaction.sh # # This will compact the omap dbs on OSDs # Wait until the cluster is Healthy HEALTH_OK=${1:-"HEALTH_OK"} while [[ "$(ceph health)" != "$HEALTH_OK" ]]; do sleep 10 done osds=$(ceph osd crush ls $(hostname -s) | cut -d. -f2) ceph osd set noout # For each OSD, we want to run it's commands in the background so all OSDs will run at the same time for osd in $osds; do osd_type=$(ceph osd metadata $osd | grep 'osd_objectstore') if echo $osd_type | grep -q filestore; then db=$(sudo grep -aEo [[:alpha:]]+db /var/lib/ceph/osd/ceph-${osd}/superblock) elif echo $osd_type | grep -q bluestore; then db=bluestore-kv else echo $osd has an invalid type exit 1 fi ( echo "================================================================================" sudo systemctl stop ceph-osd@$osd omap=/var/lib/ceph/osd/ceph-${osd}/current/omap sudo -u ceph ceph-kvstore-tool $db $omap compact sudo systemctl start ceph-osd@$osd ) & done wait # Wait until all OSDs are back up and in and then increase osd_max_backfills to speed up recovery between nodes 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=2 ceph osd unset noout break else sleep 10 fi done for osd in $osds; do sudo du -sh /var/lib/ceph/osd/ceph-${osd}/current/omap done